Add Prefix / Suffix to Lines
FREE TOOL · NO SIGN-UP
This tool lets you add a prefix and suffix to lines in bulk, so you can put the same text at the start or end of every line in seconds. Paste a list, type what should go before and after each item, and copy the finished result. It’s perfect for marketers, developers and anyone who needs to wrap lists in quotes, add commas, build URLs or turn plain lines into HTML.
What the Prefix and Suffix Tool Does
Editing a long list by hand is slow and error-prone. Change 300 lines one by one and you’ll almost certainly miss a few. This tool applies the same change to every line at once.
Adding text to start and end
Whatever you type in Prefix is added to the beginning of each line, and whatever you type in Suffix is added to the end. You can use one or both. A prefix of https://example.com/ turns a list of slugs into full URLs. A suffix of , turns a column of values into a comma-separated list. Both together, such as " and ",, wrap each line in quotes and separate them with commas.
The prefix and suffix are added exactly as typed, including spaces. If you want a space between the prefix and the line, include it at the end of the prefix.
Handling blank lines
Lists copied from spreadsheets, documents or emails often contain empty lines. With Skip empty lines switched on (the default), they’re removed before the prefix and suffix are applied, so you don’t end up with lines that contain only "",. Turn it off if the blank lines matter, for example when they separate groups.
Trim lines is also on by default. It removes leading and trailing spaces from each line before anything is added, which stops hidden spaces from ending up inside your quotes or URLs.
How to Add a Prefix or Suffix to Every Line
The output updates live as you type.
Step 1 – Paste your list
Paste your text into the Lines box, one item per line. It can be keywords, URLs, product IDs, email addresses, names or code values.
Step 2 – Enter prefix
Type the text that should appear at the start of every line into Prefix. Leave it empty if you only need a suffix.
Step 3 – Enter suffix
Type the text for the end of every line into Suffix. Leave it empty if you only need a prefix. Check the two options and decide whether to keep blank lines and surrounding spaces.
Step 4 – Copy the output
The result appears with a line count and character totals. Click Copy to grab it, or Download to save it as a .txt file. Clear resets everything.
Ready-Made Recipes
These combinations cover the most common jobs. Type the prefix and suffix exactly as shown.
Quotes and commas for code
- Quoted, comma-separated values: prefix
', suffix',gives'red','blue',for SQLIN (...)lists or arrays. - Double-quoted JSON strings: prefix
", suffix",gives"red",ready to drop inside[ ]. - Comma-separated list: prefix empty, suffix
,. If you want everything on one line instead, our Comma Separator does that directly. - Commented-out lines: prefix
//or#to disable a block of code or config.
Remember to remove the trailing comma from the last line where your language doesn’t allow it.
HTML li and links
- List items: prefix
<li>, suffix</li>, then wrap the result in<ul>and</ul>. - Table cells: prefix
<td>, suffix</td>. - Links from URLs: prefix
<a href=", suffix">Link</a>creates a working link for each URL. Edit the anchor text afterwards, or use our HTML Link Generator for more control over attributes.
SEO and PPC Uses
Exact and phrase match brackets
In Google Ads and Microsoft Advertising, keyword match types are set with punctuation. Paste your keyword list, then use prefix [ and suffix ] for exact match, or prefix " and suffix " for phrase match. Broad match needs no symbols. It’s much faster than editing each keyword, and you can paste the result straight into the ads editor. If you need every combination of several word lists, the Keyword Combiner builds them first.
Bulk URL building
Turn a list of slugs or page paths into full URLs by adding your domain as a prefix, for example https://example.com/blog/. Add a trailing slash or UTM parameters as a suffix. This is handy for building redirect lists, sitemap inputs, crawl lists or disavow files.
Doing It in Excel, Sheets or Editors
CONCAT formulas
In Excel or Google Sheets, put your list in column A and use a formula like ="'"&A1&"'," or =CONCAT("'",A1,"',") in column B, then fill it down. It works well for data already in a spreadsheet, but the online tool is quicker for a one-off list.
Regex in Notepad++ and VS Code
Code editors can do this with find and replace using regular expressions. Search for ^ to target the start of each line, or $ for the end, and replace with your prefix or suffix. It works, but it’s easy to get wrong if you don’t use regex often.
Bulk Edit Mistakes
Trailing spaces
Invisible spaces at the end of lines end up inside quotes and URLs. Keep Trim lines switched on unless you need them.
Extra comma on the last line
The suffix goes on every line, including the last. Delete the final comma when pasting into JSON or SQL, where a trailing comma causes an error.
Lost line breaks
Some apps paste lists as one long line. If the tool shows a line count of 1, fix the line breaks at the source first.
Format Any List in One Pass
When the same edit needs to happen on every line, let the tool do it. Use the add prefix and suffix to lines tool for quotes, commas, tags and URLs, then clean up repeats with the Duplicate Line Remover, number items with the Line Numbering Tool or swap words across the list with Find and Replace Text. Browse the full set of FHSEO Hub free SEO tools for more text utilities.
