XML / XPath / XSD

XSD to JSON Schematrace every mapping and limitation

Paste an XSD or load the example. Select the target draft and review the mapping report before export.

XSD to JSON Schema

XSD input

JSON Schema output

Conversion runs in this browser; schema text is not uploaded.

Conversion options

XML attributes use a fixed @ prefix in the output.

Paste an XSD or load the example.

XSD to JSON Schema helps teams carry an XML contract into a JSON API. A schema is different from an XML document: this page produces validation rules, not a sample JSON payload.

Convert XSD to JSON Schema with a selected global root. The XML Schema to JSON Schema mapping lists each approximation so a migration can be reviewed rather than assumed equivalent.

Why use XSD to JSON Schema here?

Keep the generated contract beside its evidence.

A loss report for every step

XSD to JSON Schema keeps a source path beside each mapped element or attribute. Ordering, namespace and pattern differences are marked as approximations; unsupported constructs stay visible.

An XSD tree branches into a JSON Schema document and a row-by-row mapping report.

Select the actual global root

One XSD may declare several global elements. Choose the document root before export; the selected root controls the generated JSON Schema reference and is named in the report.

Two global XSD elements lead to distinct JSON Schema root selections.

Check the decisions that affect the output

01

Choose the contract root

If the XSD has several global elements, use the root selector after conversion. The first global element is the default; changing it makes the previous result stale.

02

Choose the validator dialect

Draft 2020-12 is the default and Draft-07 is available. The definition keyword and $schema URI change together; Ctrl/Cmd+Enter runs when automatic conversion is off.

03

Read losses before export

A valid JSON Schema can still approximate XSD. Review each source path and severity; copy and download remain disabled until the latest conversion passes target-draft validation.

Structural conversion with a checkable result

Types and reusable definitions

Named simple and complex types become reusable definitions. Enumeration, length and numeric bounds carry into the generated schema where their meaning matches.

Elements, arrays and attributes

minOccurs controls required fields, maxOccurs creates arrays, and XML attributes use @-prefixed properties to avoid collisions with child elements.

Draft-aware result validation

The converter compiles the output against the selected JSON Schema draft and resolves local references. A bad schema blocks export instead of appearing as a successful conversion.

Where schema semantics stop matching

A schema, not instance data
This page converts XSD definitions to JSON Schema. It does not convert XML data to JSON or validate an XML instance against the generated JSON Schema.
No promise of lossless conversion
XML sequence order and attribute namespaces cannot be preserved as ordinary JSON object properties. The report flags those approximations and lists unsupported rules instead of hiding them.
No external schema loading
xs:include, xs:import, redefine and override are not fetched. A dependency blocks export; combine a schema set before using this single-file converter.
XSD 1.0 subset and bounded input
XSD 1.1 assertions, identity constraints and mixed content need manual review. DOCTYPE is rejected; input is limited to 1,000,000 characters and 20,000 nodes.

XSD to JSON Schema questions

How can I generate JSON Schema from an existing XSD?

Load or paste the existing XSD, then select the global root and target draft. The generated file is a JSON Schema; inspect the mapping report for any lost XSD semantics.

Is the conversion from XSD to JSON Schema exact?

No. XSD and JSON Schema describe different data models. A generated schema may be valid for its draft while sequence order, namespaces or identity constraints still need human review.

How does minOccurs map to required fields?

An optional element is left out of required. Repeated elements become arrays with item limits when available; a single optional element remains one property.

How does maxOccurs become an array?

A repeated element becomes an array with items. minOccurs and a finite maxOccurs map to minItems and maxItems; the report identifies the source declaration.

Can a JSON Schema validate XML against the original XSD?

No. JSON Schema validates JSON values, while XSD validates XML. Use an XML/XSD validator for XML instances; this tool checks the generated schema itself.

Does a diagnostic look unexpected?

Use XSD to JSON Schema with the report

Run XSD to JSON Schema on a real schema, select the intended root, and review every approximate or unsupported mapping before using the output in an API.