More games at WuGames.ioSponsoredDiscover free browser games — play instantly, no download, no sign-up.Play

Line Numbering

Add or strip line numbers from any text or code snippet. Custom prefix, suffix, separator, starting index, and skip-blank options. 100% browser-side.

settings Settings

About Line Numbering Tool

Line Numbering adds or strips a numeric prefix from every line of your text, with full control over the format. The Add mode walks the input line by line and prepends a configurable string built from prefix + counter + suffix + separator (for example, prefix 'L' + counter '1' + suffix ':' + separator ' ' gives 'L1: your text'). The counter starts at whatever value you supply (1, 0, 100, or any integer) and increments by one per line — optionally skipping blank lines so they do not consume a number, which matters for poetry stanzas, code blocks, or legal contracts where blanks are formatting elements. The Remove mode reverses the operation: it uses regex patterns to detect common numbering styles ('1. ', '1) ', '1: ', '1 - ', '[1] ', '(1) ') at the start of each line and strips them, returning your original clean text. Common workflows: producing GitHub-style line-numbered code for review comments, generating numbered todo lists for ticketing systems, preparing legal documents where each line needs a court-citable reference, formatting poetry verses, and stripping numbers from copied Stack Overflow answers to make them runnable again.

How is this different from a code editor's gutter line numbers?

Editor gutter numbers are display-only — they are not part of the file and are stripped when you copy. This tool bakes the numbers into the text itself so they survive copy/paste into emails, PDFs, Slack messages, or anywhere outside the editor. Use the editor's gutter for live editing; use this tool when sharing code or text where the recipient needs the numbers visible without their own line-numbering setup.

How does Remove mode know which prefix is a 'number' and not part of the content?

It applies a strict regex that only matches numeric patterns at the very start of the line: optional whitespace, one or more digits, then one of the common separator characters (. ) : ] | -) followed by a space. Lines that start with words, hashtags, or numbers without a separator (like '1984 was a great year') are not touched. If your custom format uses something exotic (e.g., 'Line #1:'), Remove mode may not catch it — use a Word Replacer with regex to strip your specific pattern.

What happens with very long inputs — say 10,000 lines of source code?

Performance is linear and fast. Even 100k lines complete in well under a second because the operation is a single Array.map() with string concatenation. The browser textarea handling becomes the bottleneck around ~5 MB of pasted text where the paste itself slows down, but the numbering processing stays snappy. Output character count is shown so you know your final size before copying.

Line Numbering — Add or strip line numbers from any text or code snippet. Custom prefix, suffix, separator, starting index, and skip-blan
Line Numbering

Can I start numbering at a number other than 1?

Yes — the 'Starting Number' field accepts any integer (negative, zero, or large like 1000). Useful for: continuing numbering across split documents (start at 501 in the second half), legal documents requiring section-specific ranges, or matching original source line numbers when sharing a snippet from line 247 of a larger file. Reverse order is not directly supported; if you need it, reverse the lines first with the Reverse List tool, then number.

Does 'Skip Empty Lines' just ignore blanks or remove them?

Ignore but keep. The blank line stays in the output to preserve your visual formatting, but it does not get a number assigned, and the counter does not increment for it. So 'apple\n\nbanana' with skip-blanks on becomes '1. apple\n\n2. banana' — both content lines get sequential numbers, the blank between them remains untouched. To actually remove blanks before numbering, run the input through Remove Empty Lines first.

What separator character should I use for code comments versus prose?

For code snippets shared in chat: use ': ' (colon-space, the Python/JS REPL convention) or '. ' (the GitHub line-comment convention). For legal/contract text: ' - ' (space-dash-space, ISO 14289 PDF accessibility hint). For poetry/stanzas: ' | ' (pipe with spaces, classical scholarship convention). For terminal-style output: '> ' (greater-than space). The 'Skip Empty Lines' option pairs well with code where blanks structure logic blocks.

Will the numbers also appear when I paste into Word or Google Docs?

Yes. Since the numbers are inserted as plain text characters (not as Word's auto-numbering markup), they paste as literal text in any editor — Word, Google Docs, Notion, Slack, GitHub comments, PDF exports. This is exactly what you want for sharing read-only references, but it means the recipient can edit out the numbers manually. To prevent that, paste into a PDF/image export tool after numbering.