>_devtools

JSON Schema Formatter

Format and minify JSON Schema with canonical keyword order, so schemas diff cleanly and read top to bottom.

What this does

Formats a JSON Schema with a canonical keyword order, so that identifying keywords come first, then the type, then constraints, then nested structure, and definitions come last. Two schemas that mean the same thing then look the same and produce small, readable diffs. You can also minify a schema or change the indentation.

Keyword order

Inside every schema object, including nested ones, keywords are written in this order:

  1. $schema, $id, $anchor, $ref, $comment
  2. title, description
  3. type, enum, const, default, examples, deprecated, readOnly, writeOnly
  4. format and string constraints (minLength, maxLength, pattern)
  5. number constraints (multipleOf, minimum, exclusiveMinimum, maximum, exclusiveMaximum)
  6. array keywords (prefixItems, items, contains, minItems, maxItems, uniqueItems)
  7. object keywords (properties, patternProperties, additionalProperties, propertyNames, minProperties, maxProperties, required, dependentRequired, dependentSchemas)
  8. composition (allOf, anyOf, oneOf, not, if, then, else)
  9. any other keyword, such as x- extensions, in its original order
  10. $defs, definitions

What is never changed

  • The order of names inside properties, patternProperties, and$defs is kept, because property order is often meaningful to readers. Tick “Sort property names” to order them alphabetically instead.
  • Data values are untouched: enum, const, default, andexamples keep their exact content and key order, and the required list keeps its order.
  • The meaning of the schema does not change: parsing the output gives an object equal to the input. Formatting is idempotent, so formatting twice gives the same result.

Invalid JSON is reported with the line and column of the problem. Input is limited to 1 MB. A schema may be an object or the boolean true or false.

Privacy

The schema is formatted in your browser. Nothing is uploaded or stored.