My Tool Studio
Text

Add Prefix and Suffix to Each Line

Type text into the Prefix and Suffix fields and this tool will add prefix and suffix to each line of your list at once. Turn slugs into full URLs, wrap values in quotes for a CSV, build a SQL IN list, or make HTML list items and Markdown checklists. One-click templates fill both fields, and {n} inserts a running number from any start value. Apply it to each line, each word, or items split by commas, tabs or your own separator, and trim each item first. Remove mode does the reverse and strips a prefix or suffix. Skip empty lines is on by default, so blank rows stay blank. Developers and anyone preparing a bulk import use it to avoid editing hundreds of lines by hand.

Always freeNo sign upRuns in your browser
Templates:
Tip: type {n} in either field to insert the line number.

How to use

01

Set the prefix and suffix

Choose Add or Remove and what to Apply to, then type the prefix and suffix, or click a template such as SQL ('value'), or HTML <li>. Either field can stay empty.

02

Paste your lines

Paste your list into Your lines, or press Try sample to load three product slugs with a blank line. The Result pane updates as you type.

03

Handle blanks and copy

Leave Skip empty lines ticked to pass blank lines through, and tick Trim if items have stray spaces. Add {n} for numbering, then press Copy or Download .txt.

Why Add Prefix and Suffix to Each Line

Examples: URLs, SQL values and quoted CSV

Each row shows the prefix and suffix used and what the sample line red-running-shoes becomes. Click the matching template to fill both fields at once, or type them yourself if no template fits. The {n} examples assume it is the first line. For lists that end up in code, check the last line: most SQL and JSON formats do not accept a comma after the final value.

GoalPrefixSuffixResult for red-running-shoes
Full URLhttps://example.com/products//https://example.com/products/red-running-shoes/
SQL VALUES row(''),('red-running-shoes'),
SQL IN list item'','red-running-shoes',
Quoted CSV value"","red-running-shoes",
HTML list item<li></li><li>red-running-shoes</li>
Markdown checklist- [ ] (none)- [ ] red-running-shoes
Numbered list{n}. (none)1. red-running-shoes
Numbered file nameimg-{n}-.jpgimg-1-red-running-shoes.jpg

Common questions

How do I add text to the beginning of each line?
Type the text into the Prefix field and paste your lines. Every non-empty line in the Result pane starts with that text. Clear the Suffix field if you only want the prefix.
How do I add a comma or quotes to the end of each line?
Put the comma in the Suffix field. For quoted values, click the "Quoted", template, which sets the prefix to a double quote and the suffix to a double quote and a comma. Remember to delete the comma after the last line if your format does not allow a trailing one.
How do I number each line with the prefix and suffix tool?
Type {n} in the prefix or suffix, for example {n}. followed by a space, or click the Numbered list template. {n} is replaced by 1, 2, 3 and so on, or from the number in {n} starts at. When Skip empty lines is ticked, blank lines are not counted.
How do I build a SQL IN list or VALUES rows from a list?
For VALUES rows, click SQL ('value'), and each line becomes ('value'),. For an IN list, set the prefix to a single quote and the suffix to a single quote and a comma. Remove the comma after the last item, and escape any single quotes inside your values before running the query.
Can I turn a list of slugs into full URLs?
Yes. Click Full URL, then change https://example.com/ in the Prefix field to your own domain and path. Each slug becomes a complete URL with a trailing slash; clear the Suffix field if your site does not use one.
What does Skip empty lines do when adding a prefix?
With it ticked, blank lines and lines with only spaces pass through unchanged and are not counted by {n}. Untick it and blank lines get the prefix and suffix too, which is rarely wanted in URL or SQL lists.
Can I add a prefix to each word instead of each line?
Yes. Set Apply to to Each word and every word gets the prefix and suffix, for example # for hashtags or quotes around each term. Line breaks stay where they are. For comma or tab separated values, pick that option instead so each item between separators is changed.
Are spaces in the prefix and suffix kept?
Yes, both fields are applied exactly as typed, including leading and trailing spaces. If the output looks shifted, check the field for a space you did not mean to type.
Can this tool remove a prefix or suffix from each line?
Yes. Click Remove, then type the prefix and suffix to strip. Each line that starts with the prefix loses it, and each line that ends with the suffix loses that too. Lines without them are left as they are, and the counter shows how many lines changed. The match is exact, including spaces and capitals.

More Text tools

View all