Skip to content

tree-sitter

A parser generator and library that builds syntax trees for code and updates them as you edit.

Stars
27.4k
Forks
3k
Licence
MIT
Language
Rust
Last update
4 days ago
Type
Library

What it is

Tree-sitter is a tool that reads source code and builds a syntax tree, which is a structured map of what the code means grammatically. It can update that tree quickly when the file changes, instead of re-reading the whole file. The README describes it as aimed at being fast enough to run on every keystroke in an editor and robust when code contains syntax errors.

  • Build a syntax-highlighting feature for a code editor that updates as the user types
  • Embed the C runtime library in an application to produce concrete syntax trees for source files
  • Use the Rust or Wasm bindings to parse code inside a Rust program or a web page
  • Use the command-line interface to work with grammars and parsers

Great for

  • Developers building code editors or IDE features that need to understand source code as it changes
  • Tool authors who want syntax-aware highlighting, navigation, or analysis for a programming language
  • Teams embedding a small, dependency-free parsing runtime in their own applications
  • Developers who need to parse a language in Rust, C, or the web (WebAssembly) via the listed bindings

Not ideal for

  • People who just want to use an editor; tree-sitter is a building block for tool makers, not an end-user app
  • Anyone needing a ready-made linter or formatter, since the README does not describe those features
  • Projects that need a parser for a language someone has not already written a grammar for, unless they are prepared to write one
Step-by-step guide: how to use tree-sitterInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    Clone the repository

    git clone https://github.com/tree-sitter/tree-sitter
  2. 2

    Run it

    • Read the documentation at https://tree-sitter.github.io to choose a binding (Rust, Wasm, or CLI)
    • Install the binding for your language or the command-line interface following its README
    • Parse a sample source file using the binding's examples
    • Adjust your integration once you have a working syntax tree
  3. 3

    Get the most out of it

    • Use the Rust binding (lib/binding_rust) if you are working in Rust
    • Use the Wasm binding (lib/binding_web) to run parsing in the browser
    • Use the command-line interface (crates/cli) to test grammars from the terminal
    • Check the Discord or Matrix chat linked in the README for community help

Downloads

Strengths

  • Designed for incremental updates, so the syntax tree can be refreshed quickly after edits
  • Runtime library is written in pure C with no dependencies, making it easy to embed
  • Produces useful results even when the source file contains syntax errors

Trade-offs

  • It is a developer library and toolkit, so it requires programming work before it does anything useful for an end user
  • The README is truncated and does not detail supported languages or limits, so readers should check the documentation
  • Building a grammar for a new language is a specialized task not described in depth here

How it compares

ProjectStarsTypeLevelUpdatedBest for
tree-sitter (this)27.4kLibraryadvanced4 days agoDevelopers building code editors or IDE features that need to understand source code as it changes
code-review-graph32.6kDev toolbeginner8 days agoDevelopers who use an MCP-compatible AI coding assistant on a large repository
parsedown15kLibrarybeginner9 months agoPHP developers who need to render Markdown inside a PHP web application
MudBlazor10.7kLibraryintermediate4 days ago.NET developers building web apps with Blazor
cheerio30.5kLibrarybeginner4 days agoJavaScript developers who already know jQuery-style selectors
pydantic29.3kLibrarybeginner4 days agoPython developers who already use type hints and want runtime checks on incoming data

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.