U.UtilityApp
✍️ TextFree · No signup

Add Line Numbers to Text

Prefix every line with a sequential number — useful for lists, code snippets and references.

The number format

Every line gets its number, a full stop and a space in front of it, starting at 1:

1. alpha 2. beta 3. gamma

When the list reaches 10 lines or more, the numbers are padded on the left with spaces so they all take the same width. With 12 lines, lines 1 to 9 start with one space, so in a monospaced font the full stops line up in a column above 10., 11. and 12.. With 100 lines or more, the first nine get two spaces. The padding uses spaces, not zeros, so the numbers read as 1, 2, 3 rather than 01, 02, 03.

There are no options for the starting number, the separator or the padding.

Blank lines get a number too

Every line is numbered, including empty ones. This input has a blank second line and ends with a line break:

first third (line break at the end)

and it comes out as four numbered lines: 1. first, 2. , 3. third and 4. . The final line break counts as an empty fourth line.

That is what you want when the numbers must match line numbers in an editor, for example when you are discussing code or a log file. For a list where only the items should count, run it through Remove Empty Lines first and make sure there is no line break after the last item.

Long lines and pasted paragraphs

Numbers follow line breaks, not sentences. A paragraph typed as one long line gets one number however many lines it wraps to on screen. If you paste a document and want numbered sentences, put each sentence on its own line first.

Indentation is kept after the number, so numbered code still shows its structure.

Where the numbered text goes next

  • Email and chat: numbers let people reply about "line 7" without quoting it.
  • Code reviews and bug reports: paste the numbered snippet into a code block so the spacing and alignment survive.
  • Word processors: the numbers are plain text, not an automatic numbered list. If you add or remove a line later, they won't update, so number the text when it's final.
  • Spreadsheets: each line lands in its own row with the number as part of the text. If you want the numbers in a column of their own, it is simpler to fill a number series in the spreadsheet and paste the unnumbered lines next to it.

Frequently asked questions

How do I remove line numbers from text?+

This tool only adds them. Because the numbers are padded to the same width, a code editor with column selection can select and delete the whole number column in one go. A spreadsheet's split text to columns on the full stop also works, as long as the lines have no other full stops in them.

Can I start numbering from a number other than 1?+

No, it always starts at 1. If you need to continue from an earlier list, add blank placeholder lines at the top to push the count forward, then delete those lines from the result.

Why don't the numbers line up when I paste them?+

The padding is made of spaces, which only line up in a monospaced font. In a proportional font, such as most email and word-processor defaults, spaces are narrower than digits, so switch that text to a monospaced font or put it in a code block.

Embed this tool on your website

Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.

<iframe src="https://utilityapp.lat/embed/text/add-line-numbers" title="Add Line Numbers to Text" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe>
<p style="font-size:13px"><a href="https://utilityapp.lat/text/add-line-numbers">Add Line Numbers to Text</a> by UtilityApp</p>