The Tree-sitter web playground is an interactive tool that allows you to experiment with Tree-sitter parsers directly in your browser.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tree-sitter/tree-sitter/llms.txt
Use this file to discover all available pages before exploring further.
Online Playground
You can access the online playground at:Tree-sitter Playground
Try Tree-sitter with pre-selected grammars in your browser
Features
The playground provides several powerful features for exploring how Tree-sitter parsers work:Syntax Tree Visualization
The syntax tree updates in real-time as you type in the code editor. As you move around the code, the current node is highlighted in the tree. You can also click any node in the tree to select the corresponding part of the code.Query Testing
You can enter one or more query patterns into the Query panel. If the query is valid, its captures will be highlighted both in the Code and in the Query panels.To see any query results, you must use at least one capture, like
(node_name) @capture-nameSupported Languages
The online playground includes pre-selected grammars for:Bash
C
C++
C#
Go
HTML
Java
JavaScript
PHP
Python
Ruby
Rust
TOML
TypeScript
YAML
Display Options
The playground provides several display options:- Log: Enable logging (visible in the browser’s console)
- Show anonymous nodes: Display anonymous nodes in the syntax tree
- Query: Toggle the query panel
- Accessibility: Enable accessibility features
Local Playground
You can also run the playground locally with your own grammar using the CLI’stree-sitter playground command:
Building Wasm for Offline Use
If you want the local playground to work offline, you need to build the Wasm library first:tree-sitter playground command will require an internet connection.
How It Works
The playground is built with:- CodeMirror: The code editor
- web-tree-sitter: The Wasm-based JavaScript binding
- Pre-compiled Wasm parsers: Available from the tree-sitter.github.io repo
Contributing to the Playground
If you’d like to improve the playground, the source code can be found in the Tree-sitter repository:- JavaScript:
docs/src/assets/js/playground.js - CSS:
docs/src/assets/css/playground.css