Add Line Numbers to Text

Quickly add line numbers to a block of text for sharing code snippets, log excerpts, or referencing specific lines in a review. Optional zero-padding, custom starting number, custom separator. The reverse mode strips existing line numbers.

How to use the Add Line Numbers to Text

Paste text. Pick add or strip mode. Configure start number, padding (so all numbers align), and the separator between number and line. Output updates live.

Adding (and removing) line numbers

Line numbers make a snippet referenceable — “see line 14” only works if the lines are numbered. They help when sharing code in a chat without a gist, quoting a config file in a review, or printing a listing. But you also need to strip the numbers off again before the code will run.

This adds line numbers with control over the starting number, zero- or space-padding so they align, and the separator between number and text. Strip mode reverses the process, removing existing numbering so you get the clean original back. To measure each line’s length rather than number it, see character count by line.

Common use cases

  • Code sharing — number a snippet so others can point to a specific line.
  • Review comments — quote a config file with line references.
  • Teaching — hand out a numbered listing for discussion.
  • Log excerpts — number lines of a captured log for reference.
  • Round-tripping — strip numbers back off text that was already numbered.

Frequently asked questions

Can it remove line numbers too?

Yes. Strip mode removes existing numbering, so you can paste numbered text and get the clean original back.

Why pad the numbers?

Padding with spaces or zeros keeps the separator aligned, so the text starts at the same column on every line.

Can I start from a number other than 1?

Yes — set any starting number, which is handy when quoting an excerpt from the middle of a file.

Is the separator configurable?

Yes. Choose what goes between the number and the line, such as : or a tab.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: