skillfed

abnf

Parsers for ABNF grammars.

abnf v2.7.0 1.1M downloads/30d#4,394 on PyPI53
Permissive license Active released

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 abnf

uv

uv add abnf

poetry

poetry add abnf

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Code GeneratorsTopic :: Software Development :: Interpreters

Tags

ABNF parser generatorRFC grammar parserHTTP header parsingemail address validationURI parsing libraryABNF rule compilerRFC 5234 parser
parser-generatorrfc-compliancegrammar-engine

More Code Generators packages