TheDocumentation 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.
parse command parses source files using a Tree-sitter parser. You can pass any number of file paths and glob patterns, or read from stdin if no paths are provided.
p
The command will exit with a non-zero status code if any parse errors occurred.
Input Sources
File Paths
Pass file paths or glob patterns directly:Paths File
Use--paths to provide a file containing paths:
Standard Input
If no paths are provided, input is read from stdin:Output Formats
Default (S-Expression)
By default, outputs the parse tree as an S-expression:CST Format
Pretty-printed concrete syntax tree:XML Format
Graphviz Dot
JSON Summary
Options
Input Options
The path to a file that contains paths to source files to parse.
The path to the directory containing the grammar. Implies
--rebuild.The path to the parser’s dynamic library. Used instead of the cached or automatically generated library.
If
--lib-path is used, the name of the language used to extract the library’s language function.The language scope to use for parsing. Useful when the language is ambiguous.
Set the encoding of the input file. One of
utf8, utf16-le, utf16-be.By default, the CLI looks for a BOM to determine if the file is UTF-16BE or UTF-16LE. If no BOM is present, UTF-8 is assumed.Parse a specific test in the corpus. The test number matches the output of
tree-sitter test.Output Options
Output the parse tree with graphviz dot.
Output the parse tree in XML format.
Output the parse tree in a pretty-printed CST format.
Output parsing results in a JSON format.
Suppress main output.
Omit the node’s ranges from the default parse output. Useful when copying S-Expressions to a test file.
Debug Options
Output parsing and lexing logs to stderr. Can optionally specify a debug type.
Output logs of the graphs of the stack and parse trees during parsing. Graphs are constructed with graphviz dot, and output is written to
log.html.When using
--debug-graph, open the log file in the default browser.Compile the parser with debug flags enabled. Useful when debugging with
gdb or lldb.Performance Options
Show parsing statistics.
Print the time taken to parse the file. If edits are provided, also prints time after each edit.
Set the timeout for parsing a single file, in microseconds.
Edit Options
Apply edits after parsing the file. Edits are in the format:
row,col|position delcount insert_text where row, col, and position are 0-indexed.Can be supplied multiple times.Build Options
Compile and run the parser as a Wasm module (only if the CLI was built with
--features=wasm).Force a rebuild of the parser before parsing.
The path to an alternative configuration (
config.json) file. See init-config.