How to Add Line Numbers to Text (For Code and Documents)
To add line numbers to text, use an online line number tool that prepends numbers to each line with customizable separators. Our Add Line Numbers tool numbers your text instantly with options for starting number, separator style, and padding.
Why Add Line Numbers
Line numbering is useful in many contexts:
- Code review — refer to specific lines when discussing code
- Legal documents — contracts and legal papers often use line numbering
- Technical documentation — enable precise references to content
- Data analysis — number rows in datasets for easy reference
- Educational materials — help students follow along with numbered lines
- Error reporting — report exact line numbers for bugs or issues
- Printed documents — make it easy for readers to reference specific sections
Line Numbering Options
| Option | Description | Example |
|---|---|---|
| Starting number | Begin from any number (default: 1) | 1, 10, 100 |
| Separator | Character between number and text | . , : , ) |
| Padding | Leading zeros for alignment | 001, 002, 003 |
| All or non-empty | Number all lines or only lines with content | Skips blank lines optionally |
Examples
Default (number + period + space):
1. First line
2. Second line
3. Third line
With colon separator:
1: First line
2: Second line
3: Second line
With padding (3 digits):
001. First line
002. Second line
003. Third line
How to Add Line Numbers Online (Step-by-Step)
- Open the Add Line Numbers tool
- Paste your text into the input area
- Choose your options:
- Starting number (default: 1)
- Separator (default:
.) - Padding (optional)
- Number all lines or non-empty only
- The numbered text appears instantly
- Copy the result
Use Cases
- Code snippets — number lines for code review feedback
- Contracts — line-numbered legal documents for precise referencing
- Transcripts — interview or speech transcripts with line numbers
- CSV preview — number rows when reviewing data
- Poetry — traditional line numbering for poems
- Agendas — numbered meeting agendas for easier navigation
FAQ
Can I start numbering from a different number?
Yes. The tool allows you to set any starting number. This is useful when continuing numbering from a previous section.
Does the tool number blank lines?
By default, blank lines are numbered. You can choose the “Non-empty lines only” option to skip blanks.
Can I use custom separators?
Yes. You can set any separator text between the line number and the line content.
What is padding for?
Padding adds leading zeros so all numbers have the same width. This keeps numbers aligned visually, especially in documents with many lines.
Is this the same as a numbered list in Word?
Line numbers appear at the start of each line. Numbered lists in Word automatically increment and renumber when items are added or removed.
Try our free Add Line Numbers tool to number lines in your text for code review, documents, and data processing.