Skip to main content

add-prefix-to-lines

Adding a prefix or suffix to every line in a block of text is a common bulk-edit task β€” turn 100 names into "Hello, name" lines, comment out 50 lines of code, indent paragraphs, prefix log lines with timestamps. The ZTools Add Prefix to Lines tool adds prefix and/or suffix to every non-empty line, optionally to blank lines too, with configurable line endings and per-line numbering. Faster than opening a code editor for one-off transformations.

Use cases​

Comment out a block of code​

Add "// " prefix to 50 lines. Faster than 50 keystrokes.

Build SQL VALUES list from a column​

Paste 1000 user IDs, prefix "(", suffix ")," β€” get "(1)," "(2)," ready for INSERT.

Format a list as Markdown bullets​

Prefix "- " to every line.

Generate an HTML <li> list​

Prefix "<li>", suffix "</li>".

How it works​

  1. Paste text β€” Any number of lines.
  2. Type prefix and / or suffix β€” Either or both. Empty allowed for either side.
  3. Configure β€” Skip empty lines, add to all (including blanks), per-line numbering (1., 2., ...), line ending (LF / CRLF).
  4. Apply β€” New text with the modification. Original preserved.

Examples​

Input: 3 lines "alice\nbob\ncarol", prefix "Hello, "

Output: "Hello, alice\nHello, bob\nHello, carol".


Input: Same with suffix "!"

Output: "Hello, alice!\nHello, bob!\nHello, carol!"


Input: Numbered prefix "1. ", "2. ", ...

Output: "1. alice\n2. bob\n3. carol".


Input: Comment-out: prefix "// "

Output: Every line prefixed with the comment marker.

Frequently asked questions​

Does it handle CRLF (Windows) line endings?

Yes β€” auto-detected and preserved. Toggle output to force LF or CRLF.

How are blank lines handled?

By default skipped. Toggle "include blanks" to also prefix them β€” useful for code commenting where blank lines need "//" too.

Can I prefix every Nth line only?

Toggle "every Nth line" β€” applies prefix to lines 1, N+1, 2N+1, etc.

Privacy?

All in browser.

Tips​

  • For SQL VALUES lists, prefix "(" + suffix ")," β€” then strip the trailing comma manually.
  • For Markdown, "- " (dash + space) is the universal bullet prefix.
  • For commenting code, the "include blanks" toggle preserves layout β€” without it, blank lines stay uncommented and you lose visual structure.
  • For long batches, paste as JSON or CSV first β€” the tool can also auto-prefix CSV-row index.

Try it now​

The full add-prefix-to-lines runs in your browser at https://ztools.zaions.com/add-prefix-to-lines β€” no signup, no upload, no data leaves your device.

Open the tool β†—


Last updated: 2026-05-06 Β· Author: Ahsan Mahmood Β· Edit this page on GitHub