XML to JSON Converter
Paste XML and convert to JSON online - or go the other way on the same page.
About XML to JSON Converter
Paste XML and convert to JSON online - or go the other way on the same page. This free XML to JSON Converter runs entirely in your browser, so config files, RSS feeds, SVG markup, and API envelopes with real data never leave your device. Attributes become @prefixed keys (for example @id), text-only elements collapse to strings, and mixed content uses #text so you can round-trip with Swap. Pair it with the XML Formatter & Minifier or the YAML to JSON Converter.
How to Use XML to JSON Converter
- Choose XML → JSON or JSON → XML (or Swap direction after a conversion).
- Paste your document, drop a local .xml / .svg / .rss / .json file (max 10 MB - read in the browser only), or load a config, RSS, or SVG sample.
- Set indent 2/4. For JSON → XML, optionally include the XML declaration. Review element and attribute counts.
- Copy or download the result. Comments are stripped on XML → JSON because JSON has none. Nothing is uploaded.
XML to JSON Converter Examples
Config XML with attributes
A <config env="staging"> block becomes JSON with "@env": "staging". Nested database and feature elements keep structure; repeated <feature> tags become arrays.
RSS channel to JSON
Paste an RSS 2.0 channel. Items become an array under channel.item so you can inspect titles and descriptions as JSON before wiring a reader.
SVG markup
Convert a small SVG icon to JSON to inspect xmlns, viewBox, and child shapes, then Swap back to XML for embed use.
JSON back to XML
Start from JSON with @attribute keys and a single root object key. Toggle Include XML declaration when you need <?xml version="1.0" encoding="UTF-8"?>.
Multi-key JSON wrap
If JSON has several top-level keys, they wrap in a <root> element so the output stays well-formed XML with one root.
Common Use Cases
- Turn API XML responses into JSON for debugging
- Convert RSS / Atom snippets to JSON fixtures
- Inspect SVG structure as JSON before editing
- Round-trip config XML with attributes preserved as @keys
- Produce XML from JSON test fixtures in the browser
Frequently Asked Questions about XML to JSON Converter
- How do I convert XML to JSON online?
- Choose XML → JSON, paste your XML (or drop a .xml / .svg / .rss file), and copy or download the JSON. Conversion runs in your browser - nothing is uploaded.
- Can I convert JSON to XML on the same page?
- Yes. Switch to JSON → XML or use Swap direction. A single top-level object key becomes the root element. Multiple keys wrap in <root>.
- How are XML attributes represented in JSON?
- Attributes become keys with an @ prefix, for example @id and @class. On JSON → XML those keys become attributes again so round-trips stay predictable.
- What happens to text and mixed content?
- Elements that only contain text collapse to a JSON string. When text and child elements mix, the text is stored under #text alongside child keys.
- Are XML comments preserved in JSON?
- No. JSON has no comment syntax, so <!-- comments --> are stripped. The UI shows a badge when comments were detected.
- Is my XML uploaded to a server?
- No. Parsing and conversion run only in your browser. Safe for configs and feeds that name real hosts or include private markup.
- Does the document need a single root element?
- Yes for XML → JSON. Sibling roots are rejected with a clear error - wrap them in one parent tag first. That keeps the JSON shape unambiguous.
- How is this different from the XML formatter?
- The XML Formatter & Minifier pretty-prints or compresses XML. This page converts between XML and JSON with attribute handling and Swap - use both when you need clean markup and a JSON view.
Related Tools
XML Formatter & Minifier
Free XML formatter online and XML minifier online. Beautify or compress XML, SVG, RSS, and config files in your browser - nothing is uploaded.
YAML to JSON Converter
Convert YAML to JSON and JSON to YAML online in your browser. Multi-document streams, Norway-safe YAML 1.2, Docker Compose / GitHub Actions / Kubernetes samples. Nothing is uploaded.
TOML to JSON Converter
Convert TOML to JSON and JSON to TOML online in your browser. Cargo.toml, pyproject.toml, and app configs. Swap direction. Nothing is uploaded.
JSON Minifier & Formatter
Free online JSON minifier and formatter. Minify JSON to shrink payloads or beautify (pretty-print) JSON with 2-space indentation. Validates as you go - no upload required.
JSON to CSV Converter
Convert JSON to CSV and CSV to JSON in your browser. Flatten nested objects, unflatten dotted keys on the way back, NDJSON, Excel EU preset, RFC 4180. Nothing is uploaded.