Adding a prefix to each line on Mac means concatenating a literal string of up to 200 Unicode characters to the start of every logical line in your text, without regex, escaping, or reformatting the original content. On a Mac you have several native options for this job: TextEdit's find-and-replace, the Terminal's sed and awk, BBEdit's multi-line grep, or the multi-cursor trick in VS Code. Each of them works, but each comes with a small ergonomic tax, such as regex syntax in sed, character class escaping in VS Code, or the limited find box in TextEdit. A browser-based tool that treats your prefix as a plain string, preserves your line order and whitespace, and outputs a UTF-8 TXT file is the simplest path when you want predictable results without context-switching into another app. The Add Prefix and Suffix to Lines tool does exactly that, and it runs entirely in your browser, which means your data never leaves the machine you are working on.

What Mac Users Usually Reach For First
Three built-in paths exist on macOS for prepending text to every line, and each one shows up in tutorials online. TextEdit can do it through Find & Replace with the "Insert pattern" option, but that field expects you to escape literal characters and use capture syntax, which makes a simple prefix feel heavier than it should. The Terminal's sed 's/^/PREFIX/' file.txt is the canonical command and it works, but you have to remember which characters need escaping (forward slash, ampersand, backslash) and that the command treats the prefix as a regex pattern. VS Code on macOS supports the multi-cursor shortcut Cmd+Option+Down to drop a cursor at the start of each selected line, which is genuinely fast for short files; the catch is that you have to know the difference between a "soft" line break and a "physical" one, and you have to type the prefix by hand for each cursor.
Each of these methods works. The friction is the same in all of them: the prefix you type is interpreted as something other than itself. Regex in sed, capture patterns in TextEdit, and even macro recording in BBEdit all add a layer between you and the literal string you actually want. When you are decorating a list of SQL identifiers, building markdown checkboxes, or wrapping every line in JSON quotes, predictability matters more than raw speed.
A Literal Alternative on Mac
The Add Prefix and Suffix to Lines tool treats the prefix and suffix as plain strings. Brackets, dollar signs, backslashes, asterisks, parentheses, and quotes are inserted exactly as you type them, with no regex replacement tokens and no Markdown, HTML, or code interpretation. That makes the result predictable for SQL fragments, shell comments, list markers, logging tags, and simple data preparation.
You paste up to one million characters into the browser, type the prefix (and optionally a suffix) into its own field, choose whether blank lines should be decorated or skipped, and the tool generates the exact result in a preview that preserves spaces and newlines. You can then download the output as a TXT file. The transformation runs locally in your browser using JavaScript strings, and the downloadable file is created as a UTF-8 plain-text Blob, so there is no server round-trip and no upload step.
How to Add a Prefix to Each Line on Mac
- Open the tool in Safari, Chrome, or any browser on your Mac, and paste (or type) the lines you want to decorate into the input area.
- Enter a prefix, a suffix, or both into their respective fields. Each field accepts up to 200 Unicode characters, including emoji and non-Latin text. Toggle "Leave blank lines unchanged" if you want empty or whitespace-only lines to stay as they are.
- Read the generated result in the preview to confirm it looks right, then click the download button to save a TXT file labeled UTF-8.
Edits to the input, prefix, suffix, or blank-line setting automatically clear the old result and revoke its download URL, so an outdated result cannot be saved after you have changed the inputs.
Mac Line Ending Behavior You Should Know
Text files on macOS have historically used different line endings than files shared with Windows or Linux. Classic Mac files used CR (carriage return, \r) on its own; Windows uses CRLF (\r\n); and Unix, Linux, and modern macOS use LF (\n). If you copy text out of a Word document or a CSV exported on Windows, you can end up with CRLF boundaries in your "lines," and a naive line counter or regex will misbehave.
The Add Prefix and Suffix to Lines tool recognizes all three boundary styles, CRLF, CR, and LF, when it splits your input into logical lines, then joins the result with LF consistently in the generated output. That means you can paste text from any source and the file you download will have the same line break on every line, which is what most downstream editors and build systems expect.
One quirk worth knowing: a trailing newline in your input creates one final empty logical line. If "Leave blank lines unchanged" is on, that trailing line stays empty in the output; if it is off, the trailing line receives the prefix and suffix. The behavior is deliberate so the result does not silently lose the final line boundary represented by the input. With that option enabled, both empty strings and lines containing only whitespace are returned exactly as they were, so a line with spaces is not decorated and its spaces are not removed; whitespace handling here follows the documented String trim semantics, but is only consulted when the skip option is on.
Tasks Mac Users Decorate Lines For
The same operation, concatenate prefix + line + suffix, covers a surprising range of everyday work on a Mac. The table below lists the cases the tool is built for, with the prefix (and where relevant, suffix) you would type.
| Task | Prefix | Suffix | Why literal matters |
|---|---|---|---|
| Shell comment block | # | (none) | No escaping needed for # or spaces. |
| Markdown bullet list | - | (none) | Dash and space appear verbatim. |
| Markdown checklist | - [ ] | (none) | Brackets are inserted as characters, not regex groups. |
| SQL IN list | ' | ' | Both quote marks are literal; $ in values stays unchanged. |
| JSON array values | " | " | Wraps identifiers safely; commas are added separately by the user. |
| Log prefix tag | [INFO] | (none) | Square brackets are not interpreted as character classes. |
| HTML class names | class=" | " | Quotes are inserted verbatim, no HTML escaping performed. |
For numeric prefixes (1., 2., 3., …), the dedicated Add Line Numbers to Text tool handles starting offset, padding, and separators in one pass. For wrapping values in quotes with proper JSON, SQL, or CSV escaping, the Add Quotes to Each Line tool applies the escaping rules each format actually requires.
Things the Tool Deliberately Does Not Do
Knowing what the tool is not designed for keeps you from reaching for the wrong tool. The prefix and suffix are never interpreted as regular expressions, replacement tokens, or template syntax, so $1 or \d appear in your output as the literal characters $, 1, \, d. The tool does not trim the start or end of a line, collapse internal whitespace, change letter case, remove tabs, sort entries, or deduplicate values. A line with a single space remains a line with a single space, untouched, unless you turn off the "Leave blank lines unchanged" option and let whitespace-only lines be decorated too.
The preview is rendered in a preformatted region that preserves spaces and newlines while allowing long visual wrapping; that visual wrap is purely cosmetic and does not add a real newline to the file you download. The downloadable file contains the generated string as UTF-8 plain text with no byte-order mark, no rich-text styling, no spreadsheet quoting, and no automatic delimiter detection. If you need CSV-safe escaping or a BOM for a downstream system that requires one, verify or escape the result separately. The tool also does not add sequential numbers, parse CSV fields, edit a Word document, or infer syntax.
When a Mac Terminal Command Is the Better Fit
For very large files or for repeatable jobs that you run as part of a build script, sed -i '' 's/^/PREFIX/' file.txt on macOS is hard to beat. The empty quoted string after -i is the BSD sed convention on Mac that prevents it from writing a backup file. The tool covered here is the better fit when you want a literal prefix without regex, when you would rather not type escape sequences on a Mac keyboard, when you want a UTF-8 TXT file at the end rather than an in-place edit, or when you need to handle CRLF input from a Windows source without manually preprocessing it. If you find yourself copying text into a browser anyway, the browser step is short and the result is a file you can verify before saving.
For deeper context on why literal insertion is a different category from regex replacement, see Add a Prefix to Each Line Without Regex or Escaping. For a more complete look at how the browser tool compares to native macOS apps and the Terminal, see Add Prefix and Suffix to Lines: The Browser Alternative.