Count your code, quickly.
) Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code, comments, and blanks grouped by language.
…Tokei is very fast, and is able to count millions of lines of code in seconds. Check out the 11.0.0 release to see how Tokei's speed compares to others.
Tokei is accurate, Tokei correctly handles multi line comments, nested comments, and not counting comments that are in strings. Providing an accurate code statistics.
Tokei has huge range of languages, supporting over 150 languages, and their various extensions.
Tokei can output in multiple formats (CBOR, JSON, YAML) allowing Tokei's output to be easily stored, and reused. These can also be reused in tokei combining a previous run's statistics with another set.
Tokei is available on Mac, Linux, and Windows. See installation instructions for how to get Tokei on your platform.
Tokei is also a library allowing you to easily integrate it with other projects.
Tokei comes with and without color. Set the env variable NO_COLOR to 1, and it'll be black and white.
# Alpine Linux (since 3.13)
apk add tokei
# Arch Linux
pacman -S tokei
# Cargo
cargo install tokei
# Conda
conda install -c conda-forge tokei
# Fedora
sudo dnf install tokei
# FreeBSD
pkg install tokei
# NetBSD
pkgin install tokei
# Nix/NixOS
nix-env -i tokei
# OpenSUSE
sudo zypper install tokei
# Void Linux
sudo xbps-install tokei# Homebrew
brew install tokei
# MacPorts
sudo port selfupdate
sudo port install tokei# Winget
winget install XAMPPRocky.tokei
# Scoop
scoop install tokeiYou can download prebuilt binaries in the releases section.
You can also build and install from source (requires the latest stable Rust compiler.)
cargo install --git https://github.com/XAMPPRocky/tokei.git tokeiTokei has a configuration file that allows you to change default behaviour.
The file can be named tokei.toml or .tokeirc. Currently tokei looks for
this file in three different places. The current directory, your home directory,
and your configuration directory.
This is the basic way to use tokei. Which will report on the code in ./foo
and all subfolders.
$ tokei ./fooTo have tokei report on multiple folders in the same call, simply add all the folders you'd like tokei to examine.
$ tokei ./foo ./bar ./bazTokei will respect all .gitignore and .ignore files, and you can use
the --exclude option to exclude any additional files. The --exclude flag has
the same semantics as .gitignore.
$ tokei ./foo --exclude *.rsPaths to exclude can also be listed in a .tokeignore file, using the same
syntax as .gitignore files.
By default tokei sorts alphabetically by language name, however using --sort
tokei can also sort by any of the columns.
blanks, code, comments, lines
$ tokei ./foo --sort codeBy default tokei only outputs the total of the languages, and using --files
flag tokei can also output individual file statistics.
$ tokei ./foo --filesTokei normally outputs into a nice human readable format designed for terminals.
There is also using the --output option various other formats that are more
useful for bringing the data into another program.
Note: This version of tokei was compiled without any serialization formats, to enable serialization, reinstall tokei with the features flag.
ALL:
cargo install tokei --features all
CBOR:
cargo install tokei --features cbor
YAML:
cargo install tokei --features yamlCurrently supported formats
--output json--output yaml--output cbor$ tokei ./foo --output jsonTokei can also take in the outputted formats added in the previous results to its current run. Tokei can take either a path to a file, the format passed in as a value to the option, or from stdin.
$ tokei ./foo --input ./stats.json…Tokei is available in a small alpine-based docker image, buildable through earthly:
earthly +dockerOnce built, one can run the image with:
docker run --rm -v /path/to/analyze:/src tokei .Or, to simply analyze the current folder (linux):
docker run --rm -v $(pwd):/src tokei .If there is a language that you would to add to tokei feel free to make a pull
request. Languages are defined in languages.json, and you can
read how to add and test your language in our CONTRIBUTING.md.
…This is likely due to gcc generating .d files. Until the D people decide on
a different file extension, you can always exclude .d files using the
-e --exclude flag like so
$ tokei . -e *.dThe canonical source of this repo is hosted on GitHub. If you have a GitHub account, please make your issues, and pull requests there.
(C) Copyright 2015 by XAMPPRocky and contributors
See the graph for a full list of contributors.
Tokei is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENCE-APACHE, LICENCE-MIT for more information.
No open issues yet, or sync has not completed.