Add Prefix and Suffix to Lines

Add the same text to the beginning and end of every line in one go. Wrap items in quotes, add commas for a list, turn lines into HTML list items or build SQL values, without editing line by line.

  • 100% free, no sign-up
  • Runs in your browser: text never uploaded
  • Instant results

Add to every line

Presets

How to use the Add Prefix and Suffix

  1. Paste your lines, one item per line.

  2. Type the text to add at the start of each line in Prefix, and at the end in Suffix.

  3. Tick Skip empty lines to leave blank lines untouched.

  4. Click Apply to every line, then copy the result.

Examples

HTML list items
Input
Prefix <li>, suffix </li>:
apple
banana
Result
<li>apple</li>
<li>banana</li>
Quoted, comma-separated values
Input
Prefix ', suffix ',:
red
green
Result
'red',
'green',

Who uses it

Developers turn a column of IDs into an array or SQL list without writing a script. Marketers add tracking parameters or hashtags to many lines at once. Writers and editors add bullets or quotation marks to a list of quotes. Data teams wrap values in quotes before importing them into a spreadsheet or database.

Remember the last line: if you are building a comma-separated list, you may need to delete the final comma by hand.

Preparing your list

For tidy results, start with one item per line and no stray spaces. Run messy text through Remove Extra Spaces, sort and deduplicate it with the List Sorter, and use Find and Replace to change separators, for example replacing commas with line breaks, before adding your prefix and suffix.

Worked example: a SQL IN list from a spreadsheet column

You have 200 order IDs in a spreadsheet column and need to query them:

  1. Copy the column and paste it here. Each ID is on its own line.
  2. Set Prefix to ' and Suffix to ',.
  3. Click Apply to every line. Each line now looks like 'A1042',.
  4. Copy the result into your query between WHERE order_id IN ( and ), and delete the comma after the last ID.

The same steps with " and ", produce items for a JSON or JavaScript array.

Worked example: an HTML list from plain text

Paste a list of features, one per line, set Prefix to <li> and Suffix to </li>, then wrap the result in <ul> and </ul>. For a Markdown list, use - as the prefix and leave the suffix empty; for a numbered Markdown list, 1. works on every line because Markdown renumbers automatically.

Tips

  • Tick Skip empty lines so blank lines between groups do not end up as empty quotes or tags.
  • Trailing spaces at the end of a line will sit inside your suffix. Clean them first if that matters, for example for CSV values.
  • If your text uses Windows line endings, the tool still treats each line separately.
  • Need the same text in the middle of each line instead? Use Find and Replace on a separator character.

Frequently asked questions

Yes. Leave either field empty and only the other one is added.

Last reviewed by the WordTools Pro team. How our tools work