TatSu
TatSu takes a grammar in a variation of EBNF as input, and outputs a memoizing PEG/Packrat parser in Python.
What it is and what it does
TatSu is a PEG (Parsing Expression Grammar) parser generator that takes grammars written in extended EBNF and produces Python parsers capable of building abstract syntax trees (ASTs). It uses memoization (Packrat parsing) to ensure linear-time parsing and supports left-recursive rules—a feature uncommon in traditional PEG tools. The package can be used as a library to compile grammars at runtime and parse input on the fly, or to generate standalone Python modules that implement the parser.
The tool solves the problem of parsing hierarchical, context-dependent data—tasks where regular expressions fail. It handles recursive structures (like nested conditionals or folder hierarchies), format translation with meaning preservation, and the creation of domain-specific languages. TatSu has no runtime dependencies, installs cleanly, and is actively maintained for modern Python versions (3.12 and 3.13).
Use it for:
- Build a custom configuration file parser for domain-specific settings without writing hand-coded recursive descent logic.
- Generate an AST from mathematical expressions or query languages to enable semantic analysis and transformation.
- Create a domain-specific language (DSL) for hardware description, music notation, or business rules with proper operator precedence.
- Translate between structured formats (e.g., one markup language to another) while preserving hierarchical meaning.
- Parse nested or recursive data structures like JSON variants, nested templates, or multi-level configuration formats.
- Validate and extract meaning from complex command syntax where simple regex matching is insufficient.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
TatSu compiles extended EBNF grammars into memoizing PEG parsers in Python, or generates Python source code that implements those parsers.
Yes. TatSu is a mature, actively maintained parser generator with zero dependencies, permissive licensing, and broad Python version support. Install it if you need to parse hierarchical data, build a DSL, or generate parsers from grammars. The low friction and active development make it a reliable choice for grammar-based parsing tasks.
Install
tatsu on PyPI
pip
pip install tatsuuv
uv add tatsupoetry
poetry add tatsuInstalling TatSu
Before you install
Low install friction with no runtime dependencies. Active maintenance with recent releases; last commit 2026-07-10 and version 5.24.0 released 2026-07-09. Requires Python >=3.12 but tests run on Python 3.12 and 3.13.
License in practice
BSD-4-Clause permissive license permits commercial and private use with attribution and disclaimer requirements. No copyleft restrictions; you may use generated parsers in proprietary projects.
Quickstart
pip install TatSu
from tatsu import parse
grammar = '''
start: expression $
expression: expression '+' term | term
term: /\d+/
'''
ast = parse(grammar, '3 + 5')
Requires Python >=3.12; earlier versions should use TatSu-LTS fork.
Verify before relying
- Whether the generated parsers handle all real-world grammar complexity without manual post-processing.
- Performance characteristics of generated parsers on large or deeply nested inputs.
- Whether left-recursive rule support covers all practical use cases or has known limitations.
Package facts
| License | SPDX-License-Identifier: BSD-4-Clause TATSU - A PEG/Packrat parser generator for Python Copyright (c) 2017-2026 Juancarlo Añez (apalala@gmail.com) All rights reserved. Redistribution and use in… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 36 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 921,479/month — #4,718 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tatsu-5.24.0-py3-none-any.whl
Keywords: EBNF, PEG, grammar, packrat, parser
Tags
More Compilers packages
pyparsing provides a library for building text…
permissive · top 1,000 on PyPI
CythonCython is a source code translator that…
permissive · top 1,000 on PyPI
asttokensAnnotates Python abstract syntax trees with the…
permissive · top 1,000 on PyPI
numbaNumba is a just-in-time compiler that…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
llvmlitellvmlite provides a lightweight Python binding…
permissive · top 1,000 on PyPI
ArpeggioArpeggio is a recursive descent parser with…
permissive · top 5,000 on PyPI
PyMeta3PyMeta3 compiles pattern-matching grammars…
permissive · top 15,000 on PyPI
pyPEG2pyPEG2 is a PEG (Parsing Expression Grammar)…
copyleft · top 15,000 on PyPI
abnfGenerates parsers from ABNF grammars as…
permissive · top 5,000 on PyPI
textXtextX is a meta-language for building…
permissive · top 15,000 on PyPI
ParsleyParsley is a PEG-based parsing library that…
permissive · top 5,000 on PyPI
parsimoniousParsimonious is a pure-Python PEG (parsing…
permissive · top 5,000 on PyPI
tree-sitter-typescriptProvides TypeScript and TSX language grammars…
permissive · top 5,000 on PyPI
tree-sitter-haskellProvides a tree-sitter parser grammar for…
permissive · top 15,000 on PyPI
tree-sitter-language-packProvides pre-compiled tree-sitter parsers for…
permissive · top 5,000 on PyPI