tree-sitter
Incremental parser generator and parsing library for building concrete syntax trees of source code.
Liked for syntax highlighting and queries in editors like Emacs and Neovim,123 for quickly building grammars and error-tolerant parsers for custom languages,456 and as the parsing layer for AST-based code analysis and agent tools.789 Complaints are scattered rather than shared: indentation-based languages are hard to support, some languages lack packaged parsers,1011 and structural editing has disappointed in most editors.12
Why people recommend it
Code analysis tooling · 3
Used to parse codebases into ASTs for indexing, querying, semantic diffs and agent tools.
“building a small pipeline that reads the old code base, parses it file by file using tree sitter”
“extracts entities from 30+ languages via tree-sitter”
Show 1 more
“parses the repo code and docs with treesitter”
Grammar authoring · 3
Building grammars and parsers is described as fun and faster than hand-rolling a parser.
“If you haven't tried building a grammar with tree-sitter, I highly recommend you do so.”
“the overall DevEx is much quicker that hand-rolling the parser”
Show 1 more
“Actually with tree-sitter it's much less moving parts inside parser-generator core”
Editor highlighting · 3
Commenters prefer its syntax highlighting over classic approaches, especially in Emacs and Neovim.
“I think treesitter runs circles around what classic vim is using to highlight syntax.”
“I love how easy it is to write Tree Sitter queries for very special patterns”
Show 1 more
“Emacs now with tree-sitter, LSPs, native-compilation, magit”
Easy queries · 2
Queries for special highlighting or formatting patterns are easy to write.
“I love how easy it is to write Tree Sitter queries for very special patterns”
“tree-sitter is much easier than it looks like”
Reusable grammars · 2
One grammar can serve an editor extension and an LSP written in different languages.
“Kinda nice that the same tree-sitter grammar can be used across the extension and LSP”
“It’s really cool to see tree-sitter unlock so many of these use cases.”
Error tolerance · 1
Creates ERROR or MISSING nodes, making it usable as an error-tolerant compiler frontend.
“I just use it as an error-tolerant frontend to my compiler.”
Caveats and dissent
Indentation languages · 1
Getting it to handle indentation-based languages is described as a pain.
“it's a pain to get tree-sitter to handle it”
Missing parsers · 1
Some languages, such as R, YAML and Go, lacked packaged parsers for one user.
Structural editing · 1
One commenter found it has not delivered Lisp-level structural editing in most editors.
“while I used to have hope for tree-sitter to provide a similar level of structural editing for other languages, at least in most editors I've just not found that to be the case”
Grammar limits · 1
Lack of alternate roots forced one project to maintain a custom C grammar.
“We use the tree-sitter[1] for parsing C declarations in Rizin[2]”
Markdown errors · 1
One user hit constant Markdown errors that disabled highlighting and formatting.
“Whatever AI did to TreeSitter caused it to constantly yell at me about errors because of markdown”
CGO dependency · 1
Using it from Go requires CGO, which complicates Bazel Gazelle extensions.
“Oh this is really neat for the Bazel community”
Often compared with
Who recommends it in their own words
Threads where it came up
- Tree-sitter vs. Language Servers 4 mentions
- I used Fable to rewrite 65kLoC of Go in Rust. It cost $400 2 mentions
- Show HN: I ported Tree-sitter to Go 2 mentions
- Show HN: A universal code formatter using Rust, Tree-sitter, and Rhai 2 mentions
- Local Indexing to reduce tool calling and token usage 1 mention
- On caring for user data: NeoVim caused Vim undo files to be deleted 1 mention
Also written as Tree-sitter. Data: tree-sitter.json. Quotes are verbatim; the verdict and theme labels are written by a model from these comments, and every clause links to its sources.
All comments 32
“parses the repo code and docs with treesitter”
“I think treesitter runs circles around what classic vim is using to highlight syntax.”
“building a small pipeline that reads the old code base, parses it file by file using tree sitter”
“a tree-sitter based Vi/Vim compatible tags generator”
“tree-sitter support is better Rust so it seemed like a good fit.”
“I added tree-sitter, and a bunch of syntaxes highlighters.”
“by using the output of tree-sitter”
“it's a pain to get tree-sitter to handle it”
“Emacs now with tree-sitter, LSPs, native-compilation, magit”
“Whatever AI did to TreeSitter caused it to constantly yell at me about errors because of markdown”
“create an abstract syntax tree over the tree sitter trees for queries that work across language”
“use tree-sitter to statically check code to PRD”
“It uses Tree-Sitter for syntax awareness”
“I also tried to use tree-sitter to enhance the user's prompt parser grammar”
“extracts entities from 30+ languages via tree-sitter”
“tree-sitter is much easier than it looks like”
“Actually with tree-sitter it's much less moving parts inside parser-generator core”
“How does this project compares to something like tree-sitter?”
“I used tree-sitter for coarse AST.”
“Oh this is really neat for the Bazel community”
“I absolutely love the tree-sitter library, I use it in a number of projects.”
“I have been thinking about using tree-sitter for "context extraction / optimization" for code indexing”
“while I used to have hope for tree-sitter to provide a similar level of structural editing for other languages, at least in most editors I've just not found that to be the case”
“I love how easy it is to write Tree Sitter queries for very special patterns”
“Kinda nice that the same tree-sitter grammar can be used across the extension and LSP”
“the overall DevEx is much quicker that hand-rolling the parser”
“I love tree-sitter+eglot”
“eventually, if it works as it is supposed to, I plan to move to tree-sitter queries”
“If you haven't tried building a grammar with tree-sitter, I highly recommend you do so.”
“I just use it as an error-tolerant frontend to my compiler.”
“We use the tree-sitter[1] for parsing C declarations in Rizin[2]”
“It’s really cool to see tree-sitter unlock so many of these use cases.”