DevGrill

XML to JSON Schema

Generate a JSON Schema from XML, and see the XML converted to JSON.

Runs in your browser

0 chars
JSON Schema (2020-12)

Output will sizzle here.

0 chars

Describing XML data as JSON

Moving an XML API or feed to JSON, or validating XML that's been converted to JSON, starts with knowing its shape. Paste a sample and get a JSON Schema for its JSON form: which elements and attributes exist, which repeat, which are optional, and whether values are numbers, booleans or text.

It uses the most common way to write XML as JSON: attributes become keys starting with @, an element's text becomes #text when the element also has attributes or children, a plain element becomes its value, and an element that appears more than once becomes an array. Switch to XML as JSON to see your sample converted with exactly these rules.

How to use the XML to JSON Schema

  1. Paste a representative XML sample. Include repeated elements and optional parts, so the schema can learn them.

  2. Read the schema. It updates as you type, and folds like any JSON.

  3. Check the JSON form. XML as JSON shows the data the schema describes.

  4. Use it. Send the schema to the JSON Schema Validator, or the JSON to other tools.

Tips

  • An element is required only if it appears in every one of its parents in your sample. Add more examples to make that more accurate.
  • Every object has additionalProperties: false, so unexpected fields are reported. Loosen it if your data can grow.
  • Need code types instead of a schema? Convert to JSON, then use JSON to Types.

Frequently asked questions

Is this an XSD?

No. An XSD describes the XML itself; this is a JSON Schema for the XML's JSON form. Browsers can't run XSD validation, and DevGrill doesn't upload files to do it on a server.

How are namespaces handled?

Prefixes are kept in the names, so <soap:Body> becomes the key soap:Body.

Why is a value a string when it looks like a number?

If any example of that element isn't a number, the whole field becomes text, so the schema fits all of your data.

Is my XML uploaded?

No. Everything runs in your browser.

Related tools