Add Line Numbers to Text
Paste your text and every line gets a number, such as "1. ", "1) " or "[1] ", that you can copy straight away. Choose where the count starts, the step, zero padding and whether blank lines are skipped.
0 words 0 characters 0 lines
Continue with this text: Add prefix/suffixSort linesCount lines
Your text stays in your browser: nothing is uploaded or stored on a server.
How to number lines
- Paste your text into the box, or click Open file to load a plain-text file. Example loads a short recipe to try the options on.
- Leave Action on Add numbers and pick a Format:
1 text,1. text(the default),1) text,[1] text,1: textor1 (tab) text. - Set Start at and Step if you don’t want 1, 2, 3. Tick Pad with zeros for 01, 02, 03 and Skip empty lines to leave blank lines unnumbered.
- The result updates as you type. Click Copy, or Download .txt to save it. Use as input moves the result into the box so you can run another tool on it.
The options
| Option | What it does | Default |
|---|---|---|
| Action | Add numbers puts a number at the start of each line; Remove numbers strips numbers that are already there. | Add numbers |
| Format | The number and the separator written before each line. Every format except the tab one ends with a single space. | 1. text |
| Start at | The number of the first line. Any number, including 0, negatives and decimals. An empty field counts as 1. | 1 |
| Step (negative counts down) | How much each number grows. A negative step counts down; a decimal step such as 0.5 gives decimal numbers. An empty field or 0 counts as 1. | 1 |
| Pad with zeros (01, 02…) | Adds leading zeros so every number has as many digits as the widest one. | Off |
| Skip empty lines | Leaves blank lines without a number and does not count them. | Off |
The 1 (tab) text format puts a tab character between the number and the line. Spreadsheets normally split tab-separated text into columns when you paste it, so each line fills two cells: the number and the text.
How lines are counted
- A line ends at a line break. Windows (
\r\n), old Mac (\r) and Unix (\n) line breaks are all recognized. The result always uses\n. - Long lines that wrap on screen are still one line. A paragraph pasted from a word processor is one line until it contains a line break, however long it looks in the box.
- Blank lines get a number unless you skip them. With Skip empty lines off, a blank line becomes just
4.. With it on, a line counts as empty if it is empty or holds only spaces or tabs, and those spaces are kept as they were. - A line break at the very end is kept, not numbered.
a,bfollowed by a final line break gives1. a,2. band the same final line break, so text copied from a file that ends with a newline does not get an extra empty number. - The text of each line is not touched. Indentation, tabs, emoji and accented letters stay exactly as they were; the number is only added in front.
- Padding is based on the widest number. The tool works out the first and the last number it will write (start + step × (lines − 1), counting only numbered lines when blank lines are skipped) and pads every number to the larger digit count. Start 10 with Step 10 on three lines gives 10, 20, 30, so nothing needs padding. For negative numbers the zeros go after the minus sign: Start at -1 on 200 lines gives
-001.,000.,001.and so on. - Decimals follow the start and step. Numbers get as many decimal places as Start at or Step has, without rounding noise: Step 0.1 gives
1.0.,1.1.,1.2..
Worked examples
The built-in example with the default 1. text format, first with Skip empty lines off, then on:
1. Preheat the oven 1. Preheat the oven
2. Mix the flour and sugar 2. Mix the flour and sugar
3. Add the eggs 3. Add the eggs
4.
5. Bake for 25 minutes 4. Bake for 25 minutes
Twelve lines with Pad with zeros ticked:
| Before | After |
|---|---|
line 1 |
01. line 1 |
line 9 |
09. line 9 |
line 10 |
10. line 10 |
line 12 |
12. line 12 |
Other settings on the lines a, b, c:
| Settings | Result |
|---|---|
| Start at 0 | 0. a, 1. b, 2. c |
| Start at 100, Step 5 | 100. a, 105. b, 110. c |
Format [1] text |
[1] a, [2] b, [3] c |
Format 1: text |
1: a, 2: b, 3: c |
| Start at 3, Step -1 | 3. a, 2. b, 1. c |
| Step 0.5 | 1.0. a, 1.5. b, 2.0. c |
Code with the 1 text format keeps its indentation after the number:
1 function hi() {
2 return 1;
3 }
Removing line numbers
With Action set to Remove numbers, the tool removes a number at the start of each line, together with the one space or tab that follows it. It recognizes:
| Line starts with | Example | Removed |
|---|---|---|
| A bare number, on every non-empty line, going up or down by the same step | 6 zeta, 7 eta |
Yes |
| A bare number on a line of ordinary text | 2026 was a year, 3 eggs |
No |
Number and ., ), : or ] |
1. alpha, 2) beta, 3: gamma |
Yes |
| Number in square brackets | [4] delta |
Yes |
# and a number |
#7 eta |
Yes |
| Spaces, then a number | 08. theta |
Yes |
| No space after the number | 1.alpha |
No |
| Letters or Roman numerals | a. letter, iv. roman |
No |
| A minus sign or decimals, as Add numbers writes them | -1. a, 1.5. b |
Yes |
| A single bare decimal in ordinary text | 3.5 kg flour |
No |
Only the single space or tab after the number is removed, so indentation is kept: code numbered with the 1 text format comes back as it was.
1 function hi() { function hi() {
2 return 1; return 1;
3 } }
A bare number (the 1 text and 1 (tab) text formats) needs at least two numbered lines in sequence. If one line in the list has another format, such as 5 epsilon among 1. alpha and [4] delta, the bare numbers stay, and a single line such as 1 one is left as it is. Numbers with a minus sign or decimals, which Add numbers writes with a negative or decimal start or step, are removed too: -1. a, 0. b, 1. c becomes a, b, c, and 1.0. a, 1.5. b, 2.0. c becomes a, b, c. Bare decimal numbers must all have the same number of decimals and form a sequence, so 3.5 apples followed by 2 pears is left alone. Text numbered here on two or more lines, with any start, step, format or zero padding, comes back exactly as it was.
Only one number is removed per line: 1. 2. double becomes 2. double.
When numbered lines help
- Referring to lines in a review. Number a draft, a contract clause list or a transcript so comments can say “see line 14”.
- Sharing code in a chat or email where there is no editor gutter, so others can point to a line. The tab format lines the code up in a column.
- Step-by-step instructions such as recipes or setup guides, using
1.or1), with blank lines skipped between sections. - Lists for spreadsheets. Use the tab format to get a numbered ID column next to the text when pasting into a sheet.
- Ordered lists after sorting. Sort the lines first, or remove duplicate lines, then number the final list.
- Cleaning up text copied from a numbered source. Remove numbers turns a numbered list back into plain lines, ready to re-sort or join with commas.
This tool vs line numbers in Microsoft Word
Word can show line numbers on a document: on the Layout tab, in the Page Setup group, select Line Numbers and choose Continuous, Restart Each Page or Restart Each Section. Line Numbering Options sets other intervals. By default Word does not number lines in tables, footnotes, endnotes, text boxes, headers and footers, and it counts a whole table or figure as one line.
Word’s numbers belong to the document layout. This tool writes the numbers into the text itself, one per line break, so they survive copying into an email, a chat, a plain-text file or a spreadsheet. Use Word’s feature for legal or manuscript pages that must be cited by printed line, and this tool when the numbers need to travel with the text.
Questions
How do I add line numbers to a text file?
Click Open file and choose the .txt (or .csv, .md, .log and similar) file, or paste its contents. The numbered text appears in the Result box; Download .txt saves it as a new file. Your original file is not changed.
Can I number only the lines that have text?
Yes. Tick Skip empty lines. Blank lines, including lines that hold only spaces or tabs, stay in place without a number, and the count continues on the next line with text.
How do I make the numbers 01, 02, 03?
Tick Pad with zeros. The width matches the largest number in the result, so 12 lines give 01 to 12 and 100 lines give 001 to 100. With 9 lines or fewer there is nothing to pad.
Can I start numbering at a number other than 1?
Yes. Type the first number in Start at (0 works too) and the gap between numbers in Step. Start at 100 with Step 5 gives 100, 105, 110 and so on. A negative step counts down, so Start at 10 with Step -1 gives 10, 9, 8.
Can I number lines with letters or Roman numerals?
No. The tool writes Arabic digits only. For another marker at the start of every line, such as a dash or a bullet, use add prefix and suffix.
How do I remove line numbers from text?
Choose Remove numbers under Action. Numbers written with a period, a bracket, a colon or a
Is my text uploaded anywhere?
No. Numbering runs in your browser. The text stays in this tab so it is still there if you switch tools, and it disappears when you close the tab.