# tokei

> Fast code statistics tool that counts lines of code, comments, and blanks across 150+ programming languages

Stars: 15.0k · Language: Rust · License: MIT · Categories: Dev Tools

- Repository: https://github.com/XAMPPRocky/tokei
- Page: https://www.trmn.sh/tools/tokei

## Install

- Homebrew: `brew install tokei`
- Cargo: `cargo install tokei`
- Package Manager: `pacman -S tokei`

## Overview

Tokei is a command-line code analysis tool that generates detailed statistics about codebases. It counts files, total lines, code lines, comments, and blank lines, organizing results by programming language. The tool supports over 150 languages and their file extensions, correctly handling multi-line comments, nested comments, and comments within strings for accurate analysis.

The tool excels at performance, processing millions of lines of code in seconds. It respects `.gitignore` and `.ignore` files by default, with additional filtering options through `--exclude` flags and `.tokeignore` files. Results can be sorted by various metrics (files, lines, code, comments, blanks) and output in multiple formats including JSON, YAML, and CBOR for integration with other tools.

Tokei offers flexible usage patterns, from basic directory analysis (`tokei ./src`) to complex workflows involving multiple directories, custom exclusions, and format transformations. The `--files` flag provides per-file statistics, while the `--input` option allows combining results from previous runs. It functions both as a standalone CLI tool and as a Rust library for programmatic integration.

### Installation

```bash
# via Homebrew
brew install tokei
```

```bash
# via Cargo
cargo install tokei
```

```bash
# via Package Manager
pacman -S tokei
```

## Alternatives

- [asciinema](https://www.trmn.sh/tools/asciinema.md): Command-line tool for recording and live streaming terminal sessions to lightweight asciicast files (Rust, 17.9k stars)
- [Hurl](https://www.trmn.sh/tools/hurl.md): Command line tool that runs and tests HTTP requests defined in plain text files, with request chaining, captures, asserts, and CI reports. (Rust, 19.3k stars)
- [hexyl](https://www.trmn.sh/tools/hexyl.md): Terminal hex viewer that colors bytes by category: NULL, printable ASCII, whitespace, other ASCII, and non-ASCII. (Rust, 10.3k stars)
- [grex](https://www.trmn.sh/tools/grex.md): CLI tool that generates regular expressions from user-provided test cases automatically (Rust, 8.3k stars)
- [tailspin](https://www.trmn.sh/tools/tailspin.md): Log file highlighter (binary: tspin) that colors dates, numbers, IPs, UUIDs, URLs and more in any log format, with no config, and pages output through less. (Rust, 8.0k stars)

---

Canonical: https://www.trmn.sh/tools/tokei
