Add Line Numbers

Add line numbers to text or code online: every line, blank ones included, gets 1., 2., 3. in front, ready to copy in one click.

Runs in your browser. Files never leave your device.
9 words · 54 chars

About the Add Line Numbers

Add line numbers to any text: paste a list, a script, a poem or a block of code and every line gets a number in front of it, starting from 1. A numbered transcript is easier to review, because everyone can say exactly which line they mean, and the same goes for pointing at a line of code in a message. Paste a plain list and it comes out numbered.

The numbered version appears in the Result box as you type or paste, and Copy puts it on your clipboard. Your original stays as it was, so you can keep editing it and the numbers follow.

How the lines are numbered

The text is split at every line break. Each line then gets its position, a full stop and a space in front of it, so the first line becomes 1. and the twentieth becomes 20. The lines are joined back together with the same breaks, which means the numbered text has exactly as many lines as the original.

Empty lines are counted as well, so a number always matches the line's real position. When someone says 'see line 14', they mean line 14 in the original too, not the fourteenth line with text on it.

line n  →  "n. " + line
(n starts at 1 and goes up by one for every line, empty or not)

Assumptions and limits

  • The format is fixed: number, full stop, space. To get a different style, such as 1) or a tab after the number, run the result through Search and Replace.
  • Numbers aren't padded, so lines 1 to 9 are one character shorter than lines 10 to 99 and long lists don't line up in a column.
  • A blank line at the very end, which many editors add, gets a number too, with nothing after it. Delete the last line break before pasting if you don't want it.
  • Lines are counted by line breaks, not by how text wraps on screen. A long paragraph that wraps across five lines in the box is still one line and gets one number.
  • Numbering always starts at 1; there's no option to continue from another number.

Worked examples

Number a shopping list

Four items on separate lines become a numbered list you can paste into a message or email.

Rice
Lentils
Cooking oil
Tea

1. Rice
2. Lentils
3. Cooking oil
4. Tea

Line numbers for code you're sharing

Numbering a short function lets a reviewer write 'line 3 returns too early'. The blank line keeps its own number, so the positions match the file.

1. function total(items) {
2.   let sum = 0;
3.   if (!items) return 0;
4. 
5.   for (const i of items) sum += i;
6.   return sum;
7. }

A 120-line transcript

Paste the whole interview and the last line reads 120. followed by its text. Empty lines are numbered, so an interviewer's note about line 87 points to the same place in the original document.

How to use the Add Line Numbers

  1. Paste your text. Into Input Text, one item or line of code per line; the sample shows a single line.
  2. Check the numbers. Result shows each line prefixed 1., 2., 3. and so on, empty lines included.
  3. Copy the numbered text. Press Copy; Clear empties the input when you're ready for the next one.

Frequently asked questions

How do I add line numbers to text without Word?

Paste the text here and the Result box shows it with 1., 2., 3. in front of each line. The numbers are ordinary characters rather than a list format, so the copied text keeps them in emails, chat apps and plain-text files.

Does it skip blank lines?

No. Blank lines are numbered too, so each number is the line's true position. To number only the lines with text, delete the empty lines in the input box; the result is rebuilt on every edit, so the numbers close up straight away.

Why don't my numbers line up after line 9?

Because the numbers aren't padded with spaces or zeros, so 10. is one character wider than 9. and the text shifts right by one. For aligned columns, paste the result into a spreadsheet or a code editor that shows its own line numbers.

Can I number lines of code with this?

Yes. Indentation is kept, because the number is added in front of the line without touching what follows. The numbered version won't run as code any more, though. Use it for sharing, printing or review.

How do I remove line numbers again?

Keep your original text, which this tool never changes. If you only have the numbered copy, the Regex Tester can help you build a pattern such as ^\d+\. with the m flag to find each prefix for removal in your editor.

This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.