textX
Meta-language for DSL implementation inspired by Xtext
What it is and what it does
textX is a Python framework for implementing Domain-Specific Languages by writing a grammar definition. From that grammar, it automatically generates a parser and meta-model (abstract syntax tree) that can parse and instantiate models conforming to your language. It uses a PEG parser (via Arpeggio) with unlimited lookahead and no grammar ambiguities, following the design principles of Xtext but implemented entirely in Python.
You define your DSL syntax as a textX grammar, optionally provide custom Python classes for specific rules, and then use the generated meta-model to parse text into Python object graphs. This is useful when you need to build support for a new textual language, file format, or configuration syntax without writing a parser from scratch.
Use it for:
- Build a custom configuration file format with validation and programmatic access to parsed settings
- Create a domain-specific language for modeling (e.g., state machines, workflows, or diagrams) and interpret or transform the models
- Parse and process existing textual file formats or languages where you want programmatic control over the abstract syntax
- Implement a code generation tool that reads a textual specification and produces output in another language
- Define a query or expression language for a specialized application domain
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
textX is a meta-language for building Domain-Specific Languages (DSLs) in Python by defining a grammar that automatically generates a parser and meta-model for your language.
Yes. textX is actively maintained, has no known vulnerabilities, low install friction, and is well-suited for anyone building a textual DSL in Python. The framework is production-stable (Development Status 5), has been in development since 2014, and is appropriate for research, commercial, and open-source use under the MIT license.
Install
textx on PyPI
pip
pip install textxuv
uv add textxpoetry
poetry add textxInstalling textX
Before you install
Low install friction with only two runtime dependencies (Arpeggio and importlib-metadata). The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it suitable for both open-source and proprietary projects.
Quickstart
from textx import metamodel_from_str
grammar = """Model: items*=Item; Item: 'item' name=ID;"""
mm = metamodel_from_str(grammar)
model = mm.model_from_str("item foo item bar")
Requires Python 3.8 or later; Arpeggio must be installed as a runtime dependency.
Verify before relying
- Whether textX's PEG parser approach handles all grammar patterns needed for your specific DSL use case
- Performance characteristics when parsing large or deeply nested models
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Arpeggio, importlib-metadata |
| Maintenance | actively maintained — 37 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 299,747/month — #7,853 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: textx-4.4.0-py3-none-any.whl
Keywords: parser, meta-language, meta-model, language, DSL
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pyPEG2pyPEG2 is a PEG (Parsing Expression Grammar)…
copyleft · top 15,000 on PyPI
TatSuTatSu compiles extended EBNF grammars into…
permissive · top 5,000 on PyPI
ArpeggioArpeggio is a recursive descent parser with…
permissive · top 5,000 on PyPI
parsimoniousParsimonious is a pure-Python PEG (parsing…
permissive · top 5,000 on PyPI
plyPLY is a lexer and parser generator for Python…
permissive · top 1,000 on PyPI
textparserA fast text parser library that lets you define…
permissive · top 5,000 on PyPI
mo-parsingmo-parsing is a PEG parser generator that lets…
permissive · top 15,000 on PyPI
ParsleyParsley is a PEG-based parsing library that…
permissive · top 5,000 on PyPI
pygmarsPygmars builds lightweight lexers and parsers…
permissive · top 15,000 on PyPI
graphql-queryBuilds GraphQL query strings programmatically…
permissive · top 15,000 on PyPI