# Add Prefix and Suffix to Each Line

URL: https://hifreetools.com/text/add-prefix-suffix-lines

> 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.

## 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

- Per-line transformation: newLine = prefix + (numbered ? counter + ". " : "") + line + suffix

The text is split on newlines, each line becomes prefix + optional "N. " number + line + suffix, and the lines are re-joined. It all runs in your browser.

## Examples

- Prefix only (bullet list): apple banana cherry → - apple - banana - cherry
- Suffix only (build a CSV column): Alice Bob Carol → Alice, Bob, Carol,
- Numbered with prefix and suffix: Buy milk Walk dog Call mom → - 1. Buy milk. - 2. Walk dog. - 3. Call mom.
- Skip empty lines: red blue → > red > blue

## FAQ

**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

- [MDN - String.prototype.split()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
- [MDN - Array.prototype.join()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "Add Prefix and Suffix to Each Line", https://hifreetools.com/text/add-prefix-suffix-lines
