Add Prefix and Suffix to Lines

Add text to the start and end of every line, with optional line numbers via {n}. Skip empty lines. Great for lists, code and Markdown. Runs in your browser.

Options

Tip: {n} in the prefix or suffix is replaced by the line number (1, 2, 3…).

Runs entirely in your browser. Your data is never uploaded.

What is Add Prefix and Suffix to Lines?

Adds the same text before and/or after every line of a list. The placeholder {n} inserts the line number, so you can create numbered lists, quoted strings, HTML list items or code lines in one step.

How to use Add Prefix and Suffix to Lines

  1. Paste your lines into the Input box.
  2. Type the text to add in Prefix and/or Suffix – use {n} for the line number.
  3. Keep Skip empty lines on to leave blank lines untouched.
  4. Copy the result from Output.

Example

Input
a
b
Output
1. a;
2. b;

Prefix "{n}. ", suffix ";"

When to use Add Prefix and Suffix to Lines

Use it whenever every line needs the same wrapper: quotes and commas for an array, <li> tags, Markdown bullets, > for quotes, or numbering. For conditional or pattern-based edits, use the Regex Tester's replace feature instead.

How Add Prefix and Suffix to Lines works

The input is split into lines. For every line (except empty ones when skipping is on) the prefix and suffix are added, with every {n} replaced by a counter that starts at 1 and only counts lines that were actually changed. All other characters in prefix and suffix are used literally.

Common Use Cases

  • Wrapping lines in quotes and commas for a code array
  • Turning lines into HTML <li> elements
  • Numbering lines: "{n}. " as prefix
  • Adding a domain or path in front of a list of slugs
  • Quoting an e-mail reply with "> "

FAQs

How do I number lines?

Put {n} in the prefix, for example "{n}. " or "{n}) ".

Are empty lines numbered?

Not when Skip empty lines is on; numbering continues with the next non-empty line.

Can I add text in the middle of a line?

No, only at the start and end. Use the Regex Tester with a replacement for that.

Explore more categories