Adding line numbers to text means prefixing every line of your text with a sequential integer — usually separated from the original content by a space, tab, or punctuation — so each row has a stable, human-readable identifier you can refer to during editing, review, or quoting. The identifiers run from a starting value you choose, increase by one per line, and stay aligned with the original line order so a blank line in your input still gets its own number. This numbering style is different from paragraph numbering or page numbering because it is purely text-based and survives copy and paste into code editors, transcripts, support tickets, and chat messages where the recipient has no way to see Word's automatic margin numbers. When you need that kind of stable reference but you are working outside a Word document — pasting a section into a code review, dropping a transcript into a chat, or sharing a log in plain text — a dedicated line-numbering tool gives you the same anchor points without the document overhead.

how to add line numbers to text in word
how to add line numbers to text in word

What adding line numbers to text actually does

At its core, the operation transforms each input line into a two-part string: a numeric prefix and the original line content, joined by a literal separator you control. Every logical line becomes one numbered line in the output, and the count always reflects the structure of the input rather than the number of non-empty rows. If you paste alpha, a blank line, and beta, the output is exactly three numbered lines — the middle one numbered, not skipped — because the tool treats line boundaries as positional information, not as content filters.

The transformation also normalizes line endings. Whether your source text comes from a Windows document using carriage return plus line feed, a classic Mac file using lone carriage returns, or a Unix file using lone line feeds, the recognizer splits on all three and writes the output with a single line feed between every line. That single convention keeps downloads portable across operating systems, code editors, and chat clients, and it prevents invisible CRLF characters from confusing downstream parsers.

Where line numbering helps in everyday work

Line numbering is one of those small conveniences that shows up across very different workflows. Code reviewers paste functions into chat and need to say "fix line 42"; teachers want every line of a poem or script draft to have a stable reference so students can ask about line 17; support agents share log snippets and ask colleagues to look at line 8; legal teams produce redlined working copies where each paragraph needs a fixed index that does not shift when text is added or removed above it. In all of these cases the numbering is part of the text itself rather than a feature of the surrounding document, which is exactly the situation the Add Line Numbers to Text tool is designed for.

If you only need to know how many lines you have without changing anything, a separate line counter gives you the total, the non-blank count, the blank count, and the longest line length, all without altering the original. The two tools complement each other: count first to decide whether the document is worth numbering, then number only the section you need to share.

How to number every line with Add Line Numbers to Text

  1. Open the Add Line Numbers to Text tool in your browser — the page runs entirely on your device and sends no text to a server.
  2. Paste or type the lines you want to number into the input area. You can paste directly from a Word document, a code editor, a chat window, or a downloaded log file. Up to 1,000,000 characters are accepted.
  3. Set the starting number to the integer you want the first line to receive. Values from 0 to 999999 are accepted, and the sequence then increases by one for each subsequent line.
  4. Type the separator that goes between the number and the original line. A period and a space, a colon, a vertical bar, or a tab are common choices, and the separator is treated as literal text with no special meaning.
  5. Turn on leading-zero padding if you want every number in the result to use the same digit width. The padding width is automatically set to the digit count of the final sequence value, so the last number is never truncated.
  6. Click the action to generate the result. The preview shows the exact output that will be downloaded, with preformatted wrapping so long lines remain visually readable without inserting extra newlines.
  7. Download the UTF-8 TXT file using the provided button. The file is plain UTF-8 text with no byte-order mark, and it contains the same string that the preview displayed.

If you want to change anything after generating a result — for example, a different separator or a new starting number — edit any option first. The old result is cleared and its download link is revoked so you cannot accidentally save a stale copy that no longer reflects your current settings.

Choosing the starting number, separator, and zero padding

Each control does a specific job and the defaults already cover most cases, but a few combinations are worth knowing. The starting number is the integer prepended to your very first line; the next line is start plus one, the line after that is start plus two, and so on for the entire input. A starting value of 1 gives the familiar textbook numbering, while a starting value of 0 is convenient for arrays, zero-indexed logs, and code listings where the index begins at zero.

The separator is literal text inserted exactly between the generated number and the untouched original line. It can be a single character, several characters, or empty, and it supports spaces, punctuation, and a tab pasted from your clipboard. Because it is treated as plain text, characters that would be special in a regular expression — dots, pipes, parentheses, backslashes — appear in the output just as you typed them. If you want the classic "1. text" look, type a period followed by a space. If you want a tab between the number and the line, paste a literal tab character into the separator field.

Zero padding aligns every number to the same width by adding leading zeros as needed. The width is computed from the final number in the sequence, so a run starting at 8 with three lines produces 08, 09, and 10, and a run starting at 1 with nine lines stays as ordinary one-digit numbers because the final value is still one digit. Padding affects only the numeric prefix; the original line content is never padded, trimmed, or reflowed.

Use caseStarting numberSeparatorPadding
Textbook-style line references1period and space (".")on, for long passages
Code listings in chat or review1 or 0tab characteron when files exceed 99 lines
Transcript or interview lines1vertical bar with spacesoff for short runs
Zero-indexed log or array entries0colon ("")on to match fixed column width

Understanding the output format and line endings

The downloaded file is plain UTF-8 text without a byte-order mark, which makes it open cleanly in every modern editor and paste correctly into terminals, web forms, and chat boxes. The line endings inside the file are always a single line feed character, regardless of the operating system that produced your input. That consistency is important if the numbered output will be processed by another script, because many command-line tools behave differently around CRLF and lone CR boundaries.

Trailing newlines in the input are honored. If your pasted text ends with a newline, the tool still treats that as a final empty logical line and gives it a number, so the output preserves the structure of the source rather than silently dropping the closing break. The same rule applies to whitespace-only lines anywhere in the middle of the input: they receive numbers and remain in place, which keeps the positional relationship between each number and its line intact.

Limits, privacy, and what stays untouched

Three hard limits shape what you can put through the tool. The input is capped at 1,000,000 characters to keep browser work responsive; the starting number must be a whole non-negative integer with at most six digits; and the separator is limited to 20 Unicode characters. Empty input, an invalid starting number, or a separator that is too long produces a visible error rather than a silently wrong output. If your final sequence value happens to grow beyond six digits because the input is very long, that is allowed — the six-digit cap applies to user input validation, not to silently wrapping or truncating the sequence.

Privacy is built into the design. Numbering, preview generation, and TXT file creation all happen locally in the browser, so the text you paste never leaves your device. You can confirm the underlying technique by reading the MDN reference for String split for the line-boundary recognition and the Blob reference for the local file download; both match the behavior described above.

The tool does not modify your input area, does not trim line content, does not collapse repeated spaces, and does not reinterpret tabs. It does not count only non-empty lines, does not try to renumber an existing numbered list intelligently, and does not add page numbers. If you need any of those other behaviors, the right companion tool is one click away: Line Counter for counting without transforming, and Add Prefix and Suffix to Lines when the surrounding text you want to add is something other than a sequential number. For readers who want a wider comparison of plain-text and document-based approaches, the guide how to add line numbers in Word and plain text walks through both Word's built-in margin numbers and the browser workflow side by side.