BLOG / GUIDE · 2026-04-11 · 7 min

How to add a prefix to every line of text

Five ways to put a string at the start of every line — Excel formula, Notepad++ regex, VS Code multi-cursor, sed/awk, or an instant browser tool. Markdown bullets, email quotes, code indent, SQL prep.

The short answer. Paste your lines into the add-prefix tool, type the prefix (- for bullets, > for quotes,      for indent), copy the result. In Excel, ="prefix " & A1 filled down. In Notepad++ with regex on, replace ^ with your prefix. In VS Code, Ctrl+ACtrl+L → multi-cursor type. On the command line, sed 's/^/prefix /' file.txt or awk '{print "prefix " $0}' file.txt.

What "add a prefix" actually means

Different jobs all reduce to the same operation: put this text at the start of every line.

  • Markdown bullets. Turning milk\neggs\nbread into - milk\n- eggs\n- bread.
  • Email quoting. Prefixing each line with > for a quoted reply.
  • Code indent. Adding four spaces or a tab to every line of a paste.
  • Log tagging. Adding a timestamp or environment tag to every line.
  • SQL prep. Prefixing each row with INSERT INTO users VALUES to turn a column of values into a sequence of statements.

The trick is that "every line" sometimes means "every non-blank line". Adding - to a blank line gives you - by itself — a bullet with no content, usually not what you want. Every method below either skips blanks by default or has a flag to do so.

How do you add a prefix in the browser, instantly?

Open the add-prefix tool. Paste your list. Type any prefix in the input box. The output updates live; copy when done.

  • Any literal string works: - for bullets, > for quotes,      for four-space indent, for a fancier bullet, [2026-05-23] for log timestamps. Trailing space included if you type it.
  • Blank lines stay blank by default. The Skip blanks toggle is on, so empty rows aren't prefixed. Turn it off if you want every row touched.
  • Order preserved. The output keeps your original line sequence exactly.
  • Nothing uploads. One map() call in the browser. Open DevTools → Network to confirm: zero outbound requests after page load.

For one-off pastes — a list of file paths to quote, a column of IDs to wrap, a Markdown grocery list — this is faster than firing up an editor.

How do you add a prefix in Notepad++ or VS Code?

Two clean paths in each editor. The right one depends on whether you want a permanent change to the file or a one-off transform.

Notepad++ — Find & Replace with regex

  1. Press Ctrl+H.
  2. Set Search Mode to Regular expression.
  3. In Find what: ^ (matches the start of every line).
  4. In Replace with: your prefix.
  5. Click Replace All.

To skip blank lines: search for ^.+ instead of ^, and use your-prefix-& in the replace (the & matches the whole found text). Or simpler, search ^(?!$) — "start of line that isn't immediately end of line" — and replace with just the prefix.

VS Code — multi-cursor

  1. Select all lines (Ctrl+A).
  2. Press Ctrl+Shift+L or Cmd+Shift+L — this puts a cursor at the start of every selected line.
  3. Press Home to snap all cursors to column 1, then type the prefix. Every line gets it simultaneously.

Or use Find & Replace with regex, same as Notepad++. The Ctrl+H.* icon → search ^ → replace with prefix recipe works identically.

How do you add a prefix in Excel?

The classic formula:

="prefix " & A1

Put it in B1, fill down. For every row in A, B now has the prefixed version.

To wrap each value in quotes for JSON or SQL preparation:

="""" & A1 & """,

Each double-quote in the formula needs to be doubled (Excel escape). The result for A1 = alice is "alice", — ready to drop into a JSON array.

For uniform indentation (e.g. for indenting a code paste), =REPT(" ", 4) & A1 prefixes with four spaces, but you'll need to copy & paste-special-as-text to strip the formula once done.

Google Sheets works identically — same syntax, same behaviour.

How do you add a prefix on the command line?

Two short recipes cover almost everything.

sed with start-of-line anchor:

sed 's/^/prefix /' file.txt

Replaces the start of every line with prefix . Add -i on GNU sed (Linux) to edit in place, or -i '' on macOS sed. To skip blank lines:

sed '/^$/!s/^/prefix /' file.txt

The /^$/! condition reads "for lines that are not empty"; the substitution only applies to those.

awk for clean concatenation:

awk '{print "prefix " $0}' file.txt

Slightly more readable than the sed version. To skip blanks:

awk 'NF { print "prefix " $0; next } { print }' file.txt

NF is "number of fields"; a blank line has zero fields and falls through to the second action, which prints it unchanged.

On Windows in PowerShell:

Get-Content file.txt | ForEach-Object { "prefix " + $_ } | Set-Content out.txt

Which method should you use?

Where the lines already areFastest method
One-off list pasted from somewhereBrowser tool
An Excel column with related data="prefix " & A1 filled down
Open in VS CodeMulti-cursor (Ctrl+ACtrl+Shift+L) → type prefix
Open in Notepad++Regex Find & Replace, ^ → prefix
A file on disk, scriptedsed 's/^/prefix /' file.txt
Need to skip blank linesBrowser tool (default) or sed '/^$/!s/^/prefix /'
Wrapping each item in quotes for JSON / SQLBrowser tool + a sibling suffix step, or Excel formula

Frequently asked questions

How do I add a prefix without prefixing blank lines?

Three short paths. (1) The browser tool with Skip blanks on (the default). (2) On the command line, sed '/^$/!s/^/prefix /' file.txt. (3) In Notepad++ or VS Code, regex search ^(?!$) and replace with the prefix.

How do I add a tab as the prefix?

In the browser tool, type a literal tab character — usually Tab works, though some browsers move focus instead, in which case copy a tab from elsewhere first. In Notepad++ with Extended mode on, \t works. In sed, type the tab between quotes or use $'\t' in bash: sed "s/^/\t/" file.txt.

What if my prefix needs to vary per line?

That's a different problem — you need a join, not a prefix. Put the per-line prefix values in a second column, then concatenate: in Excel, =B1 & A1. On the command line, paste prefixes.txt content.txt | awk '{print $1, $2}'. The fixed-string prefix tool is the right tool when the prefix is the same for every line.

How do I prefix only lines matching a pattern?

On the command line: sed '/pattern/s/^/prefix /' file.txt — only lines matching pattern get the prefix. In Notepad++ or VS Code with regex on, search for the matching part and replace with the prefix plus a back-reference ($& in Notepad++, $0 in VS Code).

How do I undo a prefix that was already applied?

Treat it as a Find & Replace, removing the prefix instead of adding it. In any editor: replace the prefix at start-of-line with nothing (^prefix "", with regex on). On the command line: sed 's/^prefix //' file.txt. The browser tool doesn't have an idempotent "strip prefix" mode yet — for now, treat add and remove as separate operations.

Is it safe to paste sensitive text into an online prefix tool?

Only if the tool runs entirely in the browser. Open DevTools → Network, paste your text, run the transformation, and watch for outbound requests. If any carry your data, the page sent it to a server. The joinlines prefix tool makes zero requests after page load — verifiable in DevTools.

— the joinlines team, 2026-04-11

§ — PRIVACY Your text never leaves your browser. No upload, no account, no logs on what you paste.
PRIVACY PAGE ↗