⚡ 59 developer tools, always updated, new upstream releases land in apt within hours. Join the Discord

📅 From , the apt mirror will require a subscription. See pricing · 🆓 There is an always-free mirror

Install Latest tree-sitter-cli on Ubuntu

Generate, build, test and debug Tree-sitter parsers and grammars from the command line

Latest version: 0.27.0 · updated 2026-09-15
SourceVersion
deb.griffo.io0.27.0 ✅
Official Ubuntu0.25.9 🛑
← Back to home

What is tree-sitter-cli?

tree-sitter-cli is the command-line tool for developing Tree-sitter parsers. Tree-sitter is a parser generator and an incremental parsing library: it builds a concrete syntax tree for a source file and updates it cheaply as the file is edited, which is why Neovim, Helix, Zed and GitHub use it for highlighting, folding, text objects and code navigation. The CLI is how grammars get made: it scaffolds a grammar repository, generates a C parser from grammar.js, compiles it to a shared library or to WebAssembly, runs corpus tests, parses, queries, highlights and tags files, and serves a web playground. It is a single Rust binary, and the command you type is tree-sitter.

🚀 Why Latest Versions Matter: grammars move with the CLI: the current parser ABI, the tree-sitter.json layout that tree-sitter init writes and the built-in QuickJS runtime behind --js-runtime native all arrived after the versions frozen into the archives. A grammar repository generated with a current CLI expects the same or newer on every contributor's machine and in CI. Debian stable's 0.22.6 and Ubuntu 24.04's 0.20.8 predate most of that, and upstream's own Linux binaries need glibc 2.39, so they do not even start on Debian 12 or Ubuntu 22.04.

⚡ Key Features of tree-sitter-cli

🧱 Grammar Repositories in One Command

tree-sitter init asks a few questions and writes grammar.js, tree-sitter.json and the binding and package files, so the grammar is ready to publish for Node.js, Python, Rust, Go, Swift and C from day one.

⚙️ Parser Generation

tree-sitter generate turns grammar.js into a dependency-free C parser in src/ and reports conflicts. It runs the grammar with node, or with the built-in QuickJS runtime via --js-runtime native.

🔨 Native and WebAssembly Builds

tree-sitter build compiles the parser into a shared library that editors load, and --wasm produces a .wasm module for web-tree-sitter and the playground.

🧪 Corpus Tests

tree-sitter test parses the examples under test/corpus, compares the trees with the expected S-expressions and runs highlight and tag tests too. --update rewrites the expectations after an intended change.

🔍 Parse, Query, Highlight, Tag

parse prints the syntax tree, query runs a .scm query and lists its captures, highlight renders to the terminal or to HTML, and tags extracts definitions and references.

🛝 Web Playground

tree-sitter playground serves a local page where you type code, watch the tree update as you edit and run queries against it, which is the fastest way to see why a rule does not match.

🚀 Always ahead of the official archives: Debian and Ubuntu freeze package versions when a release ships. This repository publishes new upstream releases typically within hours. A simple apt upgrade keeps you on the latest version.

📦 Installation from deb.griffo.io

Run the commands

Step 1: Add Repository

sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://deb.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | sudo gpg --dearmor --yes -o /etc/apt/keyrings/deb.griffo.io.gpg
echo "deb [signed-by=/etc/apt/keyrings/deb.griffo.io.gpg] https://deb.griffo.io/apt $(lsb_release -sc 2>/dev/null) main" | sudo tee /etc/apt/sources.list.d/deb.griffo.io.list > /dev/null
sudo apt update
install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://deb.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | gpg --dearmor --yes -o /etc/apt/keyrings/deb.griffo.io.gpg
echo "deb [signed-by=/etc/apt/keyrings/deb.griffo.io.gpg] https://deb.griffo.io/apt $(lsb_release -sc 2>/dev/null) main" | tee /etc/apt/sources.list.d/deb.griffo.io.list > /dev/null
apt update

🆓 There is an always-free mirror. deb-free.griffo.io serves packages free forever, no account, no subscription, at most 2 months behind upstream, security fixes immediately. It currently carries cliamp, Ghostty, lazydocker, Oh My Posh, Uncloud and Zed; tree-sitter-cli is not one of them, so the repository above is the only way to get it today, ask and it can be enrolled.

How the free mirror works →

Step 2: Install tree-sitter-cli

# Install latest tree-sitter-cli
sudo apt install tree-sitter-cli

# Verify installation, the command is tree-sitter and not tree-sitter-cli
tree-sitter --version
# Install latest tree-sitter-cli
apt install tree-sitter-cli

# Verify installation, the command is tree-sitter and not tree-sitter-cli
tree-sitter --version

Step 3: Create your first grammar

# The command is tree-sitter. Building and testing parsers needs a C compiler,
# and generate runs grammar.js with node unless you pick the built-in runtime
sudo apt install build-essential nodejs

# Scaffold a grammar repository, answering a few questions
mkdir tree-sitter-mylang && cd tree-sitter-mylang
tree-sitter init

# Generate the parser, compile it and run the corpus tests
tree-sitter generate
tree-sitter build
tree-sitter test

# bash, zsh, fish and nushell completions ship with the package
tree-sitter --help
# The command is tree-sitter. Building and testing parsers needs a C compiler,
# and generate runs grammar.js with node unless you pick the built-in runtime
apt install build-essential nodejs

# Scaffold a grammar repository, answering a few questions
mkdir tree-sitter-mylang && cd tree-sitter-mylang
tree-sitter init

# Generate the parser, compile it and run the corpus tests
tree-sitter generate
tree-sitter build
tree-sitter test

# bash, zsh, fish and nushell completions ship with the package
tree-sitter --help

🎯 Basic Usage Examples

Working on a grammar:

# Regenerate after each grammar.js change, without node, using the built-in QuickJS
tree-sitter generate --js-runtime native

# Run only the tests whose names match, then accept new output as the expectation
tree-sitter test --include 'function'
tree-sitter test --update

# Build a shared library, or a WebAssembly module for web-tree-sitter
tree-sitter build -o mylang.so
tree-sitter build --wasm

Parsing files:

# Print the syntax tree of a file
tree-sitter parse examples/hello.mylang

# Parse many files quietly and report how many succeeded
tree-sitter parse examples/*.mylang --quiet --stat

# Time a parse, useful when a grammar change slows things down
tree-sitter parse examples/big.mylang --time

Queries, highlighting and tags:

# Run a query against a file and list what it captures
tree-sitter query queries/highlights.scm examples/hello.mylang

# Highlight a file in the terminal, or render a standalone HTML page
tree-sitter highlight examples/hello.mylang
tree-sitter highlight --html examples/hello.mylang > hello.html

# Extract definitions and references with the tags query
tree-sitter tags examples/hello.mylang

Existing grammars and the playground:

# Work on an existing grammar
git clone https://github.com/tree-sitter/tree-sitter-json
cd tree-sitter-json
tree-sitter generate && tree-sitter test

# Write a config file, then list your grammar checkouts under parser-directories
tree-sitter init-config

# Build to WebAssembly and open the interactive playground in a browser
tree-sitter build --wasm
tree-sitter playground

🔧 Tool Integrations

The Tree-sitter CLI sits between a grammar and the tools that load it:

  • Neovim: the main branch of nvim-treesitter compiles parsers with the tree-sitter CLI and asks for a recent release, newer than Debian stable or Ubuntu LTS ship
  • Helix: highlighting, indents and text objects are Tree-sitter queries; check a change to highlights.scm with tree-sitter query before rebuilding grammars with hx --grammar build
  • Zed: language extensions pin a grammar repository and commit, so generate and test the grammar locally before bumping the pin
  • CI: tree-sitter generate followed by git diff --exit-code src/ fails a pull request whose committed parser is stale
  • Package registries: the bindings tree-sitter init writes let one grammar publish to npm, PyPI and crates.io

🚀 Why Choose deb.griffo.io?

📊 Repository Comparison:
  • Official Ubuntu: ships tree-sitter-cli in universe, but 24.04 LTS carries 0.20.8, 26.04 is already behind upstream, and 22.04 has no package at all
  • Upstream binary: current, but upstream's prebuilt Linux binaries are linked against glibc 2.39, so they do not start on Debian 12 or Ubuntu 22.04, and they live outside apt in /usr/local/bin
  • cargo or npm: cargo install tree-sitter-cli needs a Rust toolchain and a full compile on every upgrade, and the npm package downloads the same prebuilt binary with the same glibc requirement
  • deb.griffo.io: latest version with automatic updates

📦 Package Build Repository

The Ubuntu packages are automatically built and maintained in this GitHub repository:

🔗 Related Packages

Also available from deb.griffo.io:

🎯 Perfect for: writing a grammar for a new language, keeping an existing grammar's parser and corpus tests current, testing highlight and injection queries for Neovim, Helix or Zed, CI jobs that check a committed parser is up to date, and Debian 12 or Ubuntu 22.04 machines where upstream's own binary will not start.

💝 Support This Project

If this repository saves you time and effort, please consider supporting it!

⭐ Star on GitHub 🐦 Share on Twitter

Just after the command? See apt install tree-sitter-cli, one page covering Debian and Ubuntu.

📦 Recent releases from this repository

📚 Release-specific install guides

❓ Frequently asked questions

Is tree-sitter-cli in the official Ubuntu repositories?

Yes, but the official Ubuntu archive ships tree-sitter-cli 0.25.9, while this repository serves tree-sitter-cli 0.27.0, rebuilt within hours of each upstream release.

How do I install the latest tree-sitter-cli on Ubuntu?

Add the deb.griffo.io repository once using the instructions above, then run: sudo apt install tree-sitter-cli. New releases arrive through the normal sudo apt upgrade.

Are the packages signed and how are they built?

Every package is signed with the repository's GPG key (EA0F721D231FDD3A0A17B9AC7808B4DD62C41256) and built from upstream releases in public GitHub packaging repositories that anyone can inspect.

Which Ubuntu releases are supported?

Ubuntu 22.04 Jammy, 24.04 Noble, 25.10 Questing and 26.04 Resolute.