JSON Schema can be used to validate JSON5 documents. JSON for the ES5 era (JSON5) proposes to extend JSON making it easier to write. JSON5 is backwards compatible with existing JSON documents and all JSON5 is valid JavaScript. Since JSON5 maintains the same data types as JSON, JSON Schema remains the choice solution for schema validation.

JSON

[
    {
        "id": 2,
        "name": "An ice sculpture",
        "price": 12.5,
        "tags": [
            "cold",
            "ice"
        ],
        "dimensions": {
            "length": 7,
            "width": 12,
            "height": 9.5
        },
        "warehouseLocation": {
            "latitude": -78.75,
            "longitude": 20.4
        }
    },
    {
        "id": 3,
        "name": "A blue mouse",
        "price": 25.5,
        "dimensions": {
            "length": 3.1,
            "width": 1,
            "height": 1
        },
        "warehouseLocation": {
            "latitude": 54.4,
            "longitude": -32.7
        }
    }
]

JSON5

[
    {
        id: 2,
        name: "An ice sculpture",
        price: 12.5,
        tags: [
            "cold",
            "ice",
        ],
        dimensions: {
            length: 7,
            width: 12,
            height: 9.5,
        },
        warehouseLocation: {
            latitude: -78.75,
            longitude: 20.4,
        }
    },
    {
        id: 3,
        name: "A blue mouse",
        price: 25.5,
        dimensions: {
            length: 3.1,
            width: 1,
            height: 1,
        },
        warehouseLocation: {
            latitude: 54.4,
            longitude: -32.7,
        }
    }
]

Example JSON from the JSON Schema website.

Editor Support

No editors supporting JSON Schema validation of JSON5 documents are known.

Tools and Libraries

  • Polyglottal JSON Schema Validator - Written in JavaScript. Released under the MIT license.
    • Polyglottal JSON Schema Validator (pajv) is a command line utility that can be used to validate data in numerous formats against a JSON Schema.

Alternatives

No other schema definition formats are known to target JSON5.