XML to JSON Schema Generator

Infer a JSON Schema from an XML sample so a legacy feed can be validated once it has been converted to JSON.

XML
JSON Schema
Runs locally in your browser

About the XML to JSON Schema Generator

Teams migrating an XML integration to JSON need a contract for the new format, and the only reliable description of the old one is often a sample message. This tool reads that sample, converts it to the equivalent JSON structure, and writes a schema describing what it found, giving you a starting contract in seconds instead of an afternoon.

Leaf values are typed by inspection. Whole numbers become integer, decimals become number, and strings are additionally checked against a few common patterns so a value like 2026-03-09 gains "format": "date", a timestamp gains date-time, and addresses and email addresses gain uri and email. Those hints cost nothing and are usually correct, and they are easy to delete when they are not.

Arrays are described from the union of every item in the sample rather than from the first one alone, so a list whose second entry carries an extra field still produces a schema that accepts both. Empty elements are typed as a string or null union, since a document cannot say what an empty tag was meant to hold. The required list and the additional properties flag are both switches because a schema written for validating your own output should be strict, while one written for reading a feed you do not control should be forgiving. Compare with JSON to JSON Schema when you already have JSON to hand.

How to use

  1. Paste an XML sample that covers as many optional fields as you can find.
  2. Choose the draft your validator supports, either 2020-12 or draft-07.
  3. Untick List every property as required if the sample shows fields that will not always be present.
  4. Copy the schema or download it as schema.json.

Common questions

Is this the same as converting an XSD?
No. It infers a schema from a sample document. An XSD already states the rules, and translating one needs a dedicated converter.
Why does a date field get a format keyword?
Strings matching the ISO date and timestamp patterns are annotated with date or date-time, which most validators understand.
How are repeated elements described?
As an array whose items schema is built from the union of the keys across every occurrence in the sample.
Which draft should I choose?
Pick 2020-12 for modern validators. Choose draft-07 for older tooling such as some code generators and editor plugins.