Numbered lines exist for one reason: so that two people can talk about the same place in a document without ambiguity. Code review comments, contract clause references, transcript timestamps and bug reports all depend on a number that both sides can see, and pasting a plain block into a chat window throws that away.
Nothing you paste leaves your device. Numbering is pure string work performed locally, so a proprietary log file or an unpublished draft is never uploaded, queued or stored anywhere.
When you need to add line numbers to text
The clearest signal is that you are about to describe a location in words. If a message is heading towards phrases like the third line from the bottom, numbering the block first is faster for everyone and impossible to misread.
The second case is preparing a document for people who are not using your editor. Your editor shows line numbers in a gutter, but that gutter does not survive a copy and paste, so the numbers have to become part of the text itself.
- Quoting a specific line in a code review, a ticket or a chat message.
- Referencing clauses or paragraphs in a contract or a policy document.
- Preparing a transcript, a script or a set of lyrics for line by line notes.
- Turning a plain list into an ordered one for a printed handout.
- Making a long log excerpt navigable when you attach it to a bug report.
Start number, padding and separator
Three settings control the shape of the prefix. The start number is usually 1, but it should be something else whenever your block is an extract: if the excerpt begins at line 240 of the original file, numbering it from 240 keeps every reference to it correct.
Padding decides the width of the number. Without padding, line 9 and line 10 are different widths and the text after them no longer lines up, which looks untidy and makes scanning slower. Zero padded line numbers fix that by writing 009 and 010, and the tool can pick the width automatically from the number of lines so nothing is wider than it needs to be.
The separator is what sits between the number and the content. A colon and a space is the most readable default, a tab suits pasting into a spreadsheet, and a bare space is best when the result is going into a code block where extra punctuation would be noise.
How this line numbering tool treats blank lines
Blank lines are the one genuine decision in an otherwise mechanical job, and different tools answer it differently. Counting them keeps the numbers aligned with the original file, which is what you want when the numbers must match an editor gutter. Skipping them produces a cleaner ordered list, which is what you want when the numbering is for presentation.
This line numbering tool exposes both, and a third option that numbers only the non blank lines while still emitting the blank ones unnumbered. That last mode is the right choice for prose, where the empty line between paragraphs is a separator rather than content.
Trailing blank lines at the end of the input are ignored by default so that a stray newline does not add a phantom final entry.
Line endings, tabs and why counts sometimes differ
Text files end their lines in one of two ways. Unix and the web use a single line feed, while Windows uses a carriage return followed by a line feed. Software that splits on the wrong one either misses every break or leaves an invisible carriage return at the end of each line.
The tool normalises both forms before it counts, so a file written on Windows and a file written on Linux produce the same numbering. That is also why the line count here can differ by one from an editor that counts a trailing newline as an extra empty line.
Tab characters inside the text are left untouched. They are content, not layout, and rewriting them would change the meaning of anything indentation sensitive such as Python or a Makefile.
Removing line numbers again
Numbered text often arrives from somewhere else, pasted out of a code viewer or a PDF, and the numbers get in the way of running or editing it. The strip mode reverses the operation, removing a leading number and its separator from every line while leaving the rest of the line, including its indentation, exactly as it was.
Detection is deliberately conservative. Only a number at the very start of a line, optionally followed by a colon, a full stop, a bracket or whitespace, is treated as a prefix. A line that legitimately begins with a figure, such as a year in a data table, can still match, so review the result before you rely on it.
Between the two modes of this line numbering tool you can renumber as well. Strip the old numbers, then number lines in a text file again with a different start or padding, which is far quicker than editing each line by hand.
| Setting | Result |
|---|---|
| Start 1, no padding, colon | 1: first / 2: second / 3: third |
| Start 240, no padding, colon | 240: first / 241: second / 242: third |
| Start 1, padded to 3, space | 001 first / 002 second / 003 third |
| Start 1, no padding, tab | 1 (tab) first / 2 (tab) second / 3 (tab) third |
| Strip mode | first / second / third |
How to add line numbers to text
- 1
Paste your text
Drop a plain text file or paste the block directly. Windows and Unix line endings are both handled.
- 2
Set the start number
Leave it at 1 for a whole document, or set it to the original line number when the block is an extract.
- 3
Choose padding and a separator
Pick automatic padding so every number is the same width, then choose the characters that sit between the number and the text.
- 4
Decide how blank lines count
Number every line to match an editor gutter, or skip blank lines when the result is a presentation list.
- 5
Copy or download
Press the action, then copy the numbered text or download it as a plain text file.
Related tools worth bookmarking
Sources and further reading
- MDN: String.prototype.padStartThe method behind zero padding, including how it behaves when the value is already wider than the target width.developer.mozilla.org
- Unicode UAX #13: Newline GuidelinesThe reference for how carriage return, line feed and the other line separators should be interpreted in text.unicode.org
- W3C: CSS Text white space handlingExplains how browsers preserve or collapse line breaks and spaces, which is why numbered text can look different once rendered.w3.org
Frequently asked questions
Common questions about the line numbering tool.
Yes. Set any starting value, including a large one. This matters when the block you are numbering is an extract from a larger file and the numbers need to match the positions in that original document.
Padding writes every number to the same width, so 009 and 010 line up instead of shifting the text sideways. It also keeps the lines in correct order when the result is later sorted alphabetically rather than numerically.
That is your choice. Numbering them keeps the count aligned with an editor gutter, skipping them produces a tidier ordered list, and the third mode keeps blank lines in place without giving them a number.
Yes. Strip mode removes a leading number and its separator from each line while preserving indentation. It only matches a number at the very start of a line, so lines that merely contain digits are left alone.
Yes. Carriage return and line feed pairs are normalised before numbering, so a file saved on Windows and the same file saved on Linux produce identical output with no stray characters at the end of lines.
No. All the work happens in your browser tab with no network request, so a private log file or an unpublished draft never leaves your machine. You can verify this in your browser network panel.