Infer JSON Schema from Nested XML Elements

See how deeply nested XML structures with multiple levels of child elements produce nested object schemas with proper property hierarchy.

Basic XML

Detailed Explanation

Nested XML to Nested Object Schemas

Real-world XML is rarely flat. Most XML documents contain elements nested several levels deep. The converter recursively processes each level and produces a matching hierarchy of object schemas.

Example XML

<company>
  <name>Acme Corp</name>
  <address>
    <street>123 Main St</street>
    <city>Springfield</city>
    <state>IL</state>
    <zip>62701</zip>
  </address>
  <contact>
    <phone>
      <office>555-0100</office>
      <mobile>555-0101</mobile>
    </phone>
    <email>info@acme.com</email>
  </contact>
</company>

Generated Schema

The converter produces a three-level nested structure:

  • company → object
    • name → string
    • address → object
      • street, city, state, zip → string
    • contact → object
      • phone → object
        • office, mobile → string
      • email → string

How Nesting Works

For each element that has child elements, the converter creates an object type schema and recursively processes the children to build its properties. This continues until it reaches leaf elements that contain only text content, which become scalar type properties.

Tree View

The built-in tree view is especially helpful for deeply nested schemas. You can expand and collapse each level to inspect the structure without scrolling through large JSON output. Each node shows the property name and its inferred type with color coding — blue for objects, purple for arrays, green for strings, orange for numbers, and yellow for booleans.

Use Case

When dealing with hierarchical XML data such as organizational structures, configuration files with nested sections, or any XML that represents real-world entities with sub-entities. This is the foundation for understanding how the converter handles complex XML structures.

Try It — XML to JSON Schema

Open full tool