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β
- Paste text β Any number of lines.
- Type prefix and / or suffix β Either or both. Empty allowed for either side.
- Configure β Skip empty lines, add to all (including blanks), per-line numbering (1., 2., ...), line ending (LF / CRLF).
- 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.
Last updated: 2026-05-06 Β· Author: Ahsan Mahmood Β· Edit this page on GitHub