Code

Code Line Counter

Separates code lines from comment and blank lines, so the number means something.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste a source file, or upload one.
  2. Leave the language on detect unless the guess in the summary is wrong.
  3. Select Count.
  4. Read the code line count rather than the total — that is the number worth comparing between files.

What code line counter does

A total line count tells you almost nothing, because a file that is half licence header and half blank lines reads very differently from one that is not. This splits the total into code, comments and blanks, and counts a line carrying code with a comment on the end as code, which is the convention every SLOC tool follows.

The split is worked out by tokenising the source rather than by matching comment markers, so a URL containing // inside a string stays code and a brace inside a comment is not counted. Comment density is reported as a share of non-blank lines, which is the only form of it worth comparing between files.

Frequently asked questions

As code. That is the convention every SLOC tool follows, and it is the sensible one: the line does something. It is also counted separately in its own row, so you can see how much of the file is code carrying a trailing note.

Because the total is dominated by whatever the file happens to contain — a licence header, generated code, a run of blank lines. Splitting code from comments is the only way the number can be compared between two files, and doing that split correctly means knowing that // inside a string is not a comment.

Yes. A triple-quoted string at the top of a module or function is a string to the interpreter and documentation to everyone else, and counting it as documentation is what makes the comment density figure meaningful.

No. Everything happens in your browser. Nothing is sent to a server, nothing is stored, and closing the tab is all it takes to be rid of it.