Line Counter

Paste text or open a file to count its lines. The page also counts blank lines, finds the longest line and flags lines past a column limit.

How it works

Lines are counted the way an editor numbers them. A line break at the very end of the text does not start another line, so a file of three lines that ends with a line break is still three lines.

The number of line breaks is shown too, because that is what the Unix command wc -l counts. The two differ by one when the last line has no line break after it.

A line with only spaces or tabs counts as blank. Line length is counted in characters, with a tab as one character.

How to use it

  1. 1 Paste your text into the box, or open a text file such as a .csv, .log or .txt.
  2. 2 Read the line count at the top, and the blank lines and lines with text under the box.
  3. 3 To check a column limit, choose 72, 80, 100 or 120. Every line longer than that is listed by number.
  4. 4 The longest line is shown in full, with its line number, so you can find it in your editor.

Good to know

  • For a CSV with a header row, the number of records is the lines with text minus one.
  • A stray blank line in a CSV can become an empty record when the file is imported. The blank line count shows whether there is one.
  • Git commit message bodies are traditionally wrapped at 72 characters, and many code style guides use 80, 100 or 120.
  • Trailing spaces and mixed tabs hide inside lines. The Whitespace Visualizer draws them in.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Counting guests in a CSV: 7 lines, 5 people, and one row that will not fit

The example is a guest list saved as a CSV file, the kind a spreadsheet exports. Load it and the count reads 7 lines. That is not 7 guests. The first line is the header row, "name,table,diet", and line 4 is blank: the figures under the box show 6 lines with text and 1 blank line. Take away the header and the list has 5 guests. A quick count of lines is the fastest check that an export has the number of rows you expected, as long as you account for the header and any blank lines.

The blank line matters more than it looks. Many import tools read a blank line in a CSV as a record with every field empty, so a caterer who imports this file could see a sixth guest with no name and no table. The blank line count makes it visible before the file goes anywhere. Delete line 4 and the count drops to 6 lines, all with text, and 6 minus the header is 5.

Choose 80 under "Flag lines longer than" and the page reports that line 6 is longer than 80 characters. The longest line section shows it in full: it is 105 characters, a guest with a long name and a diet note in quotes. In a CSV, that is harmless. In a printed table or a narrow terminal, it wraps and breaks the layout. The same check is useful for code and commit messages. Many style guides cap code lines at 80, 100 or 120 characters, and git commit message bodies are traditionally wrapped at 72 so they read well in a terminal.

The example ends with a line break after the last guest, which is how most programs save text files. So the page counts 7 lines and 7 line breaks, and says that wc -l would agree. Remove that last line break and the page still counts 7 lines, but there are now 6 line breaks, and wc -l would report 6. When a script and an editor disagree about the length of a file by exactly one, a missing final line break is nearly always the reason.

Line lengths here are counted in characters, one per code point. A tab is one character, although an editor may show it 4 or 8 columns wide. A Chinese or Japanese character is one character, although a terminal shows it two columns wide. An emoji built from several joined parts, such as a family, counts as several. For a column limit in a code editor, these cases rarely come up, but they are why an editor's column number can differ from the length here. The page counts up to 500,000 characters at a time; split a larger log file first.

Frequently asked questions

Why does wc -l give me one less than this page?

wc -l counts line break characters, not lines. If the last line of your file has no line break after it, that line is not counted by wc. This page counts it, as your editor does, and tells you when the two numbers differ.

Does a blank line at the end count?

A single line break at the end of the text does not start a new line, so it does not count. A second one does: the text then ends with a blank line, and the page counts it as one.

How are Windows line endings counted?

A Windows line ending, a carriage return followed by a line feed, counts as one line break. A file you open is counted exactly as saved. Text you type or paste into the box is converted to plain line feeds by the browser, which does not change the count.

Is the file uploaded?

No. An opened file is read by your browser and counted on your device. Nothing is sent anywhere.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.