Skip to content

Add Prefix and Suffix to Each Line Online

Result

Add Text to Every Line at Once

Paste a list with one item per line, type what should go before each line in Prefix and what should go after it in Suffix. The result updates as you type, ready to copy or download as a .txt file. It saves editing dozens or thousands of lines by hand, or writing a find-and-replace regular expression.

Worked Example

Say you have a column of product codes copied from a spreadsheet:

SKU-1001
SKU-1002

SKU-1003

With Prefix ', Suffix ', and Skip blank lines on, the result is:

'SKU-1001',
'SKU-1002',

'SKU-1003',

Remove the last comma and the blank line and you can paste it straight into WHERE sku IN (...). With Add line numbers also on, the lines become 1. 'SKU-1001',, 2. 'SKU-1002', and 3. 'SKU-1003',. The blank line is skipped and not numbered.

Useful Prefix and Suffix Combinations

  • Quoted list for code or SQL: prefix ", suffix ",
  • Markdown bullet list: prefix - , no suffix
  • HTML list items: prefix <li>, suffix </li>
  • Full URLs from paths: prefix https://example.com, suffix /
  • Hashtags: prefix #, no suffix
  • Commented-out lines: prefix // or #

Why Not Use Find and Replace?

Most editors can do this with a regular expression: search for ^(.*)$ and replace it with '$1',. That works if you remember the syntax and your editor supports it, but it also wraps blank lines, and numbering lines needs a different approach. Spreadsheets can do it with a formula like ="'"&A1&"'," filled down a column, which means an extra column and a copy-paste-values step. Typing the prefix and suffix here is quicker for a one-off job, and you can see the result before you copy it.

Options

Skip blank lines leaves empty lines untouched so paragraph gaps or section breaks in your list survive. Add line numbers puts "1. ", "2. " and so on in front of each line before the prefix, which is handy for numbered instructions or for referring to items by position.

Related Tools

Clean the list before you add text to it: remove duplicates and sort the lines. When you need everything on one line, for example a comma-separated list, use Remove Line Breaks. To check two lists against each other, use List Diff. Everything runs in your browser, so lists containing customer or product data never leave your device.

Related Tools

Frequently Asked Questions

How do I wrap every line in quotes?
Type a quote mark in Prefix and the same quote mark in Suffix. To build a list for code or SQL, put ', in the suffix (quote then comma) so each line ends with a comma. Remember to delete the comma after the last item if your language does not allow trailing commas.
What happens to blank lines?
With Skip blank lines on (the default), empty lines and lines with only spaces are left exactly as they are and are not numbered. Turn it off if you want the prefix and suffix added to every line, including empty ones.
Where does the line number go?
Line numbers are added first, in the form '1. ', followed by the prefix, the original line and the suffix. Numbering counts only the lines that were changed, so skipped blank lines do not use up a number.
Can I add a prefix only, or a suffix only?
Yes. Leave either box empty. For example, put '- ' in Prefix alone to turn lines into a Markdown bullet list, or put a semicolon in Suffix alone to end each statement.
Are spaces in the prefix and suffix kept?
Yes. Whatever you type is added exactly, including spaces. If you want a space between the prefix and the line, include it at the end of the prefix.