tree-sitter-language-pack¶
Universal code parser for 170+ languages — parse, analyze, and intelligently chunk source code across every major programming language.
Why tree-sitter-language-pack?¶
-
170+ Languages
Parse Python, JavaScript, Rust, Go, Java, C, TypeScript, Ruby, and 165+ more with a single unified API. One dependency, every language.
-
Download on Demand
Parsers are downloaded and cached automatically on first use. No bloated installs — only fetch what you need.
-
Code Intelligence
Extract functions, classes, imports, exports, comments, docstrings, and symbols — not just raw syntax trees.
-
Syntax-Aware Chunking
Split code at natural boundaries for LLMs. Never break a function in half or separate a decorator from its definition.
-
Available Everywhere
Python, Node.js, Rust, Go, Java, C#, Ruby, Elixir, PHP, WebAssembly, CLI — same API, all platforms.
-
Native Performance
Rust core with zero-copy parsing. Tree-sitter is battle-tested in editors like Neovim and Helix for a reason.
Quick Example¶
import tree_sitter_language_pack as tslp
# Parsers download automatically on first use
result = tslp.process(
"def hello():\n print('world')\n",
tslp.ProcessConfig(language="python", structure=True, imports=True),
)
print(f"Language: {result['language']}")
print(f"Functions: {len(result['structure'])}")
const { process } = require("@kreuzberg/tree-sitter-language-pack");
const result = process(
"function hello() { console.log('world'); }",
{ language: "javascript", structure: true, imports: true },
);
console.log(`Language: ${result.language}`);
console.log(`Functions: ${result.structure.length}`);
use tree_sitter_language_pack::{ProcessConfig, process};
fn main() -> anyhow::Result<()> {
let config = ProcessConfig::new("rust").all();
let result = process("fn main() { println!(\"hello\"); }", &config)?;
println!("Language: {}", result.language);
println!("Functions: {}", result.structure.len());
Ok(())
}
package main
import (
"fmt"
tslp "github.com/kreuzberg-dev/tree-sitter-language-pack/packages/go/v1"
)
func main() {
registry, _ := tslp.NewRegistry()
defer registry.Free()
tree, _ := registry.ParseString("go", "package main\nfunc hello() {}")
defer tree.Free()
fmt.Println("Root:", tree.RootNodeType())
}
import io.github.treesitter.languagepack.TsPackRegistry;
class Main {
public static void main(String[] args) {
TsPackRegistry.init("{\"languages\": [\"java\"]}");
var tree = TsPackRegistry.parseString("java", "class Foo { void bar() {} }");
System.out.println("Root: " + tree.rootNodeType());
}
}
Install¶
Supported Ecosystems¶
| Ecosystem | Package | Minimum Version |
|---|---|---|
| Python | tree-sitter-language-pack | 3.10+ |
| Node.js | @kreuzberg/tree-sitter-language-pack | 18+ |
| Rust | ts-pack-core | 1.75+ |
| Go | packages/go/v1 | 1.26+ |
| Java | dev.kreuzberg:tree-sitter-language-pack | 21+ |
| C# / .NET | TreeSitterLanguagePack | .NET 10+ |
| Ruby | tree_sitter_language_pack | 3.4+ |
| :material-language-elixir: Elixir | tree_sitter_language_pack | 1.14+ / OTP 25+ |
| PHP | kreuzberg/tree-sitter-language-pack | 8.2+ |
| WebAssembly | @kreuzberg/tree-sitter-language-pack-wasm | Browser / Deno |
| CLI | ts-pack | — |