Code Line Counter

Measure a codebase: open files or a folder and see code, comment and blank lines per language and per file, with comment ratio and a chart, all in your browser.

S'executa al teu navegador. Els fitxers mai no surten del dispositiu. Mira com comprovar-ho

…

Com es fa

  1. 1
    Open files

    Select source files, or paste code.

  2. 2
    Pick the language

    For pasted code only.

  3. 3
    Read totals

    Code, comment and blank lines.

  4. 4
    Compare languages

    Check the chart and table.

  5. 5
    Check files

    Find the largest files.

  6. 6
    Export

    Copy or download the tables.

Sobre aquesta eina

Lines of code are a rough but useful measure: for estimating review effort, comparing the size of modules, tracking how a project grows, checking how much of a codebase is documentation, or describing a project in a proposal. Counting properly means separating real code from comments and blank lines, and that depends on each language's comment syntax, including block comments that span many lines and comment markers that appear inside strings. This counter understands 30 languages, from JavaScript, TypeScript, Python, Java, C, C#, Go and Rust to PHP, Ruby, Kotlin, Swift, SQL, shell, HTML, CSS, YAML and more. Open many files at once, or a whole folder in Chrome and Edge, and get totals by language, a table for every file and the comment ratio. Nothing is uploaded, so you can measure private code safely.

How lines are classified

- Blank: only whitespace. - Comment: only a comment, or inside a block comment. - Code: anything else, including a line with code followed by a comment. Comment markers inside strings, such as "http://", are ignored. Nested block comments are handled for languages that allow them (Rust, Kotlin, Swift, Haskell). Python docstrings at the start of a line count as comments, as most tools do.

Languages

JavaScript, TypeScript, Python, Java, C and C++, C#, Go, Rust, PHP, Ruby, Kotlin, Swift, SQL, shell, CSS, HTML and XML, JSON, YAML, Lua, R, Haskell, Scala, Dart, Perl, PowerShell, Elixir, Markdown, Dockerfile, Makefile and TOML/INI. Files with other extensions are skipped and counted in a note.

Reading the results

The comment ratio is comments divided by code plus comments. Around 15 to 30 per cent is common in application code; generated code and tests vary widely. Large differences between similar modules may point to missing documentation or dead commented-out code.

Folders

In Chrome and Edge you can select several files at once; to count a folder, select all files inside it. Skip vendor and build folders (node_modules, dist, target) to count your own code only.

Comparing over time

Run the counter on the same folders before and after a refactor or release to see how much code was added or removed and whether documentation kept pace. Keep the CSV from each count to build a simple history of the codebase, and note the date and version beside each file.

Limits

Lines are a size measure, not a quality or productivity measure. Minified files count as few lines. Unusual syntax, such as heredocs containing comment markers, can occasionally be misclassified. For large repositories, the command-line tool cloc is faster; this counter is an estimate, not an audit.

Exemple resolt

A small project with 120 TypeScript files and 14 Python scripts counts 18,420 code lines, 3,960 comment lines and 2,880 blank lines, a comment ratio of 18 per cent, with TypeScript making up 91 per cent of the code.

En resum

Preguntes freqüents

Which languages does it understand?

Thirty, including all common programming, markup and configuration languages.

Are comments inside strings counted as comments?

No. String contents are skipped.

Can I count a whole folder?

Select all the files inside it; skip vendor and build folders.

Is my code uploaded?

No. Counting runs in your browser.

What is a good comment ratio?

Often 15 to 30 per cent, but it depends on the code.

How does it compare with cloc?

The rules are similar; cloc is faster for very large repositories.

Totalment gratisSense cost, sense registre
Els fitxers es mantenen privatsTot funciona al teu navegador
Fàcil en el teu idiomaDisponible en molts idiomes