Add line numbers

Number a pasted list or snippet, starting wherever you need.

Your inputs stay on your deviceFREE · NO SIGN-UP
Number style
Start at
Align numbers
Blank lines

Lines are numbered from 1, in the order you pasted them. Numbers are written as they come; switch on alignment if the text after them must stay in one column. Blank lines take a number too, the way an editor's gutter counts them. Up to 200,000 characters.

Result

Start typing and the result appears here. No button needed.

THE LITTLE DETAILS

Add line numbers, without the extra steps.

Put a number in front of every line of pasted text. Choose the style — 1., 1), 1:, or a bare number — the number the count starts at, and whether blank lines take a number or keep their place without one. Leading zeros or spaces keep the numbers the same width so the text after them stays aligned.

How to use this tool

  1. 1Paste the lines you want numbered. Your original stays visible above the result.
  2. 2Choose the number style, the starting number, alignment, and how blank lines are treated. The result updates automatically.
  3. 3Check the numbered range in the summary, then select Copy result.

When Add line numbers is the right tool

  • A code snippet is going into a bug report and the reviewer needs to point at line 14 without counting down the block by hand.
  • A snippet starts at line 320 of a real file, so the numbering has to continue from there rather than restarting at 1.
  • A checklist of steps is being pasted into a document that has no automatic numbering, and the numbers must survive the paste as plain text.
  • A list of more than nine items has to stay aligned in a monospaced view, where 9 and 10 otherwise push the text out of column.

Blank lines are a real decision, not a detail

If the numbers have to match a file that someone else will open, every line counts, including the empty ones — that is what an editor's gutter does, and skipping blanks would make line 14 here point at line 12 there. If the numbers are labels for a list of items, blank lines are just spacing and should not consume a number. Number them is the default because matching a file is the stricter requirement; Skip them keeps blank lines exactly where they are, unnumbered.

Alignment decides where the text starts

The count crosses from one digit to two at ten, and from two to three at a hundred, which shifts the text after the number by a character each time. Spaces right-align the numbers to the width of the largest one, so the text stays in a single column in any monospaced view. Zeros do the same visually and are what sortable filenames and identifiers need, because 09 sorts before 10 while 9 does not. Off is right when the numbers feed something that parses them.

Numbering does not read your text

Numbers are assigned in the order the lines were pasted. Nothing is sorted, grouped, or renumbered by content, and existing numbering is not recognised and replaced — a listing you already numbered gets a second number in front of the first. The workspace counts those lines and says so, because the result is easy to miss at a glance. Strip the old numbers before adding new ones if you are renumbering rather than adding.

GOOD TO KNOW

A few quick answers.

Yes. Set Start at to any whole number from 0 to 1,000,000, which is what you want when a snippet begins partway into a file or continues a list from another document. The summary states the exact first and last numbers used, so you can confirm the range before copying.

Alignment set to Spaces right-aligns every number to the width of the largest one, so 9 and 10 line up and the text after them starts in the same column. Zeros do the same with leading zeros, which is what filenames and sortable identifiers usually need. Off leaves the numbers exactly as written.

By default yes, the way an editor's gutter counts every line including the empty ones — which is what you want when the numbers have to match a file. Choose Skip them and blank lines stay in place without taking a number, so the count follows only the lines with text on them.

Yes, because the numbers become part of the text itself rather than list formatting. That is the difference from a word processor's automatic numbering, which is a property of the paragraph and is often lost or renumbered on paste. It also means editing a line later will not update its number.

It ends the last line rather than starting a new one, so a list of three lines that ends with a newline is numbered 1 to 3, not 1 to 4. The summary shows the exact first and last numbers used, which is the quickest way to confirm the count matches what you expected.

Numbering has to stay under 1,000,000, counting from your starting number, and the input is limited to 200,000 characters. If a large starting number and a long list would pass that ceiling, the workspace says so instead of producing a truncated result.

Back to all tools