XML to JSON Schema
Paste XML and instantly get an inferred draft-07 JSON Schema describing its structure, types, and required fields.
Example
Input XML:
<note>
<to>Tove</to>
<count>3</count>
</note>
Generated JSON Schema (draft-07):
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Root",
"type": "object",
"properties": {
"note": {
"type": "object",
"properties": {
"to": { "type": "string" },
"count": { "type": "integer" }
},
"required": ["to", "count"]
}
},
"required": ["note"]
}How it works
The tool parses your XML with the browser's DOMParser into a plain value (attributes, text, and repeated elements become arrays), then walks that value to infer types and required keys. The result is emitted as a draft-07 JSON Schema.
Good to know
XML to JSON Schema takes a chunk of XML and produces a draft-07 JSON Schema that describes its shape: the types of each field, nested object structure, arrays, and which keys are required. It is aimed at developers who are migrating data from XML feeds, SOAP responses, or legacy config files into JSON-based systems and want a structural contract they can validate against without writing the schema by hand.
Reach for it when you have a representative XML sample and need a starting point for validation, API documentation, code generation, or a quick sanity check of what fields actually exist. Because the schema is inferred from one example, the most useful workflow is to paste the richest, most complete XML you have so that optional fields and repeated elements are present in the sample.
To read the output: the type of each leaf is guessed from its text content, so "3" becomes integer, "1.5" becomes number, "true"/"false" become boolean, and anything else stays a string. A few conventions are worth knowing when you scan the result:
- Every key present in the sample is listed under
required — the tool cannot tell which fields are truly optional, so treat that list as a draft and prune entries that may be absent in other documents. - Attributes appear as properties prefixed with
@ (e.g. @id), and free text mixed alongside child elements is captured as #text. - Arrays are only detected when a tag repeats within the same parent; the item schema is inferred from the first occurrence, and an empty or single element will not be typed as a list.
The practical caveat is that single-sample inference is structural, not semantic: a date or an ID written as digits will be typed as an integer, and a section that happens to appear once will look mandatory. Use the generated schema as scaffolding, then loosen required, fix any misread types, and add constraints (formats, enums, ranges) yourself. Everything runs locally in your browser via the built-in DOMParser, so even proprietary XML can be converted without it leaving your device.
Frequently asked questions
How are repeated XML elements handled?
When a parent contains multiple child elements with the same tag name, they are treated as an array, and the schema uses an "items" definition inferred from the first occurrence.
Are XML attributes included in the schema?
Yes. Each attribute becomes a property prefixed with "@" (for example @id), and element text that sits alongside child nodes is captured under a "#text" property.
Is my data uploaded anywhere?
No — this tool runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.
People also ask
What JSON Schema draft version does this tool output?
It generates JSON Schema draft-07, indicated by the $schema value http://json-schema.org/draft-07/schema#. You can usually upgrade the output to a newer draft like 2020-12 with minor changes, since the basic type and properties keywords are largely compatible.
How does it decide whether a value is a string, integer, number, or boolean?
It inspects the trimmed text of each element or attribute. Whole numbers become integer, decimals become number, the literal words true and false become boolean, and everything else (including dates and IDs that contain non-digit characters) stays a string.
Can it convert XML to JSON Schema if I only have an XSD or DTD?
No. This tool infers a schema from an actual XML instance document, not from an existing XSD or DTD definition. If you have an XSD, that file already defines the structure and would need a different XSD-to-JSON-Schema converter.
Why does an element appear as a single object instead of an array?
Arrays are detected only when the same tag repeats inside the same parent in your sample. If a list happens to contain just one item in the XML you paste, it is typed as a single object, so include at least two repeated elements to get an array schema.
Does the generated schema validate the namespaces or prefixes in my XML?
Namespace prefixes are kept as part of the tag and attribute names as they appear in the document, but the tool does not produce namespace-aware validation rules. It maps the parsed structure directly to property names without special handling of xmlns declarations.
Why are all my fields marked as required?
The schema is inferred from a single example, so every key that appears in that sample is added to the required list. The tool has no way to know which fields are optional, so you should manually remove any that can be missing in other documents.
Can I use the resulting JSON Schema to validate JSON converted from this XML?
Yes, once the XML is converted to JSON using the same conventions (@ prefixes for attributes, #text for mixed text), the schema can validate it with a standard validator such as Ajv. You may first want to adjust types and the required list to match your real data variations.
Is there a size limit on the XML I can paste?
There is no fixed limit imposed by the tool, but because it parses and processes everything in the browser, very large documents are constrained by your device's memory and browser performance rather than a server cap.
Related tools