Add Line Numbers
Add sequential line numbers to text.
What you provide
How this calculation works
The tool splits your text on every line break and prefixes each line with its position, starting at 1. Numbers are right-aligned and zero-free padded to the width of the largest one, so the column stays straight whether you have 9 lines or 900. Blank lines are counted too, so the final number matches the line count your editor shows. The original text is never changed — the number and a single space are simply added in front of each line.
What the results mean
- Padding
- Numbers are padded with leading spaces to equal width, so 1 and 100 align neatly down the left edge and the text after them stays in one column.
- Line count
- The last number is the total number of lines, including any trailing blank line — useful for confirming a file has the length you expect.
- Blank lines
- Empty lines still receive a number, so the numbering never skips and lines up with the same line in your editor or a diff.
Common problems and fixes
- The numbers don't line up when I paste them somewhere
- Alignment relies on a fixed-width font. In a proportional font the padding spaces are narrower than the digits, so the column drifts. Viewed in a monospace context — a code block or a plain-text editor — the column squares up.
- I need to remove the numbers again later
- This tool only adds them. To strip a leading number column in your editor, find-and-replace the regular expression ^\s*\d+\s to nothing — that removes the number and the space after it from the start of every line.
Frequently asked questions
Is my text sent anywhere?
No. The numbering happens entirely in your browser with a simple string operation — you can confirm in your network panel that nothing is sent. That means you can safely paste log excerpts, code, or private notes.
Does it number blank lines?
Yes. Every line gets a number, including empty ones, so the count matches what your editor reports and the numbers still line up with a diff or stack trace that references specific lines.
Can I start from a different number or change the separator?
Not here — this tool applies one fixed format: start at 1, right-aligned, padded, followed by a single space. If you need a custom start value or a different separator (a colon, a tab), most editors have a built-in numbering command, or a small find-and-replace with a regex will do it.
Why are the numbers right-aligned instead of left-aligned?
Right alignment keeps the space between the number and your text constant. Left-aligned numbers would push line 100's text two characters further right than line 1's, breaking the column; right alignment with padding keeps everything flush.
Put this on your own site
Free to embed, no attribution required beyond the source link the frame carries itself. It runs entirely in your visitor's browser, sets no cookies and loads no third-party script.
<iframe src="https://runthetests.com/embed/add-line-numbers/" width="100%" height="560" style="border:1px solid #e5e5e5;border-radius:8px" title="Add Line Numbers" loading="lazy"></iframe>
Preview it at https://runthetests.com/embed/add-line-numbers/. Embedded pages are marked noindex, so yours stays the canonical copy — not this one.