Add Prefix and Suffix to Each Line Online
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
Markdown Preview
Write Markdown and see the rendered HTML output in real time.
Lorem Ipsum Generator
Generate placeholder text in paragraphs, sentences, or words.
List Deduplicator
Remove duplicate lines from a list with options for case sensitivity and sort order.
List Diff / Compare
Compare two lists and find items unique to each, shared between both, or missing from one.