AnyTool
Your files never leave your device. All processing happens locally in your browser.

How do I add line numbers to text online?

Paste your text into AnyTool Add Line Numbers and every line is prefixed live with a running number. Set the start value and step, zero-pad to a fixed or automatic width, choose a separator (a dot, parenthesis, colon, pipe, tab, space or custom), add brackets, prefix or suffix text, align the numbers, skip blank lines or count down in reverse. A separate Remove mode strips existing leading numbers. Everything runs in your browser, so your text is never uploaded.

  • Live preview as you type — no convert button needed
  • Start number, step/increment, reverse (count-down) and restart support
  • Zero or space padding to a fixed or auto width, left or right aligned
  • Separators (. ) : | tab space custom), brackets and prefix/suffix text
  • Skip blank lines, plus a Remove mode that strips existing numbers — 100% client-side

What is

Add Line Numbers

Adding line numbers means prefixing each line of a block of text with a sequential number and a separator, optionally zero-padded and aligned, so the lines can be referenced, counted or formatted as a numbered list. The reverse operation strips an existing leading number and separator from each line.

Text Tools

Related terms

Numbered ListLine NumberingZero PaddingPrefix Lines

Frequently Asked Questions

All numbering runs in your browser, so nothing is sent to a server and the tool works offline.

AnyTool Add Line Numbers prefixes each line entirely in your browser using JavaScript. Your text is never uploaded, there is no account or tracking, and the page works offline after the first load — so you can number confidential code, logs or lists safely.

Yes. Set any start value and step, and turn on reverse to count down from the highest number to the start.

Enter any starting number — even a negative one — and choose the step between lines, for example 10, 20, 30. Enabling reverse numbers the first line with the highest value and counts down by the step, which is handy for ranked or descending lists.

Turn on zero padding. Auto width matches the digits of the largest number, or set a fixed width yourself.

Switch on zero padding and the numbers become 001, 002, 003 so every line lines up. By default the width is automatic — the number of digits in the largest line number — but you can set a fixed width such as 4 to force 0001, 0002, and choose left or right alignment.

Switch to Remove mode. It strips a leading number plus separator (1. / 1) / [1] / 5: / tab) from each line.

Choose the Remove tab and the tool deletes a leading line number and its separator from every line, recognising dots, parentheses, colons, pipes, brackets, zero-padding and tabs. Plain text without a separator, such as a sentence that happens to begin with a figure, is left untouched.

Detailed Explanation

Methodology

How the Add Line Numbers Tool Works

AnyTool Add Line Numbers processes text entirely in the browser. It normalises line endings (CRLF and CR to LF), splits the text into lines, then builds a numbering plan: each line that should be numbered is assigned a value starting at your chosen start and advancing by the step. The plan decides the auto padding width from the digits of the largest number, then each line is rebuilt as prefix, optional bracket, padded number, suffix and separator, followed by the original text. The result recomputes live on every keystroke or option change.

  • Line endings are normalised so numbering is consistent across platforms
  • Auto width equals the digit count of the largest line number
  • Numbers can start at any integer and advance by a custom step
  • Reverse mode assigns the highest value first and counts down
  • All computation is client-side JavaScript — no server round-trip
How It Works

Formatting, Blank Lines and Removal

Beyond the basic count, the tool offers zero or space padding to a fixed or automatic width with left or right alignment, seven separators (dot, parenthesis, colon, pipe, tab, space or custom), four bracket styles and free prefix/suffix text. Blank lines can be skipped so they stay un-numbered, or the counter can be held steady across them. A separate Remove mode reverses the process, stripping a leading number and a common separator from each line while leaving plain text that merely begins with a figure untouched.

  • Zero-pad to 001, 002 or space-pad for aligned columns
  • Separators: . ) : | tab space or a custom string; optional ( [ { < brackets
  • Prefix and suffix text wrap the number, e.g. "Line 1 - "
  • Skip blank lines or keep the counter unchanged across them
  • Remove mode strips 1. / 1) / [1] / 5: / 9 | / tab-numbered prefixes
Privacy & Security

Privacy and Offline Use

Because all numbering runs in the browser, the text never reaches a server, there is no account or tracking, and the page works offline after first load. Large inputs are debounced so the editor stays responsive, and the result can be copied or downloaded as a .txt file. This makes it safe to number confidential source code, server logs or personal lists.

Line numbering: in-browser (AnyTool) vs typical online line numberers
CapabilityAnyToolTypical online tools
Text handlingProcessed in your browserOften posted to a server
PrivacyText never leaves deviceMay log or store submitted text
Start, step and reverseYes, with restart pointOften start only
Padding and alignmentZero/space, auto or fixed widthSometimes basic or absent
Separators and brackets7 separators + 4 bracket styles + customUsually one or two
Remove existing numbersYes, multiple formatsRarely built in
Works offlineYes (PWA)No
Cost / signupFree, no signupOften ad-heavy or gated

Server-based numberers can retain pasted text in logs; AnyTool builds every numbered line locally and uploads nothing.