How to add a prefix and suffix to lines
The tool works one line at a time. It splits Input text at each newline, puts the value from Prefix at the start of each line, and puts the value from Suffix at the end. Select Skip empty lines when lines made only of spaces or other whitespace should stay as entered.
How to add text before and after each line
- Enter or paste your lines in
Input text. - Enter the text to add before each line in
Prefix. - Enter the text to add after each line in
Suffix. - Select
Skip empty lineswhen blank or whitespace-only lines should stay unchanged. - Review
Formatted output, then chooseCopywhen the result is ready.
What Prefix and Suffix add to each line
The complete Prefix value goes before the original line, and the complete Suffix value goes after it. The line text stays as entered, including spaces. Both fields are treated as literal text.
Input text:
apple
banana
cherry
Prefix: '
Suffix: ',
Formatted output:
'apple',
'banana',
'cherry',
Entering <li> and </li> writes those characters around each line. The page keeps them in the text output instead of interpreting them as HTML.
How empty lines are handled
When Skip empty lines is unchecked, the tool adds Prefix and Suffix to empty lines as well. When it is checked, a line whose characters are only spaces or other whitespace stays unchanged. Lines with other characters are processed in either setting.
An empty Input text keeps Formatted output hidden. The tool does not trim the source lines or check the text entered in Prefix and Suffix.
Where adding a prefix and suffix comes up
For an HTML list, enter <li> as the Prefix and </li> as the Suffix. The resulting tags remain visible in Formatted output for review before you paste the lines elsewhere.
For a quoted list, enter a quote as the Prefix and a quote followed by a comma as the Suffix. To mark notes, enter - as the Prefix; leave Suffix empty and select Skip empty lines to keep blank spacing.
When another text formatting tool fits better
See Text Formatting & Layout Tools for related text tasks. Text Formatter combines line numbers, prefixes and suffixes, and indentation in one workflow.
Use Text Wrapper to wrap lines to a chosen width while preserving paragraph breaks. Use Indent Text for indentation, tab-to-space conversion, space-to-tab conversion, or a hanging indent.
Frequently asked questions
How do I add text before and after each line?
Enter the source in Input text, put the leading text in Prefix, and put the trailing text in Suffix. The result appears in Formatted output after a field changes.
Can I add a prefix and suffix without changing blank lines?
Yes. Select Skip empty lines. Empty and whitespace-only lines stay as entered, while lines containing other characters receive the Prefix and Suffix.
Does Add Prefix & Suffix preserve spaces in each line?
Yes. The line text stays as entered, including spaces. The Prefix and Suffix are placed around it without trimming the line.
Where does the formatted text appear?
The processed text appears in the read-only Formatted output area. Use Copy to copy the result when it is available.