XML to JSON Converter
This XML to JSON converter turns XML documents into clean, readable JSON right in your browser. Paste your markup or upload a file, and the JSON output appears instantly on the right — ideal for API responses, configuration files, and data feeds.
JSON is lighter and less verbose than XML, works natively in JavaScript, and is the format most modern APIs expect. Converting XML to JSON simplifies nested structures, trims file size, and makes the data easier to read and process. You control exactly how attributes and text nodes are mapped, so the output matches the shape your application needs.
How to Convert XML to JSON
Add your XML
Paste your XML into the left panel, click Upload File to load a .xml, .svg, .xhtml, or .rss file, or hit Sample Data to try a worked example.
See the JSON instantly
Conversion happens automatically as you type — there is no convert button to press. The JSON appears on the right, and the status bar reports whether the XML is Valid or Invalid.
Tune the output
Use the Attr Prefix and Text Key buttons to control how attributes and mixed-content text are named, and toggle Minify for compact single-line JSON.
Copy or download
Switch between the Text and Tree views to inspect the result, then Copy it to your clipboard or Download it as a .json file.
Features
Real-Time Conversion
The converter processes your XML as you type, with a smart debounce so the JSON output updates automatically — no convert button needed.
Flexible Attribute Handling
Map XML attributes to JSON keys with an @ prefix, a _ prefix, or merge them directly into the object to match your expected structure.
Configurable Text Node Key
For mixed content, store the text under a key you choose — #text, _text, or value — so the output reads the way you want.
Smart Element Grouping
Repeated elements with the same tag name are automatically grouped into a JSON array, while single elements stay as objects.
Interactive Tree View
Explore the JSON visually with expand and collapse nodes, count badges on objects and arrays, and color-coded strings, numbers, booleans, and null.
Pretty or Minified Output
Read indented, formatted JSON in the text view, or flip the Minify toggle for compact single-line output ready to embed.
File Upload & Download
Load .xml, .svg, .xhtml, and .rss files straight from your device, and download the converted JSON as a .json file in one click.
Validation & Status Bar
Invalid XML is flagged instantly with a clear message, and the status bar shows element count, attribute count, and the output file size.
Frequently Asked Questions
How do I convert XML to JSON?
Paste your XML into the left panel or upload a file, and the JSON appears on the right automatically as you type. There is nothing to install and no convert button to press — just copy or download the result when you are done.
Does the converter run in my browser, and is my data safe?
Yes. All conversion happens entirely in your browser using its built-in XML parser. Your XML is never sent to any server, so it is safe to convert sensitive or confidential documents.
How are XML attributes handled in the JSON?
By default, attributes are prefixed with @ (for example "@category": "fiction"). Using the Attr Prefix buttons you can switch to a _ prefix or Merge attributes directly into the object with no prefix at all.
What happens when several elements share the same tag name?
Sibling elements with the same name (for example multiple <book> tags) are automatically grouped into a JSON array. A single element of that name stays a regular JSON object.
How is mixed content handled?
When an element contains both text and child elements, the text is stored under a configurable key — #text by default, with _text and value as alternatives. An element containing only text becomes a simple string value.
Does it handle CDATA sections?
Yes. CDATA sections are treated as regular text content — the wrapper is removed and the inner text is included in the JSON just like a normal text node.
What XML file types can I upload?
You can upload .xml, .svg, .xhtml, and .rss files — all XML-based formats that convert cleanly to JSON.
What is the difference between the Text and Tree views?
Text view shows the raw JSON as formatted text, which is handy for copying or reviewing the whole output. Tree view gives an interactive, hierarchical layout where you can expand and collapse nodes to explore the structure.
No comments yet. Be the first to comment!