A zero-dependency Python source code line counter, similar to cloc and tokei. Count lines of code, comments, and blanks across 50+ programming languages.
- Count lines of code, comments, and blanks by language
- Support for 50+ programming languages
- Respects
.gitignorepatterns automatically - Default ignore list (node_modules, .git, pycache, etc.)
- Directory tree view with line counts
- Compare two directories side-by-side
- Output as table, JSON, CSV, or Markdown
- Sort by lines, files, language, or any column
- Custom ignore patterns
- Single file, zero dependencies
- Python 3.7+
- No external dependencies
git clone https://github.com/Anuar-boop/codecount.git
cd codecount
chmod +x codecount.pypython3 codecount.py .python3 codecount.py src/python3 codecount.py . --jsonpython3 codecount.py . --csv > stats.csvpython3 codecount.py . --markdown >> README.mdpython3 codecount.py . --sort filespython3 codecount.py . --tree
python3 codecount.py . --tree --tree-depth 5python3 codecount.py --compare project-v1/ project-v2/python3 codecount.py . -i "*.test.js" "fixtures" "mocks" my-project
-------------------------------------------------------------------
Language Files Code Comments Blanks Total
-------------------------------------------------------------------
TypeScript 45 12,340 1,230 890 14,460
JavaScript 12 3,210 450 320 3,980
Python 8 2,100 380 210 2,690
CSS 6 890 120 80 1,090
YAML 4 230 45 30 305
Markdown 3 180 0 60 240
JSON 2 120 0 0 120
-------------------------------------------------------------------
Total 80 19,070 2,225 1,590 22,885
-------------------------------------------------------------------
|-- src/ (65 files, 15,340 lines)
| |-- components/ (30 files, 8,200 lines)
| |-- hooks/ (10 files, 2,100 lines)
| |-- services/ (15 files, 3,800 lines)
| --- utils/ (10 files, 1,240 lines)
|-- tests/ (12 files, 3,500 lines)
--- config/ (3 files, 230 lines)
-------------------------------------------------------------------
Language Dir1 Code Dir2 Code Diff Change
-------------------------------------------------------------------
TypeScript 10,200 12,340 +2,140 +21.0%
JavaScript 3,500 3,210 -290 -8.3%
Python 1,800 2,100 +300 +16.7%
-------------------------------------------------------------------
Python, JavaScript, TypeScript, JSX, TSX, Java, C, C++, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, Scala, R, Lua, Perl, Shell, Bash, Zsh, HTML, CSS, SCSS, Sass, Less, SQL, YAML, TOML, XML, JSON, Markdown, Dart, Vue, Svelte, Elixir, Erlang, Haskell, OCaml, Clojure, Nim, Zig, Terraform, Protobuf, Pine Script, Solidity, and more.
MIT License - see LICENSE for details.