skillfed

PyJSG

Python JSON Schema Grammar interpreter

pyjsg v0.12.4 292.4K downloads/30d#7,965 on PyPI
Permissive license CC0 1.0 Universal Active released

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 pyjsg

uv

uv add pyjsg

poetry

poetry add pyjsg

Installing 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

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: CC0 1.0 Universal (CC0 1.0) Public Domain DedicationProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software DevelopmentTopic :: Software Development :: Code Generators

Tags

json schema grammar pythoncode generator json schemajsg python bindingsjson to python classesschema validation pythontyped json objects pythonjsg parser generator
schema-validationcode-generationjson-schema

More Software Development packages