jsonschema2md

1.7.0 · active · verified Mon Apr 13

jsonschema2md is a Python library designed to convert JSON Schema definitions into human-readable Markdown documentation. It is actively maintained, with frequent updates that introduce new features and improvements, currently at version 1.7.0. It simplifies the process of generating clear and structured documentation directly from your JSON Schema files.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the Parser with basic options, load a JSON Schema, and convert it into Markdown string output. The resulting Markdown can then be written to a file or displayed.

import json
import jsonschema2md

# Example JSON Schema
schema = {
    "$id": "https://example.com/person.schema.json",
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Person",
    "description": "JSON Schema for a person object.",
    "type": "object",
    "properties": {
        "firstName": {
            "type": "string",
            "description": "The person's first name."
        },
        "lastName": {
            "type": "string",
            "description": "The person's last name."
        }
    }
}

# Initialize the parser with desired options
parser = jsonschema2md.Parser(
    examples_as_yaml=False,
    show_examples="all",
    # Add other options as needed, e.g., show_deprecated=False
)

# Parse the schema and get markdown lines
md_lines = parser.parse_schema(schema)

# Join and print the markdown output
print(''.join(md_lines))

view raw JSON →