XML to JSON

XML to JSON — a free online tool.

Converting XML to JSON

Paste any well-formed XML and this tool converts it to JSON, preserving attributes (under an @attributes key), repeated sibling elements as arrays, and text content. Useful when working with legacy XML APIs or feeds in a modern JSON-based codebase. Everything runs locally in your browser.

Why attributes get their own special key

XML has a structural concept JSON doesn't: an element can carry both attributes and child content at the same time (like <item id="1">Hello</item>). Since JSON objects don't have a native equivalent to XML attributes, this tool nests them under a dedicated @attributes key, keeping them clearly distinguishable from actual child elements or text content rather than mixing them together ambiguously.

Why repeated tags become arrays automatically

When the same element name appears more than once at the same level in the XML (like multiple <item> tags inside a list), representing each occurrence as a separate JSON object with the same key would simply overwrite the previous one - so the tool detects repeated sibling tags and automatically converts them into a JSON array instead, preserving every occurrence in its original order.

Why conversion stops with an error on invalid XML

Unlike HTML, which browsers parse leniently even when it's malformed, XML has strict well-formedness rules - every tag must be properly closed and correctly nested. This tool uses the browser's own strict XML parser, so unclosed tags or mismatched nesting produce a clear error rather than a silently incorrect or partial conversion.

よくある質問

How are XML attributes represented in the JSON?

Each element's attributes are nested under an "@attributes" object within that element's JSON representation, keeping them distinguishable from child elements and text content.

What happens with repeated sibling tags?

When the same tag name appears more than once at the same level, this tool automatically converts them into a JSON array, preserving their order.

Why do I get an error instead of a partial result?

XML has strict well-formedness rules, and this tool uses the browser's own strict parser - unclosed tags or incorrect nesting produce a clear error rather than risk silently converting something incorrectly.

Does this preserve the original order of elements?

Yes - both the order of array items from repeated tags and the overall document structure are preserved in the resulting JSON.

Can I convert very large or deeply nested XML files?

Yes, within your browser's memory limits - there's no hardcoded size restriction, though extremely large files will naturally take a moment longer to parse and convert.

Technical SEO & Site Managementのその他のツール