vv0.1.0 · Apache-2.0 · GitHub
mokei counts code. Give it files or a directory and it prints code, comment and blank lines for each language it finds. It does what tokei does, for 40 languages in version 0.1.0, with the language table in one TOML file. The main branch has 42 rows: GDScript and Godot Shader were added after the release.
A line count answers one question: how large is this code? The questions that come up in review and in agent work are different. Is this diff inside the size budget? How many tokens will this repository cost in a prompt? Is this block copied from another file? Which functions have no test that names them? tokei answers the first question well. The others need a second tool, or a script for each one.
mokei keeps tokei's counts where tokei is right, and adds those four questions to the same command. Where tokei is wrong, the difference is listed in docs/known-diffs.md with a small fixture that shows it.

Each row in languages.toml names a language's comment markers, string delimiters and embedded languages. The scanner reads every file with its row. Markdown fences and HTML <script> and <style> blocks are counted as child rows under their own language, as tokei counts them. With no arguments inside a git repository, mokei reads git ls-files. Anywhere else it walks the directory and honours .gitignore. The scan runs in parallel. MOKEI_JOBS=1 runs it serially and prints the same output.
Two modes do not parse code. --semantic counts statements, functions, nesting and cyclomatic complexity from token rules, per file, for Python, Mojo, JavaScript, Rust and C. --tokens estimates tokens with a byte-level model fitted to the Qwen2.5 tokenizer, unless you give it a real tokenizer.json.
mokei [FILE|DIR ...].--files: one row per file under its language.--sort code|lines|files: orders the language rows.--json: one JSON object with the languages and the total.--semantic FILES: statements, functions, maximum nesting and cyclomatic complexity per file.--diff A..B: code, comment and blank lines added and removed, per language, with lines of code before and after.--budget XS|S|M|L with --diff: exit status 1 when the added code lines reach the limit (20, 60, 150 or 400).--tokens: tokens per language. An estimate by default.--tokenizer PATH: the real count from a Hugging Face tokenizer.json. It is single-threaded: about 0.1 s for a small repository, minutes for a 140 MB tree.--dupes N: blocks of at least N normalised code lines that occur twice.--untested: definitions whose name appears in no test file. A hint, not coverage.MOKEI_LANGS=PATH: another language table. A new language is one [[lang]] row.--version.
Parity. mokei matched tokei 15.0.0 on four corpora: this repository, a web app, a tool collection, and an 11.5k-file checkout of the Modular monorepo. The exceptions are in docs/known-diffs.md. The 26 probe files in tests/fx/emb match tokei exactly.
Speed. On the 11.5k-file checkout, measured on 2026-11-07, mokei took 67.4 ms of wall time against 100.1 ms for tokei (1.49x), and 351 ms of CPU time against 989 ms. A later change for embedded languages added about 5%, to 70.9 ms. tokei is no longer installed on that machine, so the comparison cannot be repeated there, and the receipt is not committed to the repository.
Tokens. Without a tokenizer, the estimate is within 3% of the Qwen2.5 count in total on the corpora measured. Each language of 50 kB or more is within 6%. Two repositories held out of the fit, mojo-vattn and corewait, stayed within 6% in total.
Tests. tests/test_mokei.sh has 11 stages. tests/negative.sh breaks one expectation per case and requires a failure, four cases in all.
git clone https://github.com/amarbarosys/mokei && cd mokei
pixi install
pixi run gate # build, tests/test_mokei.sh, negative control; no GPU
.bin/mokei --version
Without pixi, set MOJO and MOKEI_TOKENIZERS and run ./build.sh. Then, inside any repository:
$ mokei
Language Files Lines Code Comments Blanks
Python 3 38 31 4 3
Total 3 38 31 4 3
The full set of modes, each with output captured from a real run, is in docs/usage.md.
languages.toml and VERSION through /proc/self/exe.docs/known-diffs.md.--untested is a name match. A name that appears in a test file counts as tested.--tokens is an estimate unless you pass --tokenizer.--sort, --files and --json of tokei's flags exist. Its other options do not.Source: https://github.com/amarbarosys/mokei (public, Apache-2.0). Release 0.1.0 was published on 2026-11-08.