Add Line Numbers

Paste any block of text and this tool prefixes each line with a sequential number. It is handy for reviewing long paragraphs, citing specific lines in code reviews when line numbers are missing, preparing scripts for table reads, or turning a plain-text export into a numbered to-do list.

How to add line numbers

  1. 1

    Paste the text

    Drop in your block of text. Each newline (\n or \r\n) becomes a separately numbered line.

  2. 2

    Pick the starting number

    Default is 1 but you can start from 0 (common for zero-indexed code) or any other integer if the block continues from a prior chunk.

  3. 3

    Choose padding and separator

    Zero-padding (001, 002, 003) keeps columns aligned. Separator is usually a colon, period, tab or pipe.

  4. 4

    Skip blanks (optional)

    Turn on "skip blank lines" if empty lines should stay in place without receiving a number. Leave it off if blank lines should be counted too.

Common separator formats

Style Example output Where it is used
Colon-space 1: First line Logs, error traces
Tab 1\tFirst line Spreadsheet paste
Period 1. First line Ordered lists, printable docs
Pipe 1 | First line Markdown tables
Zero-padded 001 First line Transcripts, scripts, long notes

When padding matters

If you have more than 9 lines, unpadded numbers create a ragged left edge because line 10 is two digits wide and line 1 is one digit wide. Pad to 01, 02 or 001, 002 so the text after the number stays column-aligned.

Line endings to be aware of

  • LF (\n): Unix, macOS, most developer tools
  • CRLF (\r\n): Windows Notepad and many Windows-origin files
  • CR (\r): classic Mac OS, rarely seen today

Mixing CRLF with LF can cause a block to be numbered as a single line in some editors. Normalise line endings before numbering if the count looks wildly off.

Reverse operation

To strip line numbers back out, use a find-and-replace with a regex like ^\d+[\:\.\s\t\|]+ against the line start.

Frequently Asked Questions

By default, blank lines are included and get their own number. If you turn on “skip blank lines”, empty lines are kept but not numbered, so the sequence jumps from “3” straight to “4” across the gap.

Yes. Zero-indexed numbering is common when pasting fragments of source code to line up with editor line numbers, or when the text continues a previously numbered block.

Because unpadded numbers are variable width (1 character for lines 1-9, 2 for 10-99, 3 for 100+). Turn on zero-padding or choose a fixed-width font to fix it.

Yes. The prefix is added at the very start of each line, before any existing whitespace. Tabs, spaces and leading indentation are kept intact.

The tool treats both as line breaks, so the count should be correct either way. Output is usually emitted as LF. If you need CRLF for a Windows target, copy into an editor that can save with Windows line endings.

Related Tools