Skip to main content

Introduction

Parsers generated with Tree-sitter have an associated ABI (Application Binary Interface) version, which establishes hard compatibility boundaries between the generated parser and the Tree-sitter library. A given version of the Tree-sitter library is only able to load parsers generated with supported ABI versions.

Current ABI Version

The latest ABI version is defined in the Tree-sitter API:

Latest ABI

Version 15 - The latest ABI version supported by the current library

Minimum ABI

Version 13 - The earliest ABI version that can still be loaded

Compatibility Matrix

The following table shows which ABI versions are supported by which Tree-sitter library versions:
The Tree-sitter library is generally backwards-compatible with languages generated using older CLI versions, but is not forwards-compatible. You cannot use a parser with a newer ABI version than the library supports.

Checking Compatibility

When setting a language on a parser, Tree-sitter automatically checks ABI compatibility:

Generating Parsers with Specific ABI Versions

By default, the Tree-sitter CLI will generate parsers using the latest available ABI for that version. However, you can select an older ABI using the --abi option:
The ABI version range supported by the CLI can be smaller than for the library. When a new ABI version is released, older versions will be phased out over a deprecation period. During this period, you can still load parsers with the old ABI, but you can no longer generate parsers with it.

When to Regenerate Parsers

You should regenerate your parser when:
1

Upgrading Tree-sitter

When you upgrade to a major or minor version of Tree-sitter that introduces a new ABI version, regenerate your parsers to take advantage of new features and optimizations.
2

Supporting older libraries

If you need your parser to work with older versions of the Tree-sitter library, generate it with an older ABI version using --abi.
3

ABI compatibility errors

If users report ABI version mismatch errors, you may need to regenerate your parser with a compatible ABI version.

ABI Version Changes

ABI versions may change when Tree-sitter introduces:
  • New language features in the grammar DSL
  • Changes to the generated parser structure
  • New runtime capabilities
  • Performance improvements requiring structural changes
Some notable ABI version changes:
  • ABI 13 (Tree-sitter 0.19): Major rewrite of the runtime for improved performance
  • ABI 14 (Tree-sitter 0.20.3): Added support for language metadata
  • ABI 15 (Tree-sitter 0.25): Enhanced query capabilities and optimizations

Best Practices

Keep Libraries Updated

Regularly update your Tree-sitter library to get the latest features and bug fixes.

Document Requirements

Clearly document which Tree-sitter version your parser requires.

Test Compatibility

Test your parser with the minimum supported Tree-sitter version.

Automate Regeneration

Use CI/CD to automatically regenerate parsers when Tree-sitter is updated.

Package.json Example

If you’re publishing a parser as an npm package, specify the Tree-sitter version requirement:
package.json

Cargo.toml Example

For Rust projects, specify the version in Cargo.toml:
Cargo.toml

Troubleshooting

This means your parser was generated with an ABI version older than the minimum supported by the current Tree-sitter library.Solution: Regenerate your parser with the Tree-sitter CLI:
This means your parser was generated with an ABI version newer than what the current Tree-sitter library supports.Solution: Either:
  1. Update your Tree-sitter library to a newer version
  2. Regenerate the parser with an older ABI version:
Users may have an older version of Tree-sitter installed.Solution:
  1. Check what Tree-sitter version your users have
  2. Either ask users to upgrade, or regenerate with a compatible ABI:
  1. Document the minimum required Tree-sitter version
You can check the ABI version programmatically or by looking at the generated parser.c file:

Version Detection Script

Here’s a script to check ABI compatibility:
check_abi.py

Further Reading

Creating Parsers

Learn how to create your own Tree-sitter parser

CLI Documentation

Read about the tree-sitter generate command

Contributing

Contribute to Tree-sitter development
For the most up-to-date information about ABI versions, always check the official Tree-sitter repository and release notes.