Format Code Now
/
TextAdd Line Numbers Next: Filter Lines ›

Add Line Numbers to Text

TX-19

Paste text and get a number in front of every line. Pick the start number and separator, or switch to Remove line numbers to strip them.

Runs in your browser. Nothing is uploaded.

Text

Numbered text

How to use it

  1. Paste your text into the input box.
  2. Pick the start number and a separator: dot, bracket, colon or tab.
  3. Tick Pad numbers to equal width to line the text up, or Skip blank lines to leave them unnumbered.
  4. Press Add line numbers, then copy the result or download it.
  5. To undo it, paste numbered text, choose the same separator and press Remove line numbers.

How the numbers are added

Each line gets its number, your separator and then the original line. With padding on, shorter numbers get leading spaces so that 9 lines up with 10, based on the width of the last number. With Skip blank lines on, empty lines stay empty and do not use a number. The start number can be 0, 1, 10, 100 or 1000. Line breaks of any kind in the input come out as plain line feeds.

Removing line numbers

Remove line numbers cuts a run of digits plus the separator you selected from the start of each line, allowing spaces or tabs before the digits. Lines that do not start like that are left alone. If your own text begins with a number and the same separator, such as a year followed by a full stop, that part is removed too, so check the result. Choose the separator that was used when the numbers were added.

Questions people ask

How do I add line numbers to text?

Paste your text, choose a start number and a separator, and press Add line numbers. Each line gets a number in front of it. Copy the result or download it as a text file.

Can I start numbering at 0 instead of 1?

Yes. The Start at list offers 0, 1, 10, 100 and 1000. Zero is handy for array indexes, and the larger starts help when you are continuing a numbered list that began in another document or file.

Can I number only the lines that have text?

Yes. Tick Skip blank lines. Empty lines stay empty and do not take a number, so the numbering counts only the lines that hold something, with no gaps.

How do I remove line numbers from text?

Paste the numbered text, select the separator it uses, and press Remove line numbers. The digits and separator are cut from the start of each line. Lines that do not start with a number are left exactly as they are.

Why are my numbers lined up with spaces?

That is the Pad numbers to equal width option. It adds leading spaces so a list that runs from 1 to 120 keeps its text in one column. Untick it if you want the numbers written with no padding at all.

About this tool

Add puts a number and your chosen separator in front of every line, counting from the start number. Padding adds leading spaces so the numbers line up, using the width of the last number. Blank lines are numbered unless you tick Skip blank lines, which leaves them empty and does not use up a number. Remove strips only a leading run of digits followed by the separator you selected, with spaces or tabs allowed before it; lines that do not start that way are left alone, and a number that was part of the original text, such as 2026. at the start of a line, is removed too. Line breaks of any kind come out as plain line feeds.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.