XSD to JSON Schema Converter

: Convert supported XML Schema declarations to JSON Schema
Limits: 50 MB · .xsd or plain text · Large schemas are converted with a progress line and can be cancelled; nesting is limited to 64 levels. Unsupported XSD constructs stop the conversion. The schema validates this JSON representation, not XML, and not XML child order; numbers use JavaScript precision, so review large integers and decimals. Wrap the root in an object. Element names use {namespaceURI}localName when qualified; unqualified names stay plain. Attributes use @name (or @{namespaceURI}name). Simple elements are typed JSON values. Elements with attributes use an object with #text. Repeated elements are always arrays. Optional properties may be absent. XML order and namespace declarations are not represented.
JSON Schema
The JSON Schema appears here as you type.

Translate a supported XML Schema into a JSON Schema draft 2020-12 document for a defined JSON representation. Element declarations become properties, attributes use an @ prefix, and repeated elements become arrays. Conversion stops on unsupported constructs so a choice, import or pattern does not quietly disappear from the result.

  1. Paste your XSD into the XSD schema pane, select it with Open file, or press Example for an order declaration.
  2. The JSON Schema appears as you type; a schema over 2,000,000 characters waits for the Convert button instead and shows its progress, with Cancel. If a feature is unsupported, resolve the issue named in the message above the panes; no partial output is shown.
  3. Read any warnings above the panes (types mapped loosely, mixed text) and the JSON representation note under them. Your JSON data must use that representation to match the generated schema.
  4. Use Copy or Download to save the JSON Schema, then validate representative JSON documents against it.

A required identifier becomes @id. Tags are optional, but when present they use an array even if there is only one tag. The document is wrapped under order.

Input
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="order">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="tag" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
</xs:schema>
Output
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$comment": "Wrap the root in an object. Element names use {namespaceURI}localName when qualified; unqualified names stay plain. Attributes use @name (or @{namespaceURI}name). Simple elements are typed JSON values. Elements with attributes use an object with #text. Repeated elements are always arrays. Optional properties may be absent. XML order and namespace declarations are not represented.",
  "type": "object",
  "properties": {
    "order": {
      "$ref": "#/$defs/element:order"
    }
  },
  "required": [
    "order"
  ],
  "additionalProperties": false,
  "$defs": {
    "element:order": {
      "type": "object",
      "properties": {
        "tag": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 0
        },
        "@id": {
          "type": "string"
        }
      },
      "required": [
        "@id"
      ],
      "additionalProperties": false
    }
  }
}

Can this convert any XSD without losing constraints?

No. XML and JSON have different models, and this converter handles a declared subset. Unsupported structures stop conversion. Constraints intentionally mapped more loosely, such as date lexical rules and mixed-text ordering, produce warnings.

Do I need to keep the XML root name in my JSON?

Yes. The generated schema expects an object containing exactly one declared root property. A target namespace is included in that property's name using the {namespaceURI}localName convention.

Runs entirely in your browser. Nothing is uploaded.