skillfed

textX

Meta-language for DSL implementation inspired by Xtext

textx v4.4.0 299.7K downloads/30d#7,853 on PyPI852
Permissive license Active released

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 textx

uv

uv add textx

poetry

poetry add textx

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: CompilersTopic :: Software Development :: InterpretersTopic :: Software Development :: Libraries :: Python Modules

Tags

DSL parser generatordomain-specific language frameworkgrammar-based parser pythonmeta-language implementationtextual language parserxtext alternative pythonPEG parser DSL builder
dsl-frameworkparser-generatorlanguage-implementation

More Python Modules packages