How to use the Add Prefix to Each Line
Add a prefix to all lines in a few clicks:
1
Paste your text
Paste any multi-line text into the input panel.
2
Enter or select a prefix
Type your custom prefix in the input field, or click a quick preset like '// ', '# ', or '> '.
3
Toggle empty line behavior
Use 'Skip empty lines' to leave blank lines unmodified, or turn it off to prefix every single line including empty ones.
4
Copy or download the result
Click Copy to grab the prefixed text, or download as a .txt file.
When to use this tool
Use this whenever you need to batch-prepend text to multiple lines:
- →Commenting out multiple lines of code by prefixing with //, #, or --
- →Adding a consistent base URL prefix to a list of relative paths
- →Prepending a currency symbol or measurement unit to a list of numbers
- →Adding SQL line comments (--) or shell comments (#) to a block
- →Adding indentation or markup characters to each line in a data block
- →Prefixing import paths or module names to a list of identifiers
Frequently asked questions
Q:Are empty lines prefixed too?
By default, empty lines are skipped so you get clean output without '// ' or '# ' on blank lines. Toggle 'Skip empty lines' off if you need the prefix applied to every line without exception — useful for strict format requirements.
Q:Can I add both a prefix and a suffix at the same time?
This tool handles prefix only. For adding both a prefix and suffix to each line simultaneously, use the 'Wrap Text in Quotes' tool (which adds matching characters on both sides) or combine this tool's output with the 'Add Suffix to Lines' tool for full control.
Q:What are the quick presets available?
The tool includes presets for the most common use cases: '// ' for JavaScript/C/Java/CSS comments, '# ' for Python/Shell/YAML comments, '> ' for Markdown blockquotes, '- ' for Markdown unordered list items, and '* ' for alternative Markdown bullets.
Q:Does the prefix support spaces and special characters?
Yes — the prefix field accepts any characters including spaces, tabs, symbols, and Unicode. You can enter multi-character prefixes like '>>> ', 'NOTE: ', or even emoji prefixes. The tool appends your prefix exactly as typed before each line.
Q:Is there a line count limit?
No — this tool runs entirely in your browser and processes text of any size. Performance is excellent for typical use cases. For very large files (millions of lines), a command-line tool like `sed 's/^/PREFIX/' file.txt` may be faster.
Q:How can I achieve the same result in the terminal?
In a Unix/Linux terminal: `sed 's/^/PREFIX/' input.txt`. In PowerShell: `Get-Content file.txt | ForEach-Object { 'PREFIX' + $_ }`. In Python: `[f'PREFIX{line}' for line in lines]`. This tool is the browser-based alternative for quick one-off tasks without a terminal.