abnf
Parsers for ABNF grammars.
What it is and what it does
abnf is a parser generator that turns ABNF grammar specifications into working parsers. It implements RFC 5234 and RFC 7405, the standards for ABNF syntax itself, and ships with ready-to-use grammar modules for 30+ common RFCs covering HTTP headers, email addresses, URIs, and similar structured text formats. The package has been in production use since its original deployment for HTTP header parsing in a web framework.
You use it by either loading one of the bundled RFC grammar modules and calling parse or parse_all on input strings, or by compiling your own ABNF rule inline using Rule.create(). The library works with code points (strings), not raw bytes; to parse wire data, you decode it with latin-1 first to preserve the byte-to-code-point mapping. An optional Rust backend is available for substantially faster parsing when needed.
Use it for:
- Parse and validate HTTP headers (ETag, Content-Type, etc.) using the bundled RFC 7232, RFC 7230 grammars.
- Validate email addresses and other RFC 5322 message format data against standard ABNF rules.
- Extract structured data from URIs, hostnames, or other RFC-defined formats using built-in grammar modules.
- Compile and parse custom ABNF grammars for proprietary or domain-specific text formats.
- Validate wire protocol data by decoding bytes as latin-1 and parsing against RFC-based ABNF rules.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates parsers from ABNF grammars as specified in RFC 5234 and RFC 7405, with 30+ built-in grammar modules for common RFCs like HTTP headers, email addresses, and URIs.
Yes. The package is actively maintained, has no known vulnerabilities, zero runtime dependencies, and low install friction. It solves a real problem—parsing RFC-defined text formats—with production-proven code and comprehensive built-in grammar coverage. The MIT license is permissive. Install it if you need to parse or validate structured text defined by RFCs or custom ABNF grammars.
Install
abnf on PyPI
pip
pip install abnfuv
uv add abnfpoetry
poetry add abnfInstalling abnf
Before you install
Minimal friction: pure Python wheel, no runtime dependencies, tested on Python 3.10–3.14. Active maintenance with a release 2 days ago; last commit 2026-08-14.
License in practice
MIT license (permissive); you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install abnf
from abnf.grammars import rfc7232
node, offset = rfc7232.Rule("ETag").parse('W/"moof"', 0)
print(node.value) # 'W/"moof"'
Requires Python 3.10 or later. To parse wire data (bytes), decode with latin-1 first before passing to parse methods.
Verify before relying
- Performance characteristics of the optional Rust backend relative to the pure Python implementation.
- Whether the 30+ bundled grammar modules cover all common RFC use cases or if custom grammar compilation is often needed.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,082,161/month — #4,394 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: abnf-2.7.0-py3-none-any.whl
Keywords: abnf, generator, parser
Tags
More Code Generators packages
Proto Plus wraps protocol buffers to provide…
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
beartypeBeartype is a runtime type checker that…
permissive · top 1,000 on PyPI
llvmlitellvmlite provides a lightweight Python binding…
permissive · top 1,000 on PyPI
astorastor converts Python abstract syntax trees…
permissive · top 5,000 on PyPI
rfc3987-syntaxValidates that strings conform to the ABNF…
permissive · top 1,000 on PyPI
TatSuTatSu compiles extended EBNF grammars into…
permissive · top 5,000 on PyPI
pyangpyang validates YANG data models (RFC 7950),…
permissive · top 15,000 on PyPI
tree-sitter-typescriptProvides TypeScript and TSX language grammars…
permissive · top 5,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
textparserA fast text parser library that lets you define…
permissive · top 5,000 on PyPI
pygmarsPygmars builds lightweight lexers and parsers…
permissive · top 15,000 on PyPI
xgrammarConstrains LLM text generation to follow…
permissive · top 5,000 on PyPI
lark-parserLark is a parsing library that builds abstract…
permissive · top 5,000 on PyPI
lark-jsLark-js is a command-line tool that generates…
permissive · top 15,000 on PyPI