skillfed

textparser

A text parser library for python.

textparser v0.26.2 3.5M downloads/30d#2,607 on PyPI34
Permissive license MIT Active released

What it is and what it does

textparser is a Python library for building fast text parsers by defining token specifications and grammar rules. You subclass textparser.Parser, specify how to tokenize input (using regex patterns), and define the grammar structure using combinators like Sequence. The parser then converts text into a parse tree. The library emphasizes speed—benchmarks show it parsing JSON significantly faster than alternatives like pyparsing, lark, and parsy—and takes design cues from PyParsing for a familiar interface.

It has no external runtime dependencies and installs as a pure Python wheel, making it lightweight and easy to integrate. The project is actively maintained and supports modern Python versions (3.10+). It's useful when you need to parse domain-specific languages, configuration files, or structured text formats where performance matters and you want direct control over tokenization and grammar rules.

Use it for:

  • Parse custom configuration or data file formats where you control both the syntax and the grammar rules.
  • Build domain-specific language (DSL) parsers for internal tools or scripting systems.
  • Extract structured data from text when regex alone is insufficient but you need faster parsing than general-purpose parser generators.
  • Implement protocol or message parsers where performance and predictable behavior are important.
  • Create educational or embedded parsers where you want minimal dependencies and direct control over the parsing process.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A fast text parser library that lets you define grammars using token specs and parsing rules, then parse text into structured parse trees.

Yes, if you need to parse structured text and performance matters. The library is actively maintained, has no dependencies, requires only Python 3.10+, and benchmarks show it substantially faster than comparable alternatives. MIT license is permissive. Install it if you're building a parser and speed is a priority; skip it if you need error recovery, detailed diagnostics, or support for older Python versions.

Install

textparser on PyPI

pip

pip install textparser

uv

uv add textparser

poetry

poetry add textparser

Installing textparser

Before you install

Low friction—pure Python wheel with no runtime dependencies and active maintenance (last release 55 days ago). Requires Python 3.10 or later.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.

Quickstart

pip install textparser

import textparser
from textparser import Sequence

class MyParser(textparser.Parser):
    def token_specs(self):
        return [('WORD', r'\w+'), ('SKIP', r'[ \t]+')]
    def grammar(self):
        return Sequence('WORD', 'WORD')

tree = MyParser().parse('hello world')

Requires Python 3.10 or later.

Verify before relying

  • Whether the parser handles recursive grammars or has depth/complexity limits.
  • Error recovery and reporting capabilities beyond the basic parse tree output.
  • Memory footprint for large input files or deeply nested grammars.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 55 days since the last release
Last repo commit
First released
Downloads 3,477,089/month — #2,607 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: textparser-0.26.2-py3-none-any.whl

Keywords: parser, parsing

Tags

text parsing librarygrammar-based parserfast parser pythontokenizer and parserstructured text parsingparsing frameworklanguage parser
parser-generatorperformance-focuseddsl

More Text Processing packages