b2KIT

Add Line Numbers to Text

Prepend line numbers to each line of text with customizable formatting.

How to Use Add Line Numbers to Text

  1. 1

    Paste your text

    Enter the lines of text you want to number.

  2. 2

    Configure numbering

    Set the starting number, separator style, and padding options.

  3. 3

    Copy the result

    Click copy to grab the numbered text for use in your project.

Tested tool guide Text and writing tools Checked August 15, 2026

What Add Line Numbers to Text does, with a checked example

Add Line Numbers to Text splits pasted text on line breaks and prepends a sequential number to every line, using settings you control: starting number, increment step, zero-padding width, and the separator between the number and the text (a period, colon, tab, or custom string). It runs in the browser on whatever you paste in. The most common surprise is that it treats every line break as a new line, including blank ones, so a paragraph with intentional blank spacing gets numbered gaps unless you strip them first.

Worked example

A concrete input and expected output from the current implementation.

Input

apple
banana
cherry

Expected output

1. apple
2. banana
3. cherry

Each of the three input lines gets a sequential number starting at 1 and incrementing by 1, joined to the line with a period-and-space separator - assuming default start, increment, and separator settings, all of which are adjustable.

How the result is produced

1

Line splitting

The tool breaks the input on line-break characters and treats each resulting line, including empty ones, as a unit to number. Text that only wraps visually in your source editor, without a true line break, stays on the same numbered line. Whether a trailing blank line at the end of the input receives its own number depends on whether the input string ends in a trailing newline.

2

Numbering and format controls

Numbers start at a configurable start value and increase by a configurable increment, so you can count by 1s, 5s, or any step instead of only sequentially from 1. A separator string sits between the number and the original line text, and an optional zero-padding width keeps numbers aligned in a monospaced column once line counts reach double or triple digits.

Good uses

  • Adding reference numbers to a code snippet before pasting it into a tutorial, ticket, or answer so you can point to 'line 12'
  • Numbering log excerpts or config file contents before sharing them in a bug report or code review comment
  • Preparing numbered lines for scripts, poetry drafts, or contract-style text where each line needs a visible reference number

Limits and checks

  • Blank lines get their own number just like any other line, since the tool numbers every line break in the input rather than skipping empty ones - strip blank lines first if you don't want the resulting gaps in the sequence
  • If the original text already has line numbers or list markers, the tool won't detect or replace them, so you'll get double numbering unless you strip the old numbers first
  • Zero-padding width is something you set, not something the tool infers from the total line count, so a width chosen for a 20-line file will look misaligned if you later paste a 200-line file without adjusting it

Common questions

Will the numbers stay in sync if I edit the text afterward?

No. Numbering is a one-time transformation applied to whatever you pasted. If you add, remove, or reorder lines afterward, the numbers no longer match the content, and you need to re-run the tool on the updated text.

Can I start numbering from something other than 1, like 0 or 100?

Yes. The start value is one of the configurable options, along with the increment between numbers, so you can begin at any number and count up by any step rather than only 1, 2, 3.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools