skillfed

parsimonious

(Soon to be) the fastest pure-Python PEG parser I could muster

parsimonious v0.11.0 6.9M downloads/30d#1,807 on PyPI1,914
Permissive license MIT AGING released

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 parsimonious

uv

uv add parsimonious

poetry

poetry add parsimonious

Installing 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

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Information AnalysisTopic :: Software Development :: LibrariesTopic :: Text Processing :: General

Tags

peg parser pythonparsing expression grammartext parsing librarygrammar-based parserast tree builderebnf parser pure pythonpackrat parsing
parser-generatorgrammar-basedast-builder

More Libraries packages