Back to Tools

Add Prefix to Lines

Batch add text to the beginning of each line

0
0
0
Input Lines

Put the same text in front of every line

Editing a long list one line at a time is tedious, and doing it with find and replace requires a regular expression that many people do not remember. Add Prefix to Lines lets you type the text you want at the start, and it attaches it to each line in one go. The prefix can be anything: a bullet, a comment marker, a base URL, a currency symbol or a tag.

How to add a prefix

  1. Type or paste your lines into the Input Lines box, one item per line. Sample fills in a short shopping list and sets the prefix to a dash and space, Paste takes text from the clipboard, and Clear resets the tool.
  2. Fill in the Prefix field. The placeholder suggests a greater-than pair followed by a space, but you can enter anything.
  3. Leave Skip empty lines ticked if blank lines should stay blank; untick it to add the prefix to them too.
  4. Click Add Prefix.
  5. Check the result and the Before and After counts, then use Copy or .TXT (prefixed-lines.txt).

Details of the behaviour

  • The prefix is inserted exactly as typed. If you want a gap after it, include a trailing space in the field, for example a dash and a space.
  • Lines that contain only spaces are treated as empty when Skip empty lines is on, and are passed through unchanged.
  • An empty prefix field leaves the text unchanged.
  • The summary states the number of lines in the output, which includes any blank lines that were skipped.

Where it saves time

  • Turning plain lines into a quoted reply by prefixing each with a greater-than sign.
  • Commenting out a block of configuration or code with a hash or double slash.
  • Building full links from a list of file names or slugs by putting the domain and path in front.
  • Adding a bullet character or a label such as TODO before each item in a list.

Points to remember

The tool works on lines, not on wrapped paragraphs, so a long sentence that appears wrapped in your editor but is really one line only gets one prefix. Indentation is kept: the prefix goes in front of any leading spaces, not after them. To add text at the end of each line as well, use the companion suffix tool. Everything runs in your browser page, and it does not modify your input box, so you can try another prefix on the same list straight away.


Related Tools



Frequently Asked Questions

Can I add a space after the prefix?
Yes. The prefix is used exactly as you type it, so include a trailing space in the field, such as a hyphen followed by a space. Some browsers hide trailing spaces visually, but they are still applied to each line.
What does Skip empty lines do?
When ticked, lines that are empty or contain only whitespace are left untouched, so your blank separators do not get a prefix. Untick it if you want every line, including blank ones, to start with the prefix.
Does the prefix go before or after existing indentation?
Before. The text is placed at the very start of the line, in front of any leading spaces or tabs, so indentation stays after the prefix rather than being replaced.
Why does the summary count more lines than were changed?
The message reports the total number of lines in the output, and that includes blank lines that were skipped and never received the prefix. Look at the result box to see exactly which lines were changed.
Can I load a file instead of pasting?
This tool has Sample, Paste and Clear buttons but no file upload. Open your file in any text editor, copy the lines, and paste them into the Input Lines box before clicking Add Prefix.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.