Template Modes
Common, code, legal, script, document, and saved custom presets.
Add line numbers to any text in seconds. Choose from 20+ format templates or build your own for code, legal documents, scripts, and long-form writing. Preview every change in real time, then copy, download, or convert it into a numbered code block without leaving the page.
Template Modes
Common, code, legal, script, document, and saved custom presets.
Output Types
Copy numbered text directly or turn it into shareable code-style output.
Users
Built for exact line references, not just generic lists.
Input
Hello World This is line two And this is three
Live Preview
S2
Choose a preset, tweak the builder, and watch the numbered output update instantly. The editor supports files, blank-line rules, undo and redo, custom starts, range numbering, and saved templates.
Input
Paste text, upload a file, or remove old line numbers first.
5 lines · 1 blank
Range starts at line 1
Output
Live numbered preview with the current template and builder settings.
1. Hello World 2. This is line two 3. 4. And this is four 5. Final line
5 lines numbered · Format: N.
Plain text output
S3
Build exactly the numbering format you need. Start values, step size, numbering base, zero padding, prefixes, suffixes, alignment, blank-line rules, and range controls all update the preview instantly.
Preview
1. Hello World 2. This is line two 3. And this is three
Start Number
Step
Base
Current Format String
{prefix}{number}. {content}
S4
Turn numbered output into shareable code blocks for documentation, forums, tickets, and blog posts. Choose HTML, Markdown, plain text, or BBCode, then highlight the lines that matter.
Current numbered source
1. Hello World 2. This is line two 3. 4. And this is four 5. Final line
HTML output
<style>.lc-code-block{background:#0f172a;color:#e2e8f0;border:1px solid rgba(255,255,255,0.08);border-radius:18px;padding:16px;overflow:auto;}.lc-code-block table{width:100%;border-collapse:collapse;font-family:JetBrains Mono, Menlo, monospace;font-size:14px;line-height:1.65;}.lc-line-number{color:#94a3b8;min-width:4ch;padding-right:16px;text-align:right;vertical-align:top;user-select:none;}.lc-line-content{white-space:pre;}.lc-line.highlighted{background:rgba(250,204,21,0.10);}</style><div class="lc-code-block" data-language="javascript"><table><tbody><tr class="lc-line highlighted"><td class="lc-line-number" aria-hidden="true">1. </td><td class="lc-line-content">Hello World</td></tr><tr class="lc-line"><td class="lc-line-number" aria-hidden="true">2. </td><td class="lc-line-content">This is line two</td></tr><tr class="lc-line highlighted"><td class="lc-line-number" aria-hidden="true">3. </td><td class="lc-line-content"></td></tr><tr class="lc-line"><td class="lc-line-number" aria-hidden="true">4. </td><td class="lc-line-content">And this is four</td></tr><tr class="lc-line"><td class="lc-line-number" aria-hidden="true">5. </td><td class="lc-line-content">Final line</td></tr></tbody></table></div>S5
Already have numbered text? Paste it here to strip the numbering back out. The detector recognizes the most common inline formats and can fall back to a custom regular expression when needed.
Detected Pattern
N.
Found in 3 of 3 non-empty lines. Confidence: 100%.
Clean Output
Removed line numbers from 3 lines using N. .
First line Second line Third line
S6
The goal is not just to prepend 1, 2, and 3. This page handles real formatting work: template switching, document-friendly alignment, code block export, reverse cleanup, and browser-side privacy.
See numbered output instantly while you change templates, padding, numbering bases, ranges, and blank-line rules.
Switch between common, code, document, legal, script, and saved custom formats without rebuilding the output manually.
Convert numbered snippets into HTML, Markdown, plain text, or BBCode with optional highlighted lines.
Detect and remove previously added line numbers when you need to get back to clean editable text.
Customize start number, step, alignment, zero padding, prefix, suffix, separator, and numbering base.
Number only the lines you need, or apply interval numbering for legal and review-oriented document formats.
Upload text-based files directly into the editor instead of copying from another tool first.
Everything runs in the browser so your text stays local while you preview, number, and export it.
S7
Line numbers help when a team needs to talk about exact rows, not vague paragraphs. The same core operation applies to code review, legal drafting, classroom materials, scripts, and support workflows.
Add line numbers to code snippets for code reviews, Stack Overflow posts, internal docs, and support tickets.
“I number code before posting snippets so reviewers can reference exact lines immediately.”
Prepare pleadings, exhibits, and draft contracts with right-aligned or interval-based legal numbering.
“We need every fifth line numbered in a clean, court-friendly format.”
Apply scene, page, or script numbering styles when sharing rewrites with production teams and readers.
“Script-ready numbering is faster than rebuilding the format in a document editor.”
Number reading passages and worksheets so students can cite specific lines in class or on exams.
“Numbered passages make discussion and grading much easier.”
Reference exact lines in configuration samples, tutorials, troubleshooting docs, and changelog excerpts.
“Adding line numbers to documentation makes each instruction easier to discuss.”
Match snippet numbering to the original file by starting at any line and highlighting the most important ranges.
“I can paste a fragment and keep its original line references for review reports.”
S8
The code references below target common long-tail searches such as add line numbers in Python, Bash, JavaScript, Notepad++, Microsoft Word, and VS Code.
Python examples for standard numbering, zero padding, skipped blank lines, and custom formatting.
Simple numbering
with open("input.txt", "r", encoding="utf-8") as handle:
lines = handle.readlines()
with open("output.txt", "w", encoding="utf-8") as handle:
for index, line in enumerate(lines, start=1):
handle.write(f"{index}. {line}")Zero padding and custom formats
total = len(lines)
width = max(2, len(str(total)))
for index, line in enumerate(lines, start=1):
handle.write(f"[{index:0{width}d}] {line}")Skip blank lines
number = 1
for line in lines:
if line.strip():
handle.write(f"{number}. {line}")
number += 1
else:
handle.write(line)A line number adder is a tool that prepends sequential references to each line of text so the content can be discussed, reviewed, cited, or debugged precisely. Instead of vague notes such as "look near the middle of the snippet" or "the issue is somewhere in the second paragraph," a numbered output lets people say "check line 47" or "line 12 needs a change." That sounds simple, but it becomes surprisingly important anywhere exact references save time: code reviews, legal drafts, teaching materials, scripts, support tickets, policy documents, and multi-line exports.
The difference between a useful line number adder and an old one-button utility is control. Many older tools only output "1. text" with no control over start values, padding, spacing, or blank lines. Real work is rarely that uniform. Developers may need 1 | code for a review comment. Legal teams may need right-aligned numbers or every-fifth-line numbering. Teachers may want Line 1: labels for reading passages. Writers and editors may want to remove previously added numbers before revising a draft again. A serious line number adder has to cover all of those use cases without forcing the user into a spreadsheet or desktop editor.
This page is built around that broader workflow. You can add line numbers online, switch between 20+ templates, build a custom format, skip blank lines, number only a selected range, export numbered code blocks, and reverse the process with automatic line number removal. The work happens in the browser, which makes it fast for one-off jobs and practical for sensitive text that you do not want to upload to a server. If you need surrounding metrics, open the Line Counter first, then return here to format the final excerpt.
Line numbers reduce ambiguity. In technical work, that means faster debugging and clearer review comments. A maintainer can say "line 18 should return early" instead of copying the whole block. In support and compliance work, line numbers create a stable reference system that survives copy-and-paste into tickets and reports. In classrooms, numbered passages make it easier for students to cite exact evidence and for instructors to point back to the relevant sentence without re-reading the whole page together. In editorial workflows, line numbers can be the difference between a precise revision note and an avoidable follow-up message asking, "Which part do you mean?"
Online line numbering is also faster than opening a heavier document tool when the content is already plain text. If the source is a pasted code snippet, a list of clauses, a transcript excerpt, or a log fragment, the path of least resistance is usually a browser tool that can add line numbers instantly and let you copy the result back into Slack, email, GitHub, or Word. That is the main task intent behind searches such as line number adder, add line numbers online, and number lines online. The user does not want a lecture or a desktop install. They want a format that looks right and can be shipped immediately.
Developers often need inline numbering when a snippet leaves the editor. Gutter numbers inside VS Code or another IDE are great on the local machine, but they disappear when the code is pasted into chat, documentation, bug trackers, or community posts. An online line number adder solves that transport problem. The code block generator on this page takes the numbered output and converts it into HTML, Markdown, plain text, or BBCode so the reference survives wherever the snippet goes next. If you need shell alternatives, the GNU `nl` command is still useful, but a browser interface is faster when formatting matters as much as the number itself.
Legal work is where formatting control becomes essential rather than nice to have. Courts, filings, exhibits, and internal reviews may require right-aligned line numbers or interval numbering. That is why the legal presets on this page do more than prepend a dot. They help mimic the presentation style people expect from formal documents. If you need the broader context of court-facing rules, the U.S. Courts rules and procedure pages are a useful reference, but inline formatting is still something most teams need to build directly into the text they share.
Teachers use line numbers for reading passages, poetry excerpts, source analysis, and exam materials because numbers make discussion more exact. Editors and proofreaders use them to anchor comments without breaking the flow of a draft. Screenwriters and production teams use line-like references to keep everyone aligned on revisions, cues, and page fragments. These are all variations of the same need: one line, one reference, zero ambiguity. The interface here treats them as first-class use cases with template presets instead of assuming every user wants the same output.
Different numbering styles exist because different workflows optimize for different things. Some formats prioritize readability. Some prioritize alignment. Some prioritize compatibility with code comments or legal margins. A modern line number adder should not force you to choose between fast formatting and the exact look you need. The best workflow is usually to pick the closest template, adjust the builder, then export the final output in the format the destination expects.
| Format | Example | Best For |
|---|---|---|
| N. | 1. Hello | General-purpose ordered references |
| [N] | [1] Hello | Technical docs and training materials |
| N | | 1 | Hello | Code reviews and plain-text tables |
| /* N */ | /* 1 */ Hello | Shared code snippets and Markdown docs |
| Line N: | Line 1: Hello | Teaching materials and support notes |
The rule of thumb is simple. Pick the least distracting format that still feels native to the destination. If you are sending a code sample, use a code-like format. If you are preparing a reading passage for students, use a document-style format. If you are sending a clause list for legal review, use right-aligned numbers or interval numbering. Template switching matters because format signals context before a reviewer reads a single line of the content.
Zero padding keeps numbered references visually aligned and more predictable in systems that sort values lexicographically. The jump from 9 to 10 is where unpadded formats start to feel ragged, especially in long documents and technical exports. A format such as 01, 02, 03 or 001, 002, 003 is easier to scan because the number column maintains a stable width. It also sorts more cleanly in file names and text-based systems where 10 might otherwise appear before 2. That is why the builder includes both auto padding and fixed width padding. Auto padding is good when the total size of the output changes. Fixed width is better when a team has an established style guide.
Right alignment is more than a visual preference. It keeps the content column stable when the number width grows from one digit to two digits and beyond. That matters in legal work, code review, and any document where readers need to compare lines quickly without the text shifting to the right. Many editors do this automatically in the gutter, but inline formatting often loses that advantage unless the tool gives you alignment controls. The legal and code templates above are designed around this exact issue.
That sequence is deliberately short because most users want the result immediately. Paste, pick a format, confirm the preview, and export. The deeper controls matter when the output must match a house style or a professional standard, but the core path still has to stay fast. That is the practical advantage of a dedicated line number adder compared with building the format manually in Word, Excel, or a code editor every time.
Reverse cleanup is an underrated feature. Many people add line numbers to share a snippet, then need to remove them later before they keep editing. If the numbering was inserted directly into the text, simple find-and-replace is often not enough because formats vary. One block might use 1. , another might use [001] , and a code sample might use /* 1 */. The Remove Line Numbers panel detects the common patterns and removes them in one pass. When the pattern is unusual, the custom regular expression field lets advanced users define it explicitly.
Text-based formats are the easiest case. TXT, MD, JS, PY, HTML, CSV, and log files can all be numbered directly because they already have line breaks that the tool can read. PDF is different because the line structure is often presentation-driven rather than content-driven. In most cases, it is better to add line numbers before the text becomes a PDF or after you extract the underlying plain text. Word is also different because its built-in line numbering usually lives in the margin rather than inside the content itself. That is useful for page layout, but not when you need numbers embedded in the copied text that will move into email, Slack, GitHub, or a ticketing system.
If your workflow starts in code rather than prose, Python is one of the easiest ways to automate line numbering offline. The built-in `enumerate()` function covers the common case in a few lines, while the browser tool on this page is faster for one-off formatting jobs, previews, and shared templates. For adjacent cleanup steps, pair this page with the Duplicate Line Remover, the Blank Line Remover, and the Line Sorter. Those tools fit naturally before or after numbering depending on whether the structure or the reference system comes first in your workflow.
Common questions about templates, zero padding, code snippets, custom starts, blank-line handling, reverse cleanup, and file uploads.
Paste your text into the tool, choose a numbering template, and copy the result. The preview updates instantly, so you can adjust the prefix, suffix, padding, start number, or range before exporting.
Yes. The Custom Format Builder lets you change the prefix, suffix, separator, alignment, numbering base, zero padding, start number, step size, and blank-line behavior.
Set Zero Padding to "Auto" for width based on the output size, or choose a fixed width such as 3 to generate values like 001, 002, and 003.
Yes. Set any starting value in the format builder. This is useful when you are numbering an excerpt that begins partway through a larger file or document.
Use Code Block Generator mode. It converts the numbered output into HTML, Markdown, plain text, or BBCode and can keep line numbers non-selectable in the HTML output.
Yes. Choose "Skip blank lines" to preserve blank rows without numbering them, or "Skip and remove" if you want empty rows deleted from the result.
Use the range controls to choose a start line and end line. You can also enable interval numbering when you only want a number on every fifth line or another fixed interval.
Paste the numbered text into the Remove Line Numbers panel. The tool auto-detects common patterns such as "1. ", "[001] ", "1) ", "1: ", and comment-style numbering, then strips them instantly.
Use enumerate(lines, start=1) and prepend the counter inside an f-string. This page includes Python examples for simple numbering, zero padding, skipped blank lines, and range-only numbering.
Notepad++ can display gutter line numbers, but it does not add them to the text content by default. You usually need a macro or PythonScript plugin for inline numbering, which is why a browser tool is often faster.
Legal documents often use right-aligned numbers and sometimes number every fifth line instead of every line. The Legal templates on this page are configured for that style.
Yes. Upload TXT, MD, JS, PY, HTML, CSV, and other text-based files, then download the numbered output after you confirm the format.
Move from numbering into counting, sorting, deduplication, blank-line cleanup, and deeper line-oriented workflows without leaving the same browser toolset.
Core Tool
Count total lines, blank lines, and content lines before or after you add numbering.
Content
Measure word count and density once you finish formatting numbered excerpts.
Content
Check character totals on numbered snippets, legal clauses, and code samples.
Cleanup
Clean empty rows before numbering, or strip them after numbering if the draft is too loose.
Transform
Sort the list before numbering when the order should be alphabetical, numeric, or column-based.
Cleanup
Remove repeated lines before you assign stable references to a final reviewed list.
Guide
Read the Python guide if you want to move from browser formatting into scriptable line workflows.
Guide
Compare shell commands and file-based line operations across Linux, macOS, and Windows.
Tool
Compare line-based references with broader drafting metrics such as words, sentences, and readability.