Line Counter

Paste text, source code, a log file or a CSV and the counter returns total lines, non-empty lines, blank lines, unique lines and duplicate lines. Handy when a recruiter asks “how many LOC in this repo?”, when you need to know how many rows a CSV has without opening it in Excel, or when you want to check a wordlist for duplicates before feeding it into a script.

How to count lines

  1. 1

    Paste the content

    Up to a few megabytes of text: log, source file, markdown, list.

  2. 2

    Read the breakdown

    Total, non-empty, blank, unique and duplicate counts display at once.

  3. 3

    Decide what counts

    Comments, trailing newlines, blank-between-sections: your use-case decides.

  4. 4

    Act on the count

    Size the import, deduplicate, trim, or report the number as evidence.

What actually counts as a line

Different tools give different “line counts” for the same file because they make different choices on three points.

The three ambiguities

  1. Trailing newline. POSIX text files end in \n. Does the final newline add an extra empty line? wc -l counts newlines, so a file with content on one line plus a trailing newline reports 1; a file with content and no trailing newline reports 0 (which is surprising). This counter reports “lines of content”, ignoring the final empty line after a terminator.

  2. Blank vs whitespace-only. A line with spaces or tabs but no visible character, is it empty or not? The counter treats whitespace-only lines as blank, matching most editors.

  3. Single-line files. A one-line file without a trailing newline is still 1 line.

Counter outputs explained

Metric Definition
Total lines All lines, including blanks, up to the last non-empty line
Non-empty Lines with at least one non-whitespace character
Blank Lines that are empty or whitespace-only
Unique Distinct non-empty lines, case-sensitive
Duplicates Non-empty lines that appear more than once (count of the duplicates)

Common use cases

  • Wordlist dedup, paste a wordlist, see duplicates count, then run through a deduplicator.
  • CSV row count, paste the file body; subtract 1 for the header to get data rows.
  • Log parsing, check that a rotated log has the expected number of entries.
  • Source-file LOC, quick “how many lines in this file” without opening an IDE.
  • Email list hygiene, see how many addresses are duplicates before sending a campaign.

LOC is not productivity

Line count of source code is a blunt measure. A dense, well-factored 100-line module can be harder to write and maintain than a sprawling 1,000-line one. Use line counts for scope estimates (fitting in a context window, paginating output, comparing file sizes) rather than performance evaluation.

Unicode and line terminators

The counter normalises \r\n, \r and \n to a single newline before counting, so Windows, classic Mac and Unix line endings all produce the same result. Unicode line separators (U+2028) and paragraph separators (U+2029) are also treated as breaks.

Frequently Asked Questions

wc -l counts newline characters, so a file with content and no final newline reports one fewer. This counter reports “number of lines of content”, which matches most editor status bars.

Yes, lines containing only spaces or tabs count as blank, not non-empty. That matches VS Code, Sublime and most Git workflows.

Yes. “Hello” and “hello” count as distinct unique lines. If you want case-insensitive dedup, lowercase your input first with a case converter.

No, the counter reads input locally and nothing is uploaded or logged.

Related Tools

Tool available in other languages