Skip to main content

Add a prefix or suffix to every line

Add a prefix, a suffix or both to every line of a text, keeping the line order and, if you wish, leaving blank lines untouched.

  • Clipboard
  • Export
Automate

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

How does this tool work?

Add the same text to the start, the end or both sides of every line in a list. In a few seconds a column copied from a spreadsheet becomes a bulleted list, quoted values for an SQL query, HTML list items or lines ending with a comma. The preview updates as you type and everything is processed in your browser.

The tool splits the text at line breaks, whether they come from Windows (CRLF), macOS or Linux (LF), then writes the prefix, the original line and the suffix for each line. Nothing else changes: spaces at either end of a line, tabs and letter case stay as they are, and the line order is kept.

The prefix and suffix are inserted exactly as typed, spaces included. Type “-” followed by a space to get “- Paris” rather than “-Paris”. No character is interpreted: a $, a \n or a backslash is copied literally. To insert a tab, copy one from an editor and paste it into the field.

By default blank lines, including lines made only of spaces or tabs, are left untouched, so a list split into groups keeps its gaps without stray bullets. Turn the option off to edit those lines too, for instance to keep a Markdown quote continuous with “>” on every line.

A final line break does not create an extra line and is kept in the result. Output line breaks are LF; if a program requires CRLF, convert the result afterwards with the line ending converter.

How to use this tool

  1. Paste the list

    Type or import a text with one item per line.

  2. Enter the prefix and suffix

    Fill in one field or both; the preview follows every keystroke.

  3. Copy or export

    Check the first and last lines, then copy the result or download it as a text file.

Use cases

Build an SQL list

Wrap identifiers in single quotes and end each line with a comma to build an IN clause.

Make a bulleted list or checklist

Put “-” or “- [ ]” before each task to get a Markdown list ready to paste into a ticket or a note.

Tag HTML items

Surround each line with <li> and </li> to turn a copied list into HTML list items.

Examples

Quoted values for an SQL query

Prefix ' and suffix ',. The blank line is left as it is; remove the last comma before closing the IN clause.

Input

Paris
Lyon

Nantes

Result

'Paris',
'Lyon',

'Nantes',

Markdown checklist

Prefix “- [ ]” with a trailing space. The text’s final line break is kept, with no extra bullet.

Input

Buy bread
Call Lea

Result

- [ ] Buy bread
- [ ] Call Lea

Continuous quote

Prefix “>” with the blank-line option turned off: the blank line gets the prefix too, so the quote stays in one piece.

Input

a

b

Result

> a
> 
> b

Tips and best practices

  • For a list meant for code, check the last line: a suffix such as a comma is often one too many there.
  • If your values already contain quotes, escape them before wrapping them in quotes, or the resulting query or JSON will be invalid.
  • Trim leading and trailing spaces first when the list comes from a PDF: the prefix would otherwise sit in front of those spaces.
  • To number lines rather than add fixed text, use the line numbering tool.

Frequently asked questions

Can I add only a suffix?

Yes. Leave the Prefix field empty and only the suffix is added. The reverse works too.

Are the spaces in my prefix kept?

Yes. The prefix and suffix are copied character for character, spaces included. Add a space after a bullet to separate it from the text.

What happens to blank lines?

They are left untouched by default, including lines that contain only spaces. Turn the option off to add the prefix and suffix to them as well.

Are Windows line endings handled?

Yes. CRLF, LF and CR are recognised, so the suffix never ends up after an invisible carriage return. The result uses LF.

How do I add a different number to each line?

The prefix is the same on every line. For an increasing number, use the Number lines tool, then add a suffix here if needed.

Related tools

Tools similar or complementary to this one.

Similar tools

Automatically add a number in front of every line, in the format you choose.

Text & writingUse this tool

Automatically remove empty lines and lines containing only spaces from a text.

Text & writingUse this tool

Replace a text fragment in a pasted or imported document.

Text & writingNewUse this tool