parsimonious
(Soon to be) the fastest pure-Python PEG parser I could muster
What it is and what it does
Parsimonious is a parsing library built on parsing expression grammars (PEGs)—a simplified EBNF notation you write as strings to define what text patterns to recognize. You give it a grammar and text, and it returns an abstract syntax tree (AST) representing the structure it found. The library separates parsing from interpretation: once you have a tree, you walk it with a NodeVisitor subclass to extract data or transform it however you need—render to HTML, extract key-value pairs, build an intermediate representation, or anything else.
The package is designed for speed and low memory use in pure Python, with no external parser generator or lexer step required. It handles arbitrary lookahead and right recursion automatically, making grammars simpler to write than with tools like Yacc. The library is mature in core functionality (test coverage is good, error reporting works), though marked as alpha and with a note that API changes are possible before 1.0.
Use it for:
- Parse configuration files (INI, TOML-like formats) and extract structured data into Python dicts or objects
- Build a domain-specific language (DSL) parser for custom query syntax, template languages, or markup formats
- Parse wiki markup or other text formats and transform them to HTML, plain text, or other output formats
- Validate and extract data from semi-structured text (logs, reports, data feeds) according to a grammar you define
- Implement a simple expression evaluator or calculator by parsing arithmetic or logical expressions into an AST
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parsimonious is a pure-Python PEG (parsing expression grammar) parser that builds abstract syntax trees from text according to grammar rules you define, with no external lexer or parser generator required.
Yes, if you need to parse text with a grammar you can define in code and don't want to depend on external tools or compiled parsers. The low install friction, permissive license, and lack of security issues make it a safe choice. The aging maintenance status and alpha classifier mean you should pin the version and be prepared for potential API changes if you upgrade—but the current 0.11.0 is stable for production use if your grammar needs are straightforward.
Install
parsimonious on PyPI
pip
pip install parsimoniousuv
uv add parsimoniouspoetry
poetry add parsimoniousInstalling parsimonious
Before you install
Low friction: pure-Python wheel with a single runtime dependency (regex). Last release 275 days ago; repository active with 1914 stars and recent commits, though marked as aging rather than actively developed.
License in practice
MIT license (permissive): you can use, modify, and distribute Parsimonious in commercial and private projects with minimal restrictions, provided you include the license notice.
Quickstart
from parsimonious.grammar import Grammar
from parsimonious.nodes import NodeVisitor
grammar = Grammar(r"""
expr = ~"[a-z]+"
""")
tree = grammar.parse('hello')
print(tree)
Verify before relying
- Whether performance meets the stated goal of being 'fastest arbitrary-lookahead parser' in practice for real-world grammars
- Current RAM usage characteristics and whether optimization work mentioned in 'Coming Soon' has been completed
- Stability of API before 1.0 release and whether pinning to 0.11.0 is necessary to avoid breakage
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — regex |
| Maintenance | aging — 275 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,931,760/month — #1,807 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: parsimonious-0.11.0-py3-none-any.whl
Keywords: parse, parser, parsing, peg, packrat, grammar, language
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 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
mo-parsingmo-parsing is a PEG parser generator that lets…
permissive · top 15,000 on PyPI
ParsleyParsley is a PEG-based parsing library that…
permissive · top 5,000 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
ArpeggioArpeggio is a recursive descent parser with…
permissive · top 5,000 on PyPI
parsyParsy is a parser combinator library that lets…
permissive · top 5,000 on PyPI
textXtextX is a meta-language for building…
permissive · top 15,000 on PyPI
pygmarsPygmars builds lightweight lexers and parsers…
permissive · top 15,000 on PyPI
TatSuTatSu compiles extended EBNF grammars into…
permissive · top 5,000 on PyPI