Saved

Press the star next to a tool's name to save it.

All my tools

Add Prefix and Suffix to Lines

Add prefix and suffix to lines in one step: paste a list, type the text to put before and after each line, and copy the wrapped result.

Type a prefix, a suffix or both. Blank lines are left alone unless you change the option.

Everything is worked out in your browser. Nothing you type is sent anywhere.

Result

Your wrapped lines will appear here.

Turning a plain list into something a program can use often means wrapping every line in the same characters: quotation marks and a comma for an array, an HTML tag around each item, a dash at the start of a bullet or a domain name after each username. Doing that by hand for hundreds of lines is slow and error prone. This add prefix and suffix to lines tool does it in one step.

How to add prefix and suffix to lines

Paste your list with one item on each line. Type a prefix, which is added to the start of every line, and a suffix, which is added to the end. You can use one, the other or both. Press the button and each line is rewritten as the prefix, the original text and the suffix, joined with nothing in between. The result appears below with a note saying how many of the lines were changed, and a button to copy it.

The two options

Leave empty lines alone is on by default. Blank lines in your list stay blank instead of turning into a lonely prefix and suffix, which is almost always what you want. Switch it off if you need every line, including empty ones, wrapped. Trim spaces around each line first removes leading and trailing spaces from each line before the wrapping happens, so stray spaces in the list do not end up inside your quotation marks.

Where lines come from

A line is any piece of text that ends with a line break. Computers use different codes for that: Unix and macOS use a line feed, Windows uses a carriage return followed by a line feed, and classic Mac OS used a carriage return. [2] The tool understands all of them and writes the result with a plain line feed. A list pasted from a spreadsheet column, a text file or an email will therefore be split into the lines you expect.

Ready-made patterns

GoalPrefixSuffixLine "apple" becomes
JSON or code list"","apple",
Labelled listItem: Item: apple
Bullet list- - apple
Email addresses@example.comapple@example.com
SQL values(''),('apple'),

Because the tool treats everything as plain text, the prefix and suffix can be any characters, including quotation marks, brackets and tags. Remember that quotation marks inside your items are not escaped, so check the output if your lines contain quotes themselves. The Wikipedia article on delimiters describes how a delimiter that also appears inside the data can cause a collision, and lists escape characters and doubling the delimiter as common fixes. [1] This tool does not escape anything for you, so it is best for simple items.

Worked example

Paste three lines: red, a blank line and blue. Set the prefix to a double quotation mark and the suffix to a double quotation mark followed by a comma. With the default options the result is "red", then a blank line, then "blue", each of the two filled lines ending with a comma, and the note reads two of three lines changed. With leave empty lines alone switched off, the blank line becomes a pair of quotation marks and a comma too, and the note reads three of three.

When a prefix and suffix save time

Wrapping lines by hand is easy for five items and miserable for five hundred. A typical case is turning a column of values copied from a spreadsheet into a quoted, comma separated list for a program: each value needs a quotation mark before it and a quotation mark plus a comma after it. Another is adding a domain name to a list of usernames to build email addresses, or a folder path to a list of file names. The same job done in a spreadsheet needs a formula and a fill-down; here you just paste, type and copy.

Because the prefix and suffix are plain text, you can also combine them for tricks: a prefix of a number sign and a space turns lines into Markdown headings, and a suffix of a space and two slashes starts a comment in many programming languages. Test your pattern on a few lines first, check the result, then paste the whole list. If the last line should not end with a comma, remove that comma by hand afterwards, since the tool wraps every line the same way.

Common uses

  • Building arrays, lists and quoted strings for code, JSON or spreadsheets.
  • Adding a label such as Item: before each entry of a list.
  • Adding a dash, number sign or bullet to the front of every line.
  • Adding a domain, file extension or unit to a long list of names.
  • Adding a path or URL start to a list of file names.

Step by step

  1. Paste your list with one item per line.
  2. Type the prefix, the suffix or both.
  3. Choose whether to leave empty lines alone and whether to trim each line first.
  4. Press Add prefix and suffix.
  5. Copy the result.

Limits and privacy

The tool handles up to two million characters in one go. It needs at least a prefix or a suffix, otherwise it shows a message, since adding nothing would change nothing. Everything runs in your browser, so your list is never uploaded. If you need to change the order of the lines afterwards, use the sort lines tool, and to remove duplicates in a spreadsheet use the Excel duplicates helper.

What next

Use this often? Add Add Prefix a to your Home screen.

Frequently asked questions

How do I add prefix and suffix to lines?

Paste your list with one item per line, type a prefix and a suffix and press the button. Every line is rewritten with them around the original text.

Can I add only a prefix or only a suffix?

Yes. Fill in just one of the two boxes and leave the other empty. You need at least one of them.

What happens to blank lines?

By default they stay blank. Switch off the option to leave empty lines alone if you want them wrapped as well.

Does the tool escape quotation marks inside my lines?

No. It adds exactly the characters you type and nothing else, so check the output if your items contain quotation marks.

Is my list uploaded?

No. The tool runs in your browser and nothing is sent to a server.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Text & Writing Tools