XSD to JSON Schema Examples
A collection of practical examples demonstrating how XML Schema Definition (XSD) structures map to modern JSON Schema (Draft 07).
⚡ Go to Converter ToolExample 1: Simple Object Mapping
A common scenario is mapping a flat XML element with child elements to a JSON object with properties.
Input XSD
<xs:complexType name="Person">
<xs:sequence>
<xs:element name="fullName" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="isActive" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
JSON Schema Output
"Person": {
"type": "object",
"properties": {
"fullName": { "type": "string" },
"age": { "type": "integer" },
"isActive": { "type": "boolean" }
},
"required": ["fullName", "age", "isActive"]
}
Example 2: Handling Arrays (Lists)
In XSD, collections are defined using maxOccurs="unbounded". In JSON Schema, this translates to
the array type.
Input XSD
<xs:element name="tags">
<xs:complexType>
<xs:sequence>
<xs:element name="tag" type="xs:string"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
JSON Schema Output
"tags": {
"type": "object",
"properties": {
"tag": {
"type": "array",
"items": { "type": "string" }
}
}
}
Example 3: Deeply Nested Structures
Modern APIs often have deep nesting. Our converter handles generic recursive structures efficiently.
Input XSD
<xs:element name="Order">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="sku" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
JSON Schema Output
"Order": {
"type": "object",
"properties": {
"id": { "type": "string" },
"items": {
"type": "object",
"properties": {
"item": {
"type": "array",
"items": {
"type": "object",
"properties": {
"sku": { "type": "string" }
}
}
}
}
}
}
}
Ready to convert your own XSD files?
Try our free, private, client-side converter tool.
Use XSD to JSON Schema Converter