Add a prefix or suffix to each line

Wrap every line with a prefix and a suffix, for bullets, quotes, SQL values or HTML list items. Blank lines get wrapped too.

Output
Enter text to see output.

What to know

Two fields do all the work: Prefix goes at the start of each line and Suffix at the end. With the prefix a dash and a space and the suffix a semicolon, the lines alpha, beta and an empty line become - alpha;, - beta; and a final - ; for the empty one.

Every line is wrapped, empty ones included, and lines are not trimmed first, so spaces already on a line stay inside the wrapper. If you do not want wrapped blanks, run remove empty lines before this one.

The text is added exactly as typed. Nothing is escaped, which makes it handy for markup and code: a prefix of <li> and a suffix of </li> turns a plain list into list items, and a prefix of a quote with a suffix of a quote and comma builds the body of an array. For SQL, remember that quotes inside your data still need escaping by you.

Leave one field empty to add only a prefix or only a suffix. If you also need a separator between the finished lines, pass the output through join lines afterwards, for example to get a comma-separated list of quoted values.

Choose a specific task 10
Related tools 4
How to use Add a prefix or suffix to each line
  1. Paste your items, for instance 12 city names, one per line, into the Text input box.
  2. Type <li> in the Prefix field and </li> in the Suffix field to produce HTML list items.
  3. Scan the Output panel for stray wrapped blanks, which look like an empty li, and remove them with remove empty lines on the input if present.
  4. Copy the result into your template, or save it as chatcument-text-output.txt.

Quick answers

Do blank lines receive the prefix and suffix?

Yes, every line is wrapped, so an empty line comes out as just the prefix followed by the suffix.

Can I add only a suffix?

Yes. Leave Prefix empty and fill in Suffix, and each line gains the text at its end only.

Are quotes or HTML characters escaped?

No. Prefix and suffix are inserted literally, so any escaping that your target format needs must be added yourself.

How do I make a single comma-separated line of quoted values?

Wrap each line with quote marks here, copy the output, and run join lines with a comma as the separator.