Add or Remove Line Numbers

Put a number in front of every line of a text or a code snippet, or remove the numbers from a listing you copied.

Loading tool…

About the Add Line Numbers

Add numbers writes a number and a separator before each line. Start is the first number and Step the difference between two lines, so start 10 and step 10 gives 10, 20, 30, and a negative step counts down. The separator can be 1. , 1: , 1) , a tab, 1 | , a single space or any text of your own. Padding makes all numbers as wide as the largest one, with spaces (right-aligned, like cat -n) or with zeros (001), which keeps the text aligned and makes the lines sort correctly as text.

Blank lines can be numbered like the others, left without a number (the count continues on the next line with text, like nl does by default) or removed. Lines may end in LF, CRLF or CR, and a final line break does not produce an extra numbered line.

Remove numbers detects the format used by most lines: 1. , 1: , 1) , [1] , (1) , 1 | , 1 - , a tab or a space after the number, with or without padding. Only the lines in that format are changed, so a line that begins with 3.14 or with a date such as 2026-03-15 is not damaged, and at most one space after the separator is removed so that the indentation of code survives. Swap moves the result to the input and switches the mode.

How to use it

  1. Paste the text or open a file.
  2. Choose Add numbers or Remove numbers.
  3. Set the start, step, separator and padding, and what happens to blank lines.
  4. Copy the result or download it.

Frequently asked questions

How do I add line numbers in the terminal?
cat -n file numbers every line, nl file numbers the lines that are not empty, and nl -ba file numbers all of them. With awk: awk '{ printf "%3d. %s\n", NR, $0 }' file.
How do I remove the line numbers from code I copied?
Choose Remove numbers and paste the listing. The format is detected; the status line shows which one and how many lines were changed. In a terminal, sed -E 's/^[[:space:]]*[0-9]+[.:)]?[[:space:]]?//' file does the same for the simple cases.
Why pad the numbers with zeros?
With 1, 2 … 10 a plain text sort puts 10 before 2. With 01, 02 … 10 every number has the same width, so the lines sort in order and the text starts in the same column.
Can the numbering start at 0 or count in steps?
Yes. Start accepts any whole number, including 0 and negative numbers, and Step any whole number: step 5 gives 0, 5, 10 and step -1 counts down.

Related tools