Append and Prepend Tool – Add Text to Each Line Online
Instantly add custom prefixes (prepend) and suffixes (append) to every line of your text in real time. Whether you need to wrap plain lists in HTML <li> tags, format values with quotes and commas for SQL IN queries and JSON arrays, prepend domain URLs, or add customizable line numbers, this tool processes thousands of lines in a single click.
How to Use the Append and Prepend Tool
- Paste Your List – Enter your multi-line text into the Source Text box on the left, or click Load Sample to test with an example list.
- Set Prefix & Suffix (or Pick a Preset) – Type the characters you want to add before each line in Text to Prepend and after each line in Text to Append, or click one of the Quick Presets (such as
HTML <li>,JSON "item",, orSQL 'item',). - Add Optional Line Numbering – Enable Add sequential line numbers to number each row starting from
0,1, or any custom integer with your chosen step increment and format. - Copy or Download – Your result updates live without overwriting your original input. Click Copy to Clipboard or Download .txt when finished.
Cheat Sheet: Common Developer & Data Formatting Recipes
Use these combinations of Prepend and Append settings to automate repetitive coding and spreadsheet tasks in seconds:
| Task / Use Case | Prepend (Before Line) | Append (After Line) | Recommended Option |
|---|---|---|---|
SQL IN Clause List |
' |
', |
Check Omit trailing comma on last line |
| JSON / JS String Array | " |
", |
Check Omit trailing comma on last line |
| HTML Unordered/Ordered List | <li> |
</li> |
Check Trim leading & trailing spaces |
| HTML List with Unique IDs | <li id="item-{n}"> |
</li> |
Uses dynamic {n} placeholder |
| Markdown Task Checklist | - [ ] |
(leave blank) | Check Skip empty lines |
| Full URLs from Slug List | https://example.com/ |
/ |
Check Trim leading & trailing spaces |
Using Dynamic Placeholders ({n}, {0n}, {total})
Unlike basic prefix/suffix tools that only allow static text, our generator supports dynamic counter tokens directly inside both the Prepend and Append fields:
{n}– Inserts the current line number (respecting your custom Start at and Step by settings).{0n}/{00n}– Inserts the current line number zero-padded to 2 digits (01,02) or 3 digits (001,002).{total}– Inserts the total count of processed lines (e.g.,[Step {n} of {total}]).
Frequently Asked Questions
How do I avoid a trailing comma on the last line when formatting SQL or JSON lists?
Enable the Omit trailing comma on last line checkbox under General Options (or click the JSON "item", or SQL 'item', Quick Preset, which turns it on automatically). Every line except the last active line will end with a comma.
Can I start line numbering at 0 for zero-indexed arrays?
Yes! Set the Start at input to 0 under Line Numbering Options. You can also set negative starting numbers or change Step by to 2, 5, or 10.
Will clicking "Apply Changes" overwrite my original input text?
No. Your original list stays safely in the Source Text box while the formatted result is generated live in the separate Result box below, allowing you to adjust prefixes, suffixes, and numbering formats at any time without duplicating tags.
How can I remove prefixes or suffixes from lines instead of adding them?
If you need to strip existing prefixes or suffixes from each line, check out our dedicated Remove Prefix From Text and Remove Suffix From Text tools linked below.