Add Line Numbers to Text

Add line numbers to text by pasting it below: every line is numbered as you type. Everything runs in your browser, so your text is never uploaded.

0 lines • 0 characters
Or open a text file

The file is read by your browser and never uploaded.

Separator after the number

Default is one space, giving "1: text". Clear it for "1:text".

Numbering Options

Start Number: The number given to the first line. Any whole number works, including 0 and negative numbers.

Increment: How much to add for each following line. Use 2 for even numbers, 10 for BASIC-style numbering, or a negative value such as -1 to count down.

Separator: Character between the line number and text. Common separators include colon (:), period (.), and tab.

Pad with zeros: Adds leading zeros so every number has the same number of digits (01 … 10, or 001 … 100). Useful for sorting.

Right-align with spaces: Pads with spaces instead, so numbers line up vertically in a monospaced font.

Skip empty lines: Blank lines keep their place but get no number, and the count continues on the next line with text.

Prefix/Suffix: Text before the number or after the separator. Example: prefix "Step " with a period separator gives "Step 1. text".

Remove line numbers / Swap: Strips numbers in the format set above, so you can undo numbering or clean up copied code listings.

Summary: add line numbers to text, free and private

To add line numbers to text for free and without uploading anything, paste it into the box above or open a text file. The numbered version appears underneath as you type, and the Copy and Download .txt buttons save it. The numbering happens in your browser, and the Network tab in your browser's DevTools shows that no request is sent.

A line-numbering tool puts a running number at the start of each line. To count lines rather than number them, use the line counter; for removal only there is a separate remove line numbers page.

Table of Use: settings and what you get

Each row shows the text pasted in, the settings changed from their defaults and the result. ↵ marks a line break and ⇥ a tab.

TaskInputSettingsResult
Number a snippet or listalpha↵beta↵gammaDefaults: Start Number 1, Increment 1, Colon1: alpha↵2: beta↵3: gamma
Count downSame three linesStart Number 10, Increment -110: alpha↵9: beta↵8: gamma
Keep numbers the same width12 linesNumber width: Pad with zeros01: …↵09: …↵10: …↵12: …
Split into spreadsheet columnsSame three linesSeparator: Tab (the default suffix space is cleared)1⇥alpha↵2⇥beta↵3⇥gamma
Make a Markdown numbered listSame three linesSeparator: Period1. alpha↵2. beta↵3. gamma
Number paragraphs, not blank linesalpha↵↵betaSkip empty lines ticked1: alpha↵↵2: beta
Strip numbers from a listing1: alpha↵2: betaRemove line numbers, Separator: Colonalpha↵beta

Features

  • Start Number and Increment. Any whole number, including 0 and negatives. Decimals and numbers past 9,007,199,254,740,991 get an error message.
  • Five separators. Colon, Comma, Period, Pipe or Tab sits between the number and the text.
  • Prefix and Suffix. Add text before the number or after the separator. The suffix starts as one space; clear it to get 1:text.
  • Number width. Leave numbers as they are, pad them with zeros to the width of the largest, or right-align them with spaces. When you pad, negative and positive numbers keep the same width.
  • Skip empty lines. Blank and whitespace-only lines are left unnumbered and the count continues on the next line with text.
  • Remove line numbers and Swap. Removal uses the separator, prefix and suffix you have set. Swap sends the result back in as the input and flips the mode.

Numbers stay attached to their lines, so remove empty lines, remove duplicate lines or sort the lines alphabetically first.

How to Use the Line Numbering Tool

  1. Type or paste your text into the box labelled "Text to number", or click Choose File to open a text file.
  2. Read the result under "Numbered Text". It updates whenever you change the text or a setting.
  3. Set Start Number, Increment, Separator, Prefix/Suffix, Number width and Skip empty lines as needed.
  4. Click Copy, or Download .txt to save the numbered text. Click Reset to start again.
  5. To undo numbering, click Remove line numbers (or Swap) and make sure the separator, prefix and suffix match.

Who Can Use It

Developers number snippets and log excerpts so a colleague can quote "line 14", then compare versions in the text diff tool. Teachers and students number poems and exercises, and spreadsheet users pick Tab to get a row-number column.

Writers can polish numbered lists in the Markdown editor and check length with the word counter or character counter. Find and replace and the text case converter tidy a copied listing.

FAQs

How do I add line numbers to text online for free?

Paste your text into the box labelled "Text to number" and the numbered version appears below it, as "1: first line", "2: second line" and so on. Change the start number, increment, separator, prefix or number width if you want another style, then click Copy or Download .txt. No sign-up is needed.

How do I add line numbers to a text file?

Click Choose File under "Or open a text file" and pick a text-based file such as .txt, .md, .csv, .log, .json, .js or .py. Your browser reads it locally. Set the numbering, then click Download .txt to save numbered-lines.txt. The download is always a .txt file, so rename it if you need the original extension.

Can I start line numbers at 0, or count down?

Yes. Start Number and Increment each accept any whole number, including 0 and negative numbers. Start at 0 with an increment of 1 for zero-based numbering, or start at 10 with an increment of -1 for a countdown of 10, 9, 8 and so on. Decimals such as 0.5 are not accepted.

How do I add leading zeros to line numbers?

Open the Number width menu and choose "Pad with zeros (01, 02 … 10)". Every number is padded to the width of the largest one, so 12 lines get 01 to 12 and 100 lines get 001 to 100. "Right-align with spaces" pads with spaces instead, which suits reading in a monospaced font.

How do I remove line numbers from text?

Click "Remove line numbers", paste the numbered text and pick the separator it uses, plus the prefix if there is one. The tool deletes the number, separator and suffix from the start of each line and leaves other lines alone. After numbering some text, Swap moves the result into the input and switches mode.

Is it safe to add line numbers to code or private documents online?

Yes. The numbering runs in JavaScript in your browser and a file you open is read locally, so nothing is uploaded. Open the Network tab in your browser's DevTools and you will see no request when you paste text or change a setting. Nothing is stored either, so reloading the page clears the text.