How to Add Line Numbers to Text: Code, Logs, and Reference

When you need to refer to specific lines in a block of text — code snippets, log output, or lists — adding line numbers makes it easy for others (or future you) to say “see line 5” or “the error is on line 12”. A line number generator takes your text and prepends a number to each line, with options for start number, separator, and alignment.
Here’s when and how to use one, and what to expect from a good tool.
What Is a Line Number Generator?
A line number generator takes text (one or more lines) and adds a line number at the start of each line. You get output like:
1 | first line2 | second line3 | third line
You choose how the numbers appear: start number (e.g. 1 or 100), separator (pipe, spaces, dot, or paren + tab), and whether to pad numbers so the text column lines up. Everything runs in your browser — no data is sent to a server.
When to Use Line Numbers
- Code snippets — Add line numbers before pasting into docs, tutorials, or support replies so you can say “see line 5” or “the bug is on line 12”.
- Logs — Number log output for easier reference in tickets, discussions, or post-mortems.
- Lists — Number a list (tasks, items, steps) for reference without editing the original.
- Teaching — Provide numbered text for exercises (“answer referring to line 3”) or handouts.
- Data / CSV — Add row numbers to a column of values for debugging or reference.
Options: Start Number, Separator, Padding
- Start number — The number assigned to the first line (default 1). Use a higher value if you’re continuing from a previous block (e.g. start at 100).
- Separator — What appears between the number and the line text. Pipe (
|) is common and readable; spaces give a minimal gap; dot or paren + tab mimic editor styles (e.g.1.or1)with a tab). Choose based on where you’ll paste the result. - Pad numbers — When on, line numbers are right-aligned (e.g.
1,10,100) so the text column lines up. When off, numbers are not padded. Padding is especially useful for long blocks (10+ lines).
Is My Text Sent to a Server?
No. A good line number generator runs entirely in your browser. Your text never leaves your device — safe for code, logs, or sensitive content.
Try the Line Number Generator
The Tooladex Line Number Generator lets you paste any text, set the start number and separator (pipe, space, dot, or paren + tab), and optionally pad numbers for alignment. Copy the result with one click. All processing in your browser — no account, no data sent to a server.
Line Number Generator
Add line numbers to any text. Choose start number, separator (pipe, space, dot), and optional padding. Copy numbered output for code, logs, or reference.