XML to JSON Converter
Convert XML to JSON and back again, instantly and entirely in your browser. Attributes are preserved and the input is validated before parsing.
XML to JSON Converter features
Bidirectional Conversion
Convert XML to JSON and JSON to XML with a single direction toggle.
Swap In One Click
Move the output back into the input to instantly reverse the conversion.
Attributes Preserved
XML attributes are kept using an @_ prefix on JSON keys, so nothing is lost.
Validation First
XML is validated before parsing, so malformed markup is caught early.
100% Private
All conversion happens locally in your browser — nothing is ever uploaded.
Instant Output
Powered by fast-xml-parser for quick, reliable parsing and building.
Overview
XML (Extensible Markup Language) and JSON (JavaScript Object Notation) are two of the most common formats for storing and exchanging structured data. XML uses nested tags such as <book>Dune</book>, while JSON uses key-value pairs like {"book": "Dune"}. Many APIs, config files, and legacy systems mix both, so converting between them is a routine task.
This XML to JSON Converter performs a bidirectional conversion. A direction toggle lets you switch between XML → JSON and JSON → XML, and a Swap button moves the output back into the input so you can convert it the other way in one click.
XML attributes are preserved during conversion using an @_ prefix on the resulting JSON keys. For example, <book id="1">Dune</book> becomes a JSON object containing a key like @_id, so no information from the original markup is lost. When you convert JSON back to XML, keys with that prefix are rebuilt as attributes.
Under the hood the tool uses fast-xml-parser to parse and build the data, and the XML is validated before parsing so malformed markup is caught early. Everything runs locally in your browser — your data is never uploaded to a server.
How to use the XML to JSON Converter
- Paste or type your XML (or JSON) into the input box.
- Set the direction toggle to XML to JSON, or switch it to JSON to XML.
- Read the converted result in the output panel — invalid XML is flagged before conversion.
- Note that XML attributes appear in the JSON with an @_ prefix on their keys.
- Click Swap to move the output into the input and convert it back the other way.
- Copy the converted output to use it in your project.
Good to Know
A few things worth keeping in mind when converting between XML and JSON:
- Attributes use a prefix. XML attributes become JSON keys prefixed with
@_. If you edit the JSON, keep that prefix intact so attributes rebuild correctly on the way back to XML. - Not every detail maps over. XML features such as namespaces, comments, and mixed text-and-element content may be simplified or dropped, since JSON has no direct equivalent.
- Conversion is structural, not semantic. The tool transforms the data shape — it does not validate against a DTD or XML Schema, and JSON output is not checked against any schema.
- Everything stays local. Parsing and building both run in your browser, so no data leaves your device.
Private by design
Every byte you paste into the XML to JSON Converter is processed locally in your browser. Formatly makes no network request with your data, logs nothing, and stores nothing on any server — so it is safe for API responses, tokens, configuration and other sensitive content. Your most recent input and theme are saved only in your own browser's local storage.
XML to JSON Converter FAQ
Is my data safe and private?
Yes. This converter runs 100% in your browser using client-side JavaScript. Your XML and JSON are never uploaded to any server, so even sensitive or proprietary data stays on your own machine.
Does this tool work offline?
Once the page has loaded in your browser, conversion happens entirely on your device. Because no server round-trip is needed, it continues to work even if your connection drops.
What does the @_ prefix in the JSON mean?
It marks data that came from an XML attribute. For example, <book id="1"> produces a JSON key like @_id. This keeps attributes distinct from child elements and lets the tool rebuild them correctly when you convert JSON back to XML.
Can it convert JSON back into XML?
Yes. The conversion is bidirectional. Use the direction toggle to choose JSON → XML, or click Swap to move the current output into the input and convert it the other way.
What happens if my XML is invalid?
The XML is validated before parsing, so malformed or unbalanced markup is detected up front and you are alerted rather than receiving a broken or partial result.
What is the difference between XML and JSON?
XML is tag-based and verbose, using elements and attributes like <item id="1">value</item>. JSON is lighter and uses key-value pairs like {"item": "value"}. JSON is common in modern web APIs, while XML is widespread in config files and legacy systems — this tool bridges the two.
Is the conversion lossless?
The tool preserves XML attributes via the @_ prefix and round-trips structured data faithfully. Note that some XML-only details — such as comments, processing instructions, or strict element ordering of mixed content — do not have direct JSON equivalents, so treat conversions of such documents as approximate.