Text Tools

Prefix / Suffix Lines

Add the same prefix and suffix to every non-empty line.

Results are provided for general informational use. Verify important financial, health or legal figures before relying on them.

About this Prefix / Suffix Lines

The Prefix / Suffix Lines tool adds repeated text before and/or after each non-empty line. It is useful for preparing lists, adding quotes, building simple syntax and bulk-editing structured text.

Adding the same prefix or suffix to every line of a list is a common need when formatting data for import into another system, such as wrapping each item in quotation marks or adding a bullet character to a plain list.

How the calculation works

The tool processes each line independently and leaves blank lines blank. The prefix and suffix are inserted as literal text.

How to use it

  1. Paste one or more lines.
  2. Enter an optional prefix and suffix.
  3. Apply the change to every non-empty line.

Practical example

Adding prefix “<li>” and suffix “</li>” can quickly wrap a plain list in simple HTML list-item tags.

Adding the prefix dash-space and no suffix to a plain three-item list instantly converts it into a properly formatted Markdown bullet list, ready to paste directly into a Markdown document.

Things to double-check

This tool applies the chosen prefix and suffix only to non-empty lines by default, since applying them to blank lines as well would typically create unwanted stray text where there was previously just empty space.

Adding text to every line

Enter a prefix, a suffix or both, and the tool adds them to each line of the text. With the prefix a dash and a space, a list of names becomes a Markdown bullet list. With a prefix of an opening quote and a suffix of a closing quote followed by a comma, a column of values becomes a list ready for code. Empty lines are skipped, so blank spacing is not filled with stray text.

Typical formats

Common patterns include wrapping lines in HTML list tags with li, adding a base web address to a list of page paths, turning words into quoted array items or SQL list values, and adding a number sign to make tags. For an SQL IN list, use single quotes as prefix and suffix plus a comma in the suffix, then remove the final comma by hand.

Watch for special characters

If your lines already contain quotes or apostrophes, wrapping them can break the result. A name like O'Brien inside single quotes needs the apostrophe doubled in SQL or escaped with a backslash in code. Clean or escape such values first. The final line of a list often should not end with a comma, so edit the last line after the conversion.

Check and test

Run the tool on a few lines first to confirm that the spacing is right, since a missing space after a dash gives -item instead of - item. Read the output in the place where it will be used, such as your editor or database tool, to catch errors. For large lists, use the Line Counter to confirm that the number of lines has not changed.

Before and after examples

Suppose the lines are apple, banana and cherry. Adding the prefix li opening tag and the suffix li closing tag turns each line into a list item such as an li element around apple. Adding the prefix of a web address, such as https://example.com/ to a list of page names, creates full links. Adding quotes and a comma creates a list of strings ready for code. Preview the first lines, then apply the change to the whole text, and use the Line Counter to confirm that the number of lines is unchanged.

Building lists for code and data

To create a list for an SQL IN clause, put a single quote as the prefix and a single quote plus a comma as the suffix, then wrap the whole list in brackets and remove the last comma. For a JSON array of strings, use a double quote as the prefix and a double quote with a comma as the suffix. For a list of web addresses, use the base address as the prefix. Always check the first and last lines, and make sure that values do not contain the quote character you used.

Worked example: a list for a database query

Take three city names on separate lines: Karachi, Lahore and Islamabad. Using a single quote as the prefix, and a single quote followed by a comma as the suffix, produces 'Karachi', then 'Lahore', then 'Islamabad', each on its own line. Wrap the lines in IN ( and ) and remove the final comma, and you have a list ready for a database query. With the prefix of an option opening tag and the suffix of the closing tag, the same three lines become the choices of an HTML drop-down list.

Other useful patterns

Adding a pound sign to a list of words creates hashtags. Adding a base address to a list of page names creates links. Adding a dash and a space creates a Markdown list, and adding a number and a full stop, if you type the numbers, creates a numbered one. A prefix of a class name and a suffix of a semicolon can build CSS declarations from a list of values. Any time you need to apply the same wrapper to many lines, this tool turns a long manual job into a single step.

Escaping special characters

Before you wrap lines in quotes, check whether the text contains quotes itself. In SQL, an apostrophe inside a string is written twice, so O'Brien becomes 'O''Brien'. In JSON and most programming languages, a double quote or backslash inside a string needs a backslash before it. Run a find and replace on those characters before you add the prefix and suffix. The last line of a list usually should not end with a comma, so edit it by hand after the conversion.

Check the result

Preview the first few lines, then apply the change to the entire list and review the first and last lines in particular. Use the Line Counter to confirm that the number of lines has not changed, and paste a few lines into the place where you will use them to see that they work. For lists that you generate often, a spreadsheet formula that joins text around a cell achieves the same result and is easy to repeat. Keep the original list in case you need a different format later.

Key terms explained

A prefix is text added to the start of a line and a suffix is text added to the end. A wrapper is a pair of prefix and suffix around a value. A delimiter separates items. Escaping adds a backslash or doubles a character so that it is treated as plain text. A string literal is text in quotes within code. A list item is one entry in a list. A template is a pattern with fixed and variable parts. A trailing comma is a comma after the last item.

Rules of thumb and quick checks

Preview the first lines before you apply a change to the whole list. Check for quote characters inside the values, and escape them first. Remove the final comma if the format does not allow it. For SQL lists, double any single quote inside a value. Keep the original list, count the lines before and after, and paste a sample into the target system to confirm it works.

Frequently asked questions

Can I add only a prefix?

Yes. Leave the suffix blank.

Are blank lines changed?

No. Blank lines remain blank.

Can I use symbols or HTML-like text?

Yes. The strings are inserted literally into the textarea.

Can I add different prefixes to different lines at once?

This tool applies one consistent prefix and suffix to every line in a single pass; for varied per-line formatting, the list would need to be split and processed separately.

Will this add the prefix and suffix to blank lines too?

By default it skips empty lines, since adding text to a blank line usually isn't the intended result.

Keep exploring

More Text Tools

View category →