AbraCalc

Lines of Code Counter

Count total lines, non-empty lines, and blank lines in code or text. Free, instant.

Embed this tool on your site
Cite this tool

APA

AbraCalc. (2026). Lines of Code Counter [Online calculator]. Retrieved from https://abracalc.com/generator/lines-of-code-counter/

BibTeX

@misc{abracalc-lines-of-code-counter, author = {AbraCalc}, title = {Lines of Code Counter}, year = {2026}, howpublished = {\url{https://abracalc.com/generator/lines-of-code-counter/}} }

Did this tool answer your question?

How to use this tool

  1. Enter code or text in the fields above.
  2. Results update instantly as you type — or click Calculate.
  3. Read your total lines and the full breakdown beneath it.

Quickly count total lines, non-empty code lines, and blank lines in any snippet — useful for estimating project size or documentation density.

How it works

The Lines of Code Counter reads the text or code you paste and reports three numbers: total lines (every line including blank ones), non-blank lines (lines with at least one non-whitespace character), and blank lines (lines that are entirely empty or contain only spaces).

It works on any language or plain text because it counts structural lines rather than parsing syntax. Paste a Python function, a SQL file, a shell script, or a README and the counts are accurate regardless of language.

Use it to get a quick feel for file size before committing code, to satisfy a style rule limiting function length, or to compare two versions of a file at a glance.

Counting is instant and runs in your browser. The text is never uploaded anywhere.

Worked example

Check the length of a function before a code review

  1. Select the function body in your editor and copy it.
  2. Paste it into the 'Code or text' box.
  3. Read the 'Non-blank lines' figure.
  4. Compare it to your team's maximum function length guideline.

An accurate non-blank line count confirming whether the function is within the agreed limit.

Common mistakes to avoid

  • Copying only part of a file and treating the result as the total file LOC.
  • Confusing 'total lines' with 'lines of code' — blank lines and comment-only lines inflate the total but are not executable code.
  • Pasting minified code as a single long line — the counter shows 1 total line, which is technically correct but not a useful complexity measure.

Key terms

LOC (Lines of Code)
A software metric that counts the number of lines in a source file, often used as a rough proxy for code size or complexity.
Non-blank line
Any line that contains at least one character that is not a space or tab.
Blank line
A line containing no characters, or only whitespace, with no code or text content.

Frequently asked questions

What counts as a blank line?
A blank line is one containing only whitespace (spaces and tabs). Comments are counted as non-empty lines.

References & sources