Skip to content

Add line numbers

Prefix text lines with numbers using a starting index and a choice of formats, with an option to leave blank lines alone.

Processed on your device

How it works & useful details

How to use this tool

Paste your text, choose a nonnegative starting integer and prefix format, then number the lines. Existing numbering is preserved.

How the result is calculated

Leave blank lines unnumbered preserves empty and whitespace-only lines and does not advance the counter for those lines. Otherwise, a final newline creates a final numbered blank line.

Line tools normalize CRLF and CR to LF. A final newline represents an empty final line; empty input has zero lines.

Up to 500,000 UTF-16 code units per input. Text stays on your device.

The result is limited to 2,000,000 UTF-16 code units.

About this tool

Add line numbers prefixes every line with a number, using a starting index and the format you choose. It is useful for referencing code, quoting a transcript, or preparing numbered steps from a plain list.

Numbering happens locally, and blank lines can be left unnumbered so the original shape of the text survives. The result is copyable and downloadable.

How to use it

  1. Paste the text you want to number.
  2. Set the starting number and the separator format.
  3. Choose whether blank lines keep their numbering position or stay empty.
  4. Copy or download the numbered text.

Worked example

With "leave blank lines unnumbered" enabled and the dot format, the text

alpha

beta
gamma

becomes

1. alpha

2. beta
3. gamma

The blank line is kept but does not advance the counter, so the numbers stay consecutive. Without the option, the blank line becomes "2." and beta becomes 3.

Choosing a format

  • Dot (1. item): readable lists, and pasting into Markdown, where it renders as an ordered list.
  • Parentheses (1) item): legal clauses, exam questions, and styles where a trailing dot would be confusing.
  • Tab (1<tab>item): pasting into a spreadsheet, where the number and the text land in separate columns.

Starting at a number other than 1 is useful for continuing a list across documents, or for numbering code excerpts so the line numbers match the original file. Existing numbers in the text are left as they are, so check for a double prefix if the source was already numbered.

Frequently asked questions

Does numbering preserve indentation?

Yes. The original line content, including leading whitespace, is kept after the number and separator.

Which line endings are produced?

The output uses standard line breaks compatible with editors and spreadsheets; the original content is not otherwise modified.

What is the limit?

Up to 500,000 characters of text per run.

Can I remove line numbers again?

Not with this tool. The regex replace tester can remove them: replace ^\d+\. with nothing, using the multiline flag.