--- id: textparser version: "0.26.2" license: MIT license_treatment: permissive maintenance: active --- # textparser — A text parser library for python. License: permissive · Maintenance: active · Downloads: 3.5M/mo ## 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 above — 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 pip install textparser uv add textparser 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_current - Install friction: low - Maintenance: active - Downloads: 3.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags text parsing library, grammar-based parser, fast parser python, tokenizer and parser, structured text parsing, parsing framework, language parser, parser-generator, performance-focused, dsl [View on SkillFed](https://skillfed.io/packages/textparser) · [View on PyPI](https://pypi.org/project/textparser/)