Skip to content
Toolew.com

Add Prefix and Suffix to Lines

Add text before and after every line, with presets for quoted lists, SQL VALUES, HTML list items, Markdown bullets and comments.

Runs in your browser. Your data is not uploaded.
Loading tool…

Tool guide

What this tool does

Add Prefix and Suffix to Lines wraps each line of a list in the text you specify. Presets cover the common jobs, such as quoting values for code, building SQL rows or HTML list items, and a {n} placeholder inserts a running number.

Developers and analysts constantly reshape lists: a column of IDs copied from a spreadsheet needs quotes and commas before it can go into an IN clause, a list of names must become HTML list items, or every line of a config needs commenting out. Doing it with a text editor’s multi-cursor works, but only if you have such an editor open and the list is short.

Here you type a prefix and suffix, or pick a preset, and every line is rewritten instantly. The {n} placeholder inserts a counter starting at any value, and {line} repeats the line’s own text inside the prefix or suffix. For the quote and SQL presets, quotes inside values are escaped, so O’Brien becomes O''Brien in SQL, preventing broken statements. A final option removes the trailing comma from the last line so the list is ready to paste. All processing happens in the browser.

How to use Add Prefix and Suffix to Lines

  1. Paste your list into the Lines box, one item per line.
  2. Choose a Preset, or keep “Custom prefix and suffix” and type your own Prefix and Suffix.
  3. Use {n} in the prefix or suffix to number lines, and set “First value of {n}”.
  4. Keep “Trim spaces around each line first” on to remove stray spaces copied from spreadsheets.
  5. Leave “Escape quotes inside values” and “Remove trailing comma from the last line” on for code and SQL.
  6. Copy the result or download it as a text file.

Tips for better results

  • For a SQL IN list, use the single-quote preset and wrap the output in parentheses: WHERE id IN (…).
  • A prefix of “https://example.com/products/” and an empty suffix turns a list of slugs into full URLs.
  • Use \t in a custom prefix or suffix to insert a tab and build two-column, spreadsheet-ready text.
  • The Markdown task preset (“- [ ] ”) converts a plain list into a checklist for GitHub issues or notes apps.

Common use cases

  • Turning a column of customer IDs into a quoted, comma-separated list for a database query.
  • Generating <li> elements for a navigation menu from a list of page names.
  • Commenting out a block of shell or Python configuration lines with “# ”.
  • Creating numbered labels like “Item {n}: ” in front of each product line.

Common mistakes to avoid

  • Switching off escaping and then pasting a value with an apostrophe into SQL, which ends the string early.
  • Forgetting that empty lines are skipped by default, so the {n} counter does not count them either.
  • Copying the output into code without checking the last line still needs, or should not have, a trailing comma.

Frequently asked questions

What do {n} and {line} do?

{n} is replaced with a running number that starts at your chosen value and increases by one per processed line. {line} is replaced with the line’s own text, so a suffix such as “ = {line}” can repeat the value.

How are quotes escaped?

With the double-quote preset a double quote or backslash inside a value gets a backslash in front, as in JSON and JavaScript strings. With single-quote and SQL presets an apostrophe is doubled, the escaping rule used by standard SQL.

Can I add text only to the start or only to the end?

Yes. Leave the other field empty. A prefix alone indents or labels lines; a suffix alone is handy for adding commas, semicolons or line-end markers.

What happens to blank lines?

With “Leave empty lines unchanged” on, blank lines pass through without a prefix or suffix, which is usually what you want for grouped lists. Turn it off to wrap them as well.

Feedback & suggestions

Help us improve Add Prefix and Suffix to Lines. We read every message.

Rating (optional)
Necessary
Required for security, language and theme preferences. Always on.