skillfed

TatSu

TatSu takes a grammar in a variation of EBNF as input, and outputs a memoizing PEG/Packrat parser in Python.

tatsu v5.24.0 921.5K downloads/30d#4,718 on PyPI444
Permissive 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) Active released

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 tatsu

uv

uv add tatsu

poetry

poetry add tatsu

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: CompilersTopic :: Text Processing :: General

Tags

PEG parser generatorEBNF grammar compilerpackrat parser pythongrammar to parserDSL parser generatorleft-recursive grammar supportabstract syntax tree builder
parser-generatordsl-toolscompiler-tools

More Compilers packages