Korean

tokei — Code Line Counter

Linux / Modern CLI Tools / tokei.html

Modern CLI ToolsOriginalRegistered 2026-01-19T18:00:00+09:00

💬 "tokei command"

tokei is a tool that counts lines of code by language across a codebase. It tells you how much code you have per language, and how many of those lines are code, comments, and blanks.

Written in Rust it counts even huge repositories in an instant, and can filter to only git-tracked or hidden files. Use it to gauge project size and plan refactors.

  • Concept: Scan a folder and report per-language code, comment, and blank line counts.
  • Features: Per-language line counts, code/comment/blank split, file counts, sorting, and JSON output.
  • Strength: Counts even hundred-thousand-line projects in under a second, as a table or JSON.
  • Use when: Gauging project size, checking technical debt, or comparing language mixes.

Basic Usage

tokei counts automatically when you point it at a folder. No config needed.

1. Basic count

Scan the current folder for per-language stats.

tokei           # current folder
tokei src        # a specific folder

2. Filtering

Include hidden files or skip gitignore.

tokei --hidden         # include hidden files
tokei --no-ignore       # ignore .gitignore
tokei --files           # count files only

3. Sorting and output

Sort by most code or emit JSON.

tokei --sort code      # sort by code lines
tokei -o json | jq '.["Rust"].code'

Installation & Download

tokei installs via cargo, a package manager, or a release binary.

EnvironmentCommand
cargocargo install tokei
Ubuntu/Debian (if packaged)sudo apt install tokei
Archsudo pacman -S tokei
Release binarygithub.com/XAMPPRocky/tokei/releases

Verify with tokei --version. Count with tokei folder by passing a path.

Common Options

Command / KeyDescription
--sort codeSort by code line count
--filesCount only files
--hiddenInclude hidden files
--no-ignoreIgnore .gitignore rules and count everything
-o jsonOutput JSON for piping to other tools

3 Essential Command Combinations

  • tokei . — Count lines per language in the project
  • tokei --sort code | head — See the languages with the most code
  • tokei -o json | jq 'keys' — Extract the language list as JSON

💬 "Using tokei on a real server"

A step-by-step look at gauging project size.

Step 1 · Count the project

Scan the project folder.

tokei ~/workspace/site

Step 2 · Sort by language

See which languages dominate.

tokei --sort code ~/workspace/site

Step 3 · Save results

Store the stats as JSON.

tokei -o json ~/workspace/site > loc.json

How it is used in practice

1. Gauge project size

Situation — Check the size of a newly joined project.

tokei --sort code .

Result — Per-language code, comment, and blank counts appear as a table.

Point — Set refactor priorities and estimate effort.

2. Compare language mixes

Situation — Compare language balance across projects.

for d in api web; do echo $d; tokei --sort code $d | head -3; done

Result — Compare top languages per project.

Point — Check for tech-stack skew or duplication.

Caveats

  • Files listed in .gitignore are excluded by default (use --no-ignore to include them).
  • With --no-ignore on very large dependency folders, counting can slow down.
  • tokei counts lines only—it does not judge code quality or complexity.