YAML to JSONSchema Converter

Turn a sample YAML file into a JSON Schema that validates the next one against the same shape.

YAML
JSON Schema
Runs locally in your browser

About the YAML to JSONSchema Converter

A Helm values file, a CI pipeline or an application config is easy to break with a typo that no tool catches until deployment. A JSON Schema fixes that: editors offer completion from it, and a validation step in the pipeline rejects a bad file before it ships. Writing one by hand from scratch is the tedious part, so this generator infers a first version from a YAML file that already works.

Inference looks at every value. Scalars become string, integer, number or boolean, mappings become objects with their properties described, and sequences become arrays whose items schema merges every element rather than trusting the first. A key that appears in some list entries but not others is left out of required, which is usually the correct reading of an optional field.

String formats are detected by pattern, so a timestamp gains "format": "date-time", an address gains email, and a link gains uri. Multi document YAML is handled too: every document is treated as another sample of the same shape, which produces a much better schema than a single example alone. Choose the 2020-12 draft for modern validators or draft-07 for older tooling.

Read the result as a starting point, then add descriptions, ranges and enums by hand. Check your source file first with the YAML Validator, or generate a schema from JSON instead with JSON to JSON Schema.

How to use

  1. Paste the YAML file, or press Sample to load a deployment values file.
  2. Pick the draft your validator expects and give the schema a title.
  3. Tick Forbid extra properties for a strict schema that rejects unknown keys.
  4. Copy the schema or download schema.json, then add descriptions and ranges by hand.

Common questions

How are required keys chosen?
A key is required when every sample of that object carries it. Keys missing from some list entries are treated as optional.
Does it read a multi document YAML file?
Yes. Documents separated by --- are treated as repeated samples of the same shape, which sharpens the inferred types and the required list.
Which string formats are detected?
Date, time, date-time, email, uri, uuid and ipv4, and only when every observed value matches the pattern.
Is the generated schema ready to publish?
It is a solid draft. Add human readable descriptions, numeric ranges and enum lists, because no sample can imply those.