Home / Text tools / Code line counter

Code Line Counter

Paste code or open a file to see how many lines are code, comments or blank, for your language.

0Total lines
0Code lines
0Comment lines
0Blank lines

Lines of code, comments and blanks

Choose a language, then paste your code or open a file. The counter splits every line into code, comment or blank, and shows each as a number and as a share of the file. A line with code followed by a trailing comment counts as code.

How comments are found

  • Line comments such as // or # make the whole line a comment when they start the line.
  • Block comments, such as /* to */ or the HTML comment markers, are tracked across lines.
  • Blank lines inside a block comment are counted as blank.

Limits to know about

This is a quick estimate, not a full parser. Comment markers inside strings can be misread, and Python docstrings are counted as code. For reports on whole projects, use a command line tool such as cloc.

Using the numbers

Lines of code help estimate size, compare versions and plan reviews. They are a poor measure of productivity or quality, so use them as context rather than a target.

For total lines of any text use the line counter. To drop blank lines, try the non-empty line counter. The guide covers counting lines in the terminal.

Frequently asked questions

What is the difference between LOC and SLOC?

LOC is every line. SLOC, or source lines of code, usually excludes blank lines and comments.

Which languages are supported?

JavaScript, TypeScript, Java, C, C++, C#, Go, Rust, Swift, Kotlin, PHP, CSS, Python, Ruby, Shell, YAML, SQL and HTML or XML.

Is my code uploaded?

No. Files are read in your browser and nothing is sent to a server.

Why does my total differ from my editor?

Editors may count the empty line after a final line break. This tool does not add an extra line for it.