Add Line Numbers Tool
Paste your text to add a number to the front of each line.
Result
How it is calculated
The text is split at every line break (Windows, old Mac and Unix breaks all count as one), and each line gets number | line in front of it. The first number is the start value you enter (1 if left empty), each later line adds 1, and a decimal start is cut to its whole part. All numbers are padded with spaces on the left to the width of the widest one (a negative start such as -1 counts with its minus sign), so the vertical bars line up: with 10 lines starting at 1, line 1 is shown as 1 | . The separator is always the vertical bar with a space on each side. Empty lines are numbered too, and the line count result tells you how many lines were found. Nothing happens if the text box is empty.
Worked example
Paste two lines, milk and eggs, and set the start number to 9. The first line becomes 9 and the second 10. The widest number has two digits, so 9 is padded with one space. The result is 9 | milk and the line count is 2. With the start left at 1 the same text would give 1 | milk and 2 | eggs, with no padding because both numbers are one digit.
10 | eggs
Common mistakes
- Leaving a trailing line break at the end of the pasted text: the empty last line is counted and numbered, so a 3-line list shows 4 lines.
- Expecting to choose a different separator such as a dot or a tab: the tool always uses a space, a vertical bar and a space.
- Using the output as code: the numbers and bars are part of the text, so remove them again before running or compiling a numbered snippet.
- Leaving the start number empty and expecting numbering from 0: an empty field means 1, so type 0 yourself, and note that decimals are cut, so 1.9 becomes 1, not 2.
About this calculator
This tool splits pasted text at each line break and prefixes every line with a sequential number, right-aligned with space padding so the numbering stays aligned even as line lengths vary, followed by a fixed “ | ” separator. You can set the number to start from (it starts at 1 by default), and it also reports the total line count — a plain-text equivalent of what code editors show in their gutter or what word processors do with automatic line numbering.
Programmers preparing code snippets for documentation or bug reports, teachers numbering worksheet lines, and legal or manuscript editors who need to reference specific lines in a document use it to add numbering without opening a full editor — useful whenever you need to say “see line 42” in a plain-text file that doesn't have built-in line numbers.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
When you only paste part of a long file, set the start number to the first pasted line's real position. If you copy lines 98 to 100 from a log, start at 98 and the output reads 98, 99 and 100, matching the original file, so a reference such as see line 99 still points to the right place. Numbers padded to three digits keep the bars aligned. Which separator would you prefer instead of the vertical bar?