PyJSG
Python JSON Schema Grammar interpreter
What it is and what it does
PyJSG is a code generator that reads JSON Schema Grammar (JSG) specifications and produces Python 3 classes representing the schema's structure. It bridges the gap between declarative schema definitions and typed Python objects, using the typing library to provide IDE support and type hints.
The generated classes inherit from JSG base types and include built-in validation, serialization to JSON, and attribute access control. You define a schema in JSG syntax, run the generate_parser command-line tool, and get back a Python module with classes ready to instantiate, populate, validate, and serialize. The package includes a validation library that checks whether Python objects conform to their schema definitions.
Use it for:
- Generate strongly-typed Python models from existing JSON Schema Grammar definitions for data interchange formats.
- Build configuration file parsers that validate structure and types at runtime using generated schema classes.
- Create domain-specific language interpreters where the grammar defines both syntax and Python object structure.
- Validate JSON data against a schema before processing, catching structural errors early in a pipeline.
- Serialize Python objects back to JSON while enforcing schema constraints and type safety.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates Python 3 classes from JSON Schema Grammar (JSG) specifications, enabling type-safe object representations of JSON data with validation and serialization support.
Yes, if you work with JSON Schema Grammar and need type-safe Python bindings. The package is actively maintained, has no known vulnerabilities, installs cleanly, and is permissively licensed. The main consideration is whether your project already uses JSG; if you're starting fresh, evaluate whether JSG's grammar syntax fits your schema needs better than alternatives.
Install
pyjsg on PyPI
pip
pip install pyjsguv
uv add pyjsgpoetry
poetry add pyjsgInstalling PyJSG
Before you install
Low install friction with a pure Python wheel distribution. Maintenance status is active with a recent release. Three runtime dependencies (antlr4-python3-runtime, jsonasobj, requests) are standard libraries in the Python ecosystem.
License in practice
Licensed under CC0 1.0 Universal (public domain dedication), which is permissive and places no restrictions on use, modification, or distribution.
Quickstart
pip install pyjsg
generate_parser input.jsg
from pyjsg.jsglib.jsg import loads
schema_json = '{"type": "Schema"}'
s = loads(schema_json)
print(s._as_json_dumps())
Requires Python 3.10 or later; the package depends on internal features of the typing library which may require testing when upgrading Python versions.
Verify before relying
- Current compatibility with Python 3.13 and 3.14 (listed as supported but package last released 2026-05-01)
- Whether antlr4-python3-runtime introduces any platform-specific compilation requirements
- Real-world validation performance and error message clarity for complex schemas
Package facts
| License | CC0 1.0 Universal (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — antlr4-python3-runtime, jsonasobj, requests |
| Maintenance | actively maintained — 105 days since the last release |
| First released | |
| Downloads | 292,377/month — #7,965 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyjsg-0.12.4-py3-none-any.whl
Keywords: Code Generator, JSG, Javascript, Python, Schema
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
ShExJSGShExJSG provides a Python object model for the…
permissive · top 15,000 on PyPI
PyShexCParses Shape Expression Compact (ShExC) syntax…
permissive · top 15,000 on PyPI
jsonasobjConverts JSON data into Python objects with…
permissive · top 15,000 on PyPI
dataclasses-jsonschemaGenerates JSON Schema from Python dataclasses…
permissive · top 15,000 on PyPI
pyPEG2pyPEG2 is a PEG (Parsing Expression Grammar)…
copyleft · top 15,000 on PyPI
jsonasobj2Converts JSON data into Python objects with…
permissive · top 15,000 on PyPI
marshmallow-jsonschemaConverts marshmallow schemas into JSON Schema…
permissive · top 5,000 on PyPI
PyShExPyShEx parses and validates RDF data against…
permissive · top 15,000 on PyPI
tree-sitter-htmlProvides an HTML grammar for tree-sitter,…
permissive · top 5,000 on PyPI
types-orjsonProvides PEP 561 type stubs for the orjson…
permissive · top 15,000 on PyPI