Add text to the start and end of every line

Type a prefix, a suffix or both, and the tool adds them to every line of your list, so "apple" becomes 'apple', or "home" becomes https://example.com/home.

Live demo · real result from this tool

Result

'apple', 'banana', 'cherry',

Processed on your device — nothing is uploaded.

How to use add prefix and suffix

  1. Paste your lines into One item per line.
  2. Type the text to add before each line in Prefix and after each line in Suffix. Either can be left empty.
  3. Leave Leave empty lines alone ticked so blank lines stay blank. Untick it to wrap blank lines too.
  4. Copy the result.

What it does and when to use it

Adding the same text to dozens of lines by hand is slow and error-prone. Spreadsheet formulas and code editors can do it, but this tool is quicker for a one-off job. Some common prefix and suffix pairs:

Goal Prefix Suffix
Quoted items for code ' ',
HTML list items <li> </li>
Full links from page slugs https://example.com/ (empty)
Markdown checklist - [ ] (empty)
Hashtags from words # (empty)
File names (empty) .jpg

For bullets in several styles, text to bullet list has them ready-made, and text to numbered list adds counting numbers. To number lines with a fixed format, add line numbers is the right tool.

How it works

The text is split at line breaks. For each line the tool writes the prefix, then the line exactly as it was, then the suffix. When Leave empty lines alone is ticked, a line that is empty or holds only spaces is passed through unchanged. Lines are then joined back with line breaks. Nothing is trimmed, escaped or checked, so what you type is what you get. The work happens in your browser.

Worked examples

These outputs come from the tool’s own function.

The default code list. apple, banana, cherry with the default prefix ' and suffix ', give 'apple',, 'banana', and 'cherry',. Remove the last comma by hand if your language does not allow a trailing comma.

Full URLs. home and about with Prefix https://example.com/ and an empty Suffix give https://example.com/home and https://example.com/about.

HTML list items. first, an empty line and second, with <li> and </li>, give the two list items with the blank line still between them. With Leave empty lines alone unticked, the blank line becomes <li></li>.

Limits and tips

  • The same prefix and suffix go on every line; there is no counter or per-line variable. Use the numbered list or line number tools for that.
  • Characters such as & or quote marks inside your lines are not escaped for HTML, SQL or JSON. Check the result if the data is unusual.

Frequently asked questions

Why do the boxes already contain quote marks?
The defaults, ' as the prefix and ', as the suffix, turn each line into a quoted list item for code, such as 'apple',. Clear both boxes and type your own text for anything else.
Can I add text only to the start, or only to the end?
Yes. Leave the other box empty. An empty prefix or suffix adds nothing.
Are spaces in the prefix and suffix kept?
Yes, exactly as typed. To get "- item", type a hyphen followed by a space in Prefix.
Does it trim my lines first?
No. Each line is used as it is, including any spaces at its start or end. Clean them first with trim lines if needed.
How do I put all the lines on one line afterwards?
Paste the result into the line joiner, which joins lines with a separator you choose. It can also add quotes itself.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close