Skip to main content

An implementation of JSON data generator from JSON Schema for Python

Project description


jsonfromschema is used to generate JSON data (file .json) from JSON Schema (.json, see Project is written in Python for Python purposes, but it is also stand-alone tool.

SPDX-License-Identifier: 0BSD

Project name: jsonfromschema License: 0BSD / Free Public License 1.0.0 More information about license:


git clone

You can run it from sources without any dependancies* (python and some modules delivered with it)

python ./jsonfromschema


python ./jsonfromschema --help

See CLI section for more details.


pip install jsonfromschema


pip install -e


pip install -e


git clone
cd jsonfromschema
python # or pip install -e .


There are two kind of interfaces: CLI and Python module.


CLI is Command Line Interface. So you have tool called: jsonfromschema

$ jsonfromschema --help
usage: jsonfromschema [-h] [-v] [-w [VALIDATE]] [--no-default] [--no-examples] [--maximum]
         [--subschema SUBSCHEMA] [--from-python-package FROM_PYTHON_PACKAGE]
         schema output

Generate JSON data file (*.json) from JSON Schema

positional arguments:
schema                path to JSON Schema file or python packages resource
output                path to JSON data output file

optional arguments:
-h, --help            show this help message and exit
-v, --verbose         verbose mode
-w [VALIDATE], --validate [VALIDATE]
                        use jsonschema to validate output and check if schema
                        is valid [3,4,6,7 (default)]
--no-default          do not use 'default' fields in jsonschema
--no-examples         do not use 'default' fields in jsonschema
--maximum             generate as complex json as possible (by
                        implementation); for example ignore "required" and
                        favor "object" over less complicated fields
--subschema SUBSCHEMA
                        extract subschema only by this json fragment pointer
--from-python-package FROM_PYTHON_PACKAGE
                        'schema' is path to python package resource, this
                        option needs package name as argument

Some examples:

$ jsonfromschema input_schema.json output_json_data.json


$ jsonfromschema input_schema.json output_json_data.json -v

Validate output: It use “jsonschema” module (pip install jsonschema) to validate output json to be valid with given schema.

$ jsonfromschema input_schema.json output_json_data.json -w

Generate subschema: Use JSON pointer (schema side) to generate only part of schema:

$ jsonfromschema tests/test_schema_main.json.json output.json -w --subschema=/properties/string_default
$ cat output.json

Use JSON Schema resources from some python packages:

$ jsonfromschema ../tests/test_schema_main.json output.json -vw --subschema=/properties/string_default --from-python-package jsonfromschema
$ cat output.json

Python Module

API is not stable right now.

import jsonfromschema.lib
generate_dict_from_text(root_name, schema_text, optional_args=None)
generate_dict_from_file(schema_file, optional_args=None)
generate_dict_from_package(package, path, optional_args=None)
Default values are:
'verbose': False,
'no-default': False,
'no-examples': False,
'maximum': False,
'pkg_resource_root': None,
'subschema': None,
pkg_resource_root is package name, for example “jsonschema”


  1. JsonSchema Draft-7 support (in progress)
  2. Check Draft-4 support
  3. Section about Contributions

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for jsonfromschema, version 0.1.2
Filename, size & hash File type Python version Upload date
jsonfromschema-0.1.2-py2.py3-none-any.whl (9.9 kB) View hashes Wheel py2.py3
jsonfromschema-0.1.2.tar.gz (11.5 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page