Adding line numbers to text means prepending a sequential integer to every logical line of a block of pasted text, including blank and whitespace-only lines, while preserving the original line content byte-for-byte and emitting the result with a single line-feed character between output lines. The Add Line Numbers to Text tool performs this transformation entirely in the browser: you paste up to 1,000,000 characters, choose a starting number between 0 and 999999, set a separator up to 20 Unicode characters, and optionally turn on leading-zero padding. When you trigger the action, the tool splits the input on every CRLF, CR, and LF boundary, numbers each logical line from the chosen start, prefixes the generated number and separator in front of the untouched original text, and joins the result with LF. Because the original line endings are normalized rather than preserved, the output is consistent and predictable no matter whether the source came from Windows, classic Mac, or Unix. The numbered preview shows the exact bytes that will be written to the downloaded UTF-8 plain-text file, so what you see in the preview is what you save.

add line numbers to text explained
Add Line Numbers to Text, Explained End to End

How the Numbering Process Actually Works

The transformation runs as a four-step pipeline the moment you trigger the action. First, the input string is split on every recognized line boundary: carriage-return plus line-feed (CRLF), a lone carriage return (CR), and a lone line feed (LF) all count as line breaks, and trailing empty lines are retained so the positional relationship between numbers and the original line sequence is preserved. Second, a counter is initialized at the chosen starting number and increments by exactly one for every logical line, including empty ones, so a three-line input containing a blank line in the middle still produces three numbered rows rather than two. Third, each generated number is rendered as ordinary base-ten digits and prepended to the original line text with the configured separator sitting in between; the original line content is otherwise untouched, so the tool does not trim, collapse repeated spaces, or reinterpret tabs. Fourth, the prefixed lines are joined back together using a single LF character, producing the exact string that appears in the preview and the exact bytes that go into the downloaded file. Because joining always emits LF, the output is uniform regardless of which line endings the source used. The whole pipeline runs locally in the browser, and nothing you paste is uploaded to any server.

Settings That Control the Output

Three controls shape every numbered result, and each one has a specific rule worth understanding before you click the action.

The starting number must be a whole, non-negative integer with at most six digits, so any value from 0 to 999999 is accepted. From there the sequence increases by exactly one for every logical line, which means very long inputs can produce values past six digits; the six-digit limit applies to user input validation, not to the sequence itself, so the tool will not silently wrap or truncate a large counter.

The separator is the literal string inserted between the generated number and the original line. It can contain spaces, punctuation, a tab pasted from your clipboard, or be entirely empty, and it is limited to 20 Unicode characters. Common choices include a period and space, a colon, a vertical bar, or a tab. The separator is never interpreted as a regular expression and characters are never escaped, so a literal pipe in the separator field is a literal pipe in the output.

Zero padding uses the digit width of the last number in the result. A three-line sequence starting at 8 produces 08, 09, and 10; a nine-line sequence starting at 1 produces ordinary one-digit numbers because the final value stays one digit. Padding affects only the generated numeric prefix; the original line text is never padded. If you turn padding off, every number renders at its natural width.

ControlWhat it controlsAccepted range or ruleDefault behavior
Starting numberFirst integer in the sequenceWhole, non-negative integer with at most six digits (0 to 999999)Begins counting from your chosen value
SeparatorLiteral string placed between number and lineUp to 20 Unicode characters; may be empty; never regex-interpretedInserted verbatim, no escaping applied
Leading-zero paddingDigit count of every generated numberWidth equals the digit count of the last number in the resultOff, so numbers render at natural width

If the input is empty, the starting number is not a valid integer, or the separator is longer than 20 Unicode characters, the tool surfaces a visible error and produces no output. The input area itself is never modified when a result is generated, which keeps your source text intact for re-runs with different settings.

Apply Line Numbers to Your Text

  1. Paste or type the text you want to number into the input area. The tool accepts up to 1,000,000 characters of any UTF-8 text.
  2. Set the starting number to the integer you want as the first label, anywhere from 0 to 999999.
  3. Type the separator you want between the number and the original line, such as a period and space, a colon, a tab, or any short literal string up to 20 characters.
  4. Toggle leading-zero padding on if you want the number column to align, or leave it off for natural-width digits.
  5. Trigger the action to generate the result, inspect the preview to confirm the numbering, separators, and padding look right, and download the result as a UTF-8 plain-text TXT file.

If you edit any option after a result has been generated, the old result is cleared and its download object URL revoked, so a stale download cannot be mistaken for the current output. The preview uses preformatted wrapping, which means long lines can wrap visually for readability without gaining extra newline characters in the downloaded file. The output file itself is plain UTF-8 text with no byte-order mark, so it opens cleanly in any text editor or terminal without encoding surprises.

Line Endings, Blank Lines, and Whitespace Explained

Three behaviors frequently surprise first-time users, and all three are deliberate design choices rather than side effects.

Blank lines are numbered. A logical line is anything between two recognized line boundaries, so an empty line between two paragraphs of text still receives its own integer. A line containing only spaces or tabs is also counted as a logical line and receives its own number; the tool does not silently skip whitespace-only lines. If the input contains alpha, a blank line, and beta, the output contains three numbered lines, and the blank one sits in the middle at the position where it was in the source.

Line endings are normalized on output. CRLF from Windows, lone CR from classic Mac, and lone LF from Unix are all recognized on input, but the preview plus the downloaded file use a single LF character between output lines. The original line-ending bytes from the source are not preserved verbatim, which keeps the output predictable across platforms and prevents a mixed-line-ending file from sneaking into the downloaded text.

Original line text is otherwise untouched. The transformation prefixes a number and separator and leaves every other character exactly as it was, so repeated spaces, tabs, leading indentation, and trailing whitespace on each line all survive the round trip. A trailing newline at the very end of the input creates one final empty logical line that is numbered, which preserves the original line structure rather than collapsing it into a shorter output.

Common Scenarios Where Numbered Output Helps

Numbered text is most useful when someone else has to reference a specific line. In a code review, a reviewer can write "see line 42" and the author can find the exact spot in seconds, without counting from the top of the file. In a transcript or interview log, line numbers let readers and editors reference a precise sentence during editing. In poetry or script drafts, numbered lines make workshop feedback painless, because "change line 7" is faster than retyping the line in chat. In support logs, an agent can paste the offending output and write "the stack starts at line 118" so the developer jumps straight to it.

For legal-review working copies, classroom material, and any workflow that needs stable line identifiers, the labels live on logical lines rather than visual lines, which means they survive reformatting of paragraph wrapping and font changes. Numbering every logical line including blanks also preserves the visual shape of the document when someone scrolls, because the column of numbers moves down at the same rate as the body text.

The tool is not the right choice for counting-only workflows, renumbering an existing numbered list intelligently, or adding page numbers. For counting rather than transforming, the Line Counter reports total, non-blank, and blank line counts plus the longest line length in one pass. For adding arbitrary literal text around each line rather than a sequential number, the Add Prefix and Suffix to Lines tool handles arbitrary prefix and suffix text, with an option to leave blank lines untouched.

If you're weighing options, Add a Prefix to Each Line on Mac Without sed covers this in detail.

If you're weighing options, Wrap Every Line in Quotes for JSON, SQL, and CSV covers this in detail.