How to Count Lines of Code: SLOC, Comments and Blank Lines
Count lines of code in files or a whole folder, split into code, comments and blank lines for 30 languages, and learn what the numbers really tell you.

How to Count Lines of Code: SLOC, Comments and Blank Lines
How big is this codebase? The question comes up when estimating a migration, scoping an audit, comparing two libraries, writing a grant report or simply getting to know a new project. Lines of code is the oldest and simplest answer. The free Code Line Counter counts files or a whole folder in your browser and splits every line into code, comments and blank lines, per language, like the command-line tool cloc but without installing anything.
Three kinds of line
A raw line count mixes very different things, so the counter classifies each line:
- Code: a line containing at least one character of program text, even if it also has a trailing comment.
- Comment: a line that contains only a comment, including every line of a block comment and documentation comments.
- Blank: a line with nothing but whitespace.
Source lines of code, or SLOC, usually means the code lines alone. The comment ratio, comments divided by code, gives a rough sense of documentation density, although a high number can also mean large blocks of commented-out code.
Thirty languages
Each language has its own comment syntax. Python and shell use hash marks, C-family languages use double slashes and slash-star blocks, HTML and XML use their own comment markers, SQL uses double dashes, and Lua, Haskell and others have their own forms. The counter recognises the language from the file extension and applies the right rules, including strings that contain comment-like characters, so a URL with two slashes inside a string is not mistaken for a comment.
Counting a folder
In Chrome and Edge you can pick an entire folder. The counter reads every file, skips common generated and dependency folders, and groups the results by language, with a total row at the bottom. Other browsers let you select many files at once. Files never leave your computer; they are read locally by the browser.
Generated code distorts the totals, so leave out build outputs, lock files, minified bundles and vendored libraries if your folder includes them. The goal is to measure code people wrote and maintain.
What the numbers mean
Lines of code measure size, not value or effort. A short, clever function can take longer to write than a long, simple one, and deleting code is often the most valuable change a developer makes. Use counts to:
- compare the size of modules or services within one project;
- track growth over time, by counting before and after each release;
- estimate rough effort for mechanical work such as a language migration or a licence review;
- spot imbalances, such as a test folder far smaller than the code it tests.
Avoid using line counts to measure individual productivity. They reward verbose code and punish careful refactoring.
Lines and complexity
Two files with the same number of lines can differ hugely in difficulty. A long configuration table is easy to read, while a short function full of nested conditions is not. Pair line counts with a look at the largest files in the table: they are usually the best candidates for splitting.
Comparing over releases
Save the CSV export from each count with the date and version. Over a year, a simple spreadsheet shows which parts of the system grow fastest and whether documentation and tests keep pace.
Step by step
- Open files, choose a folder, or paste code and pick its language.
- Wait a moment while the files are read and classified.
- Read the totals per language: files, code, comments and blank lines.
- Look at the comment ratio and the largest files.
- Export the table as CSV to keep a record.
Privacy
All counting happens in the browser. Proprietary source code is read locally and never uploaded to any server.



