Free Online XML ↔ JSON Converter
Convert XML to JSON and JSON to XML with attribute handling, validation messages and a JSON tree preview.
XML input
JSON result
How to use
Choose XML to JSON or JSON to XML, then paste your text or open a file.
Pick whether to keep attributes and convert numbers, or set the root element and indentation.
Check the result, or switch to Tree to explore JSON as an outline.
Copy the result or download it as a file.
Why use this tool
Attributes kept
XML attributes become keys that start with @_, and convert back to attributes.
Error line numbers
Invalid XML is reported with the line and column of the problem.
Tree preview
Explore converted JSON as a collapsible tree.
Valid XML out
Single-root wrapping, escaping of special characters and element name checks keep the XML valid.
About this tool
Attributes can be kept as keys that start with @_, repeated elements become lists, and numbers and booleans can be converted to real JSON types. Invalid XML is reported with a line and column. Explore the result in a collapsible tree, then copy or download it.
Frequently asked questions
An element with attributes and text becomes an object with the attributes as @_ keys and the text under a key called #text. Convert back and it becomes the same XML.
XML needs exactly one root element. If your JSON has several top-level keys or is a list, the tool wraps it in a root element whose name you can choose, and tells you it did so.
Names must start with a letter or underscore and contain only letters, numbers, dots, dashes and underscores. Other keys are rejected with a message naming the key.
No. Comments are dropped when converting to JSON.
With Convert numbers turned on, 007 becomes 7. Turn it off to keep every value as text.