Line Number Tool

Add or remove line numbers from any text. Configure format, start number, padding, and separator.

Input
Output
Paste text above to add or remove line numbers.

How to Use the Line Number Tool

  1. Paste your text into the input area on the left (or top on mobile).
  2. Choose a mode — "Add Numbers" to prepend line numbers, or "Remove Numbers" to strip existing ones.
  3. Configure the format — choose between N:, N., N), or plain N separators.
  4. Set the start number — default is 1, but you can start from any integer, including 0.
  5. Choose padding — none, space-padded, or zero-padded for alignment in monospace environments.
  6. Copy or download — click Copy to copy to clipboard or Download to save as a .txt file.

What This Tool Does

The Line Number Tool lets you instantly prepend numbered labels to each line of any text — or strip them off again. It handles plain text, code snippets, log files, scripts, poems, and any other line-based content. All processing happens in your browser; your text never leaves your device.

Features

  • Add line numbers — four format styles: colon (1: text), dot (1. text), parenthesis (1) text), or plain (1 text)
  • Remove line numbers — automatically detects and strips leading numbers in common formats
  • Configurable start number — begin numbering at any integer (0, 1, 100, etc.)
  • Padding options — none, space-aligned, or zero-padded for fixed-width columns
  • Strip blank lines — remove empty lines before numbering to number only content lines
  • Live processing — output updates instantly as you type or change settings
  • Privacy-first — 100% client-side, no server, no upload

Common Use Cases

  • Code sharing — add line numbers to a snippet before pasting it into a chat or document so colleagues can reference "line 42" precisely
  • Log file analysis — number log lines to track which entries you have reviewed
  • Document editing — number paragraphs or clauses in legal documents, contracts, or specifications
  • Diff preparation — strip line numbers from a numbered copy before feeding it to a diff tool
  • Data processing — add row numbers to CSV-like plain text when your spreadsheet tool strips them
  • Teaching — add line numbers to student code excerpts to annotate feedback by line

Line Number Formats Explained

The four formats suit different conventions:

  • N: text — colon-separator, common in terminals and log viewers (e.g., grep --line-number output)
  • N. text — dot-separator, matches most word processors and outline formats
  • N) text — parenthesis style, used in legal and academic numbering (1) Introduction…)
  • N text — plain whitespace, minimalist, useful when you do not want any punctuation between number and content

Padding and Alignment

When you copy numbered text into a monospace font environment (a terminal, a code editor, or a PDF), alignment matters. Without padding, a 100-line document displays 1 first line and 99 last line with different widths, causing the content column to shift. Space padding adds leading spaces so all numbers occupy the same number of characters. Zero padding replaces spaces with zeros — common in log files and serialised identifiers — producing 001 first line and 099 last line. The tool calculates the required width automatically based on the highest line number in your output.

Removing Line Numbers

The remove mode strips leading line numbers from text that was previously numbered — whether by this tool, a text editor, a terminal command like cat -n, or a diff viewer. It recognises digits followed by a colon, period, parenthesis, or whitespace at the start of each line. This is especially useful when you want to compare two versions of a file but one copy has line numbers prepended: strip them first, then use a diff tool. The remove mode does not strip numbers that appear mid-line — only those at the very beginning of each line.

Related Tools

After adding line numbers to your text, you might want to compare it with another version using our Diff Checker. If you are working with code, the JSON Formatter and YAML to JSON Converter handle structured data numbering automatically. For bulk text transformations — changing case, generating slugs, or deduplicating lists — see our Case Converter and List Deduplicator.

Frequently Asked Questions

Paste your text into the input box, choose a format (N:, N., N), or parenthesis), set your starting number, and the tool adds line numbers instantly. You can configure padding, separator character, and whether to skip blank lines.
Yes. Switch to "Remove Numbers" mode. The tool detects and strips leading line numbers in common formats — digits followed by a colon, period, parenthesis, or whitespace — from each line of your text.
No. This tool runs 100% in your browser. Your text never leaves your device. There is no server, no upload, no logging, and no data collection of any kind.
Zero-padding aligns line numbers so they are all the same width. For example, with a 100-line file, padding ensures lines 1–9 display as 001–009, keeping columns aligned when you copy the numbered text into a monospace editor or terminal.
When enabled, any empty or whitespace-only lines are removed before numbering. This is useful when you only want to number lines that contain actual content, such as non-empty code lines or paragraphs.