Advertisement

Line Counter

Count lines in text or code: total, blank and non-blank lines, duplicates, the longest line and lines over a length limit, line by line.

Up to 200,000 UTF-16 code units.

Count the lines in any text, list or code snippet. As well as the total, you get blank and non-blank lines, unique and repeated lines, the longest line and how many lines run past a length limit such as 80 characters — handy for checking a list before an import, counting entries in a CSV export or keeping code inside a style guide’s line length.

How to use this tool

  1. Paste your text, list or code into the box.
  2. Set the line length limit you want to check against (80 characters by default).
  3. Choose whether duplicates should ignore surrounding spaces and upper/lower case.
  4. Use the tables to find repeated lines and lines that are too long.

Formula

Non-empty text: lines = line breaks + 1, minus 1 if text ends in a newline. Empty text has 0 lines.

A blank line is empty or contains only spaces or tabs. Line length is measured in visible characters, so an emoji or accented letter counts as one and a tab counts as one. Blank lines also count toward the maximum and limit. Long lines that merely wrap on screen are still single lines.

Example

The sample guest list has 9 lines: 8 with names and 1 blank. “Ben Carter” appears twice (lines 2 and 5), so there are 7 unique lines and 1 repeated copy to delete. The longest line is line 7 at 14 characters because of the spaces around “Emma Novak”, and no line is over the 80-character limit.

Frequently asked questions

Does a line break at the end of the text add a line?

No. Most editors and the Unix command wc -l treat a final newline as the end of the last line, not the start of a new one. The “Line breaks” row shows the raw number of newline characters, which is the number wc -l prints.

Are wrapped lines counted?

No. Only real line breaks start a new line, so a long paragraph that wraps across the screen is still one line.

How are duplicate lines found?

Non-blank lines are compared, by default after trimming spaces at each end and optionally ignoring case. “Unique lines” counts each distinct line once; “Repeated copies” is how many lines you would delete to leave one of each.

What line length limit should I use for code?

Python’s PEP 8 style guide limits lines to 79 characters, 80 is traditional for many C and shell projects, and some teams allow 100 or 120. Set the limit to match your project’s style guide.

Sources

Last updated: 2026-10-30

Advertisement