XML to JSON Schema Converter
Paste an XML sample or an XSD, get a draft-07 JSON Schema
Input XML
JSON Schema Output
What is XML to JSON Schema Converter?
This tool turns an XML document, or an XML Schema (XSD), into a JSON Schema draft-07 document. The schema describes the JSON shape our XML to JSON converter produces: attributes as @name properties, an element's own text as #text, repeated elements as arrays. That makes it handy when an XML feed is being turned into JSON and you want to validate the result, as described at json-schema.org.
For a plain XML sample, the schema is inferred from every instance of each element: a property is required only if it appears in all of them, and types come from the values (whole numbers are integer, decimals number, true/false boolean; values with a leading zero stay string). For an XSD it reads global and inline xs:element, xs:complexType and xs:simpleType declarations, sequences, choices, attributes, simple content, minOccurs/maxOccurs, enumerations and the common facets. Everything runs in your browser with the native DOMParser; nothing is uploaded.
How to Convert XML to JSON Schema
Follow these steps to generate a JSON Schema from your XML.
Paste or Upload XML
Paste your XML or XSD into the Input XML panel, or click Upload to load a file. The tool detects an XSD by its xs:schema root. Sample loads two orders so you can see how optional fields and arrays are handled.
View Generated Schema
The JSON Schema Output panel updates as you type. In the sample, giftWrap shows up as an optional boolean because only one item has it, and zip stays a string because 02134 starts with a zero.
Download or Copy
Click Download to save the schema as a .json file, or Copy to copy it to your clipboard.
When You'd Actually Use This
API Documentation
Convert your XML data structures to JSON Schema to document your REST API request and response bodies using tools like OpenAPI / Swagger.
Data Validation Setup
Generate a JSON Schema from sample XML to use as a validation baseline for JSON data that mirrors your XML structure.
Schema Migration
Moving from SOAP and XSD to JSON APIs? Paste the XSD to get a starting JSON Schema, with named complex types under definitions and enumerations kept as enum.
Code Generation
Use the generated JSON Schema as input to code generators that produce TypeScript interfaces, Java classes, or other language models.
Frequently Asked Questions
Is the XML sent to a server?
No. Everything happens in your browser; your XML never leaves your device.
Which JSON Schema draft does it generate?
Draft-07, which almost every validator supports, Ajv included. See the draft-07 meta-schema.
What does it do with XML attributes?
Each attribute becomes an @name property with a type inferred from its values (or from its declared type in an XSD), and is required when every instance has it or the XSD says use="required".
How does it detect arrays?
From a sample, an element becomes an array when it repeats inside at least one parent. From an XSD, when maxOccurs is greater than 1 or unbounded; minOccurs and maxOccurs become minItems and maxItems.
What parts of XSD are supported?
Global and inline complex and simple types, xs:sequence, xs:all, xs:choice (choice branches are optional), element refs, attributes, simple content with attributes, complex content extension (as allOf), enumerations, patterns, length and range facets, and documentation annotations. Imports, includes, substitution groups and identity constraints are not processed. If you need the exact rules behind any of those constructs, they are defined in XML Schema Part 1: Structures.
Will the schema be exactly right?
From an XSD it is close; from a sample it is only as good as the sample. A field that happens to be present in every record of your sample is marked required, so review the required lists before you rely on them.
Related Tools
Explore other XML and schema tools: