Xml To Json Schema Generator
Infer JSON Schema from XML structure in the browser
What is XML to JSON Schema?
This tool parses your XML in the browser, turns the resulting tree into plain JSON-shaped data, and builds a JSON Schema (draft-07) that describes that shape. Use it to bootstrap API contracts, validators, or documentation from sample XML payloads.
How it works
Parsing uses fast-xml-parser with attributes preserved under keys that start with
@_ and text nodes under #text when present. The schema generator walks that object:
objects become type: object with properties, arrays use the first element as a hint
for items, and leaf values map to string, number, integer,
or boolean.
How to use
- Paste XML or load a sample file.
- Optional: set a friendly Schema title for the root document.
- Copy or download the generated JSON Schema.
You can also generate schemas from JSON or YAML using the JSON to JSON Schema Generator or YAML to JSON Schema Generator.
Frequently Asked Questions
Is the schema guaranteed to validate every possible XML document for my service?
No. It reflects the structure of the XML you pasted. Different samples or optional nodes may need you to merge or relax the schema manually.
Why do I see keys like @_id in the schema?
Those come from XML attributes in the parser configuration. They keep attribute names distinct from child elements.
Can I use this output with Ajv or other validators?
Yes, for draft-07 compatible validators. You may need to tweak required arrays or add
additionalProperties rules for production strictness.
What if parsing fails?
Fix malformed XML (unclosed tags, bad entities). The tool surfaces the parser error message in the output panel.