Free Add Prefix and Suffix to Each Line
Paste a list and wrap every line with a prefix, a suffix, or both. Optionally add an incrementing line number and skip blank lines, all live in your browser.
Numbers are inserted right after the prefix as "N. ". With skip-empty on, blank lines stay unchanged and are not counted.
Quick answer
To add a prefix and suffix to each line, paste your text, type the characters you want before each line in the Prefix box and after each line in the Suffix box. The tool splits your input on newlines, prepends the prefix (optionally with a running number) and appends the suffix to every line, then joins them back together. Enable "skip empty lines" to leave blank lines untouched.
Formula & method
Per-line transformation
newLine = prefix + (numbered ? counter + ". " : "") + line + suffix
- prefix — Text added before each line
- suffix — Text added after each line
- numbered — Whether a running line number is inserted
- counter — Current line number, starting from the chosen start value and incrementing by 1
- line — The original line of text
Lines are split on the newline character and re-joined with newlines after transformation. When skip-empty is enabled, blank lines pass through unchanged and are not counted.
browser
Examples
- Input
- apple banana cherry
- Result
- - apple - banana - cherry
- Why
- With prefix "- " and an empty suffix, the prefix is prepended to every line and the lines are re-joined, turning a plain list into a Markdown-style bullet list.
- Input
- Alice Bob Carol
- Result
- Alice, Bob, Carol,
- Why
- With an empty prefix and suffix ",", a trailing comma is appended to every line, which is handy for assembling a column of comma-separated values.
- Input
- Buy milk Walk dog Call mom
- Result
- - 1. Buy milk. - 2. Walk dog. - 3. Call mom.
- Why
- With prefix "- ", suffix ".", numbering on, and start value 1, each line becomes prefix + "N. " + line + suffix, producing a numbered, punctuated checklist.
- Input
- red blue
- Result
- > red > blue
- Why
- With prefix "> ", an empty suffix, and "skip empty lines" enabled, the blank middle line is left untouched while the two non-empty lines are quoted.
When to use this tool
- Turning a plain list into Markdown bullets, blockquotes, or HTML list items by adding the same prefix and suffix to every line.
- Building SQL IN-clauses, CSV columns, or code arrays by quoting and comma-terminating each line at once.
- Numbering steps, tasks, or references where you need a running count and a consistent wrapper around each entry.
Common mistakes
- Forgetting that a prefix or suffix you type may already contain a trailing space, so "-" and "- " produce different alignment.
- Expecting line numbers to count blank lines too. When skip-empty is on, empty lines are passed through and are not numbered, so numbering stays continuous over the real content.
- Leaving a trailing newline in your input, which creates a final empty line that also gets a prefix and suffix unless skip-empty is enabled.
Frequently asked questions
How do I add the same text to the beginning of every line?
Paste your text, type the characters you want into the Prefix box, and leave the Suffix box empty. The prefix is prepended to each line instantly and the result updates as you type. Use the Copy button to grab the output.
Can I add a prefix and a suffix at the same time?
Yes. Fill in both the Prefix and Suffix boxes and each line will be wrapped with the prefix in front and the suffix at the end. For example, prefix "<li>" and suffix "</li>" turns each line into an HTML list item.
How do I add line numbers to each line?
Enable the "Add line numbers" option. The tool inserts a running number formatted as "N. " right after your prefix, starting from the value in the Start at field and incrementing by one per line. You can combine it with a prefix and suffix.
Will blank lines get a prefix and suffix too?
By default yes, because every line is processed. Turn on "Skip empty lines" to leave blank or whitespace-only lines untouched. When that option is on, blank lines are also not counted by the line numbering.
Does numbering start at 1 or can I change it?
You can change it. Set the Start at field to any whole number and the count begins there, so you can continue a list that already reached, say, 10 by starting at 11.
Is my text uploaded anywhere?
No. All processing happens locally in your browser using plain JavaScript. Your text never leaves your device, so it is safe to use with private or sensitive lists.
How are lines detected?
The tool splits your input on the newline character, so each visual line becomes one entry. Wrapping caused only by the textarea width does not create a new line; only actual line breaks do.
Sources & references
External references open in a new tab. We are independent and not affiliated with these organizations.
- ✓ Free to use
- ✓ No sign-up required
- ✓ Runs entirely in your browser — nothing is uploaded.
- ✓ Formula and method shown above
Provided “as is” for general information only — results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.
Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.
Related tools
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the add prefix and suffix to each line to appear: