Open Tools LibraryOpen Tools Library
Developer Tools

XML to JSON

Real XML parsing via the browser's own parser — attributes handled correctly.

Also known as: XML JSON converter, XML parser online, XML to JSON transformer

100% FreeNo Signup RequiredReal XML ParserCorrect Attribute Handling
100% local — nothing you enter here ever leaves this browser tab
Loading tool…
Step by step

How it works

  1. 1Paste your XML into the box, or click "Try a sample" to see it in action.
  2. 2Toggle whether to include attributes (as @name keys) and whether to strip namespace prefixes.
  3. 3Read the converted JSON, updated live as you edit.
  4. 4Copy the result, or download it as a .json file.
Why OTL

Why use XML to JSON

Built on a real XML parser

Uses the browser's native DOMParser instead of fragile regex-based parsing.

Correct attribute handling

Attributes are clearly prefixed and distinguishable from child elements, not dropped or merged confusingly.

Handles repeated elements correctly

Multiple sibling tags with the same name automatically become a JSON array.

Clear parse errors

Surfaces the actual XML parser error message instead of silently returning broken output.

Namespace handling

Optionally strip namespace prefixes for cleaner, simpler output.

Nothing uploaded

Parsing and conversion both happen locally in your browser tab.

Real-world use

Who uses XML to JSON

Migrating legacy XML data to JSON

Convert an old XML export into JSON for a modern API or database.

Reading an RSS or Atom feed

Convert feed XML into JSON to work with it more easily in JavaScript.

Inspecting a SOAP response

Turn a SOAP XML response into readable JSON for debugging.

Converting a config file format

Migrate an XML-based configuration file into JSON.

Working with XML APIs in a JSON-first codebase

Convert responses from an XML API before passing them into JSON-based tooling.

Teaching XML structure

See exactly how attributes, text, and nested elements map onto JSON.

Deep dive

About XML to JSON

A lot of XML-to-JSON converters are built on regular expressions trying to approximate what an XML parser does, and it usually shows: attributes get dropped or handled inconsistently, malformed XML produces garbage output instead of an error, and edge cases like CDATA sections or entity references (&, <, and similar) get mangled. This tool avoids all of that by using the browser's own DOMParser — the same battle-tested engine that renders XML natively — to actually parse the document, then walking the resulting structure to build JSON from it.

That matters most for attributes, which are where naive converters most often go wrong. This tool represents each attribute as a key prefixed with @ (so <to importance="high"> becomes {"@importance": "high"}), keeping attributes clearly distinguishable from child elements in the resulting JSON — with an option to drop attributes entirely if you only care about the element structure and text content.

Repeated sibling elements are handled the way most JSON consumers expect: a single occurrence of a tag becomes a plain value or object, while multiple occurrences of the same tag under one parent automatically become a JSON array. Text content is captured under a #text key when an element has both attributes or children and its own text, so nothing gets silently dropped.

Because DOMParser doesn't throw JavaScript exceptions on malformed XML — it silently embeds a <parsererror> element in the result instead, a genuine gotcha that trips up naive implementations — this tool explicitly checks for that and surfaces the real parser error message instead of returning an empty or broken result. Everything happens locally: your XML is parsed and converted entirely in the browser tab, never uploaded anywhere.

Compare

XML to JSON vs. other options

How Open Tools Library compares to desktop software and other online tools.

FeatureOpen Tools LibraryDesktop softwareOther online tools
PriceFree, unlimitedVariesOften free
Parsing methodReal XML parser (DOMParser)VariesOften regex-based
Attribute handlingCorrect, clearly markedVariesOften dropped or inconsistent
Malformed XML handlingClear parser error shownVariesSometimes silent/broken output
Data privacyNever leaves your deviceStays localOften sent to a server
SpeedInstant, live as you typeInstantVaries by site
Pro tips

Pro tips

  • Turn off attribute inclusion if you only need element text and structure — it produces noticeably cleaner output.
  • Strip namespace prefixes if your XML uses them heavily and you don't need to distinguish namespaces in the JSON.
  • A single child element becomes an object; two or more with the same tag name automatically become an array — no configuration needed.
  • If conversion fails, check the exact parser error shown — it usually points to a specific malformed or unclosed tag.
  • CDATA sections and XML entities (&amp;, &lt;, etc.) are handled correctly since a real XML parser is doing the work, not a regex.
Under the hood

Technical specs

Parser
Browser-native DOMParser (application/xml)
Attribute representation
@attributeName keys
Repeated elements
Automatically become arrays
Namespace handling
Optional prefix stripping
Output format
JSON (copy or .json download)
Processing location
100% local, in your browser

Privacy & security

XML often carries structured business or system data, so converting it shouldn't require handing a copy to a server you don't control.

XML parsing and JSON conversion both run locally in your browser tab.

No account or signup is required to use this tool.

Nothing you paste in is stored, logged, or cached anywhere.

Works the same for a public RSS feed as it does for an internal system export.

FAQ

Frequently asked questions

Is my XML uploaded anywhere?

No. Parsing and conversion both happen locally in your browser using the browser's built-in XML parser.

How are XML attributes represented in the JSON?

Each attribute becomes a key prefixed with @, e.g. importance="high" becomes "@importance": "high", keeping it clearly distinct from child elements.

What happens to text content alongside attributes or child elements?

It's captured under a #text key so it isn't lost when an element also has attributes or children.

Does it handle CDATA sections and XML entities correctly?

Yes — since a real XML parser does the parsing, CDATA and entities like &amp; and &lt; are handled the same way a browser natively handles XML.

What happens with malformed XML?

The tool detects the parser's own error and shows it directly, rather than silently returning broken or empty output.

Can I download the result?

Yes — copy it directly or download it as a .json file.

Stuck?

Troubleshooting

My attributes are missing from the output

Check that "Include XML attributes" is turned on — with it off, only element structure and text content are converted.

I'm getting a parse error but my XML looks fine

Look for unclosed tags, mismatched opening/closing tags, or invalid characters — the error message names the specific problem the parser found.

Repeated tags aren't turning into an array

Arrays only form when two or more sibling elements share the exact same tag name under the same parent — check for a typo or namespace difference between them.

My namespace prefixes are cluttering the output

Turn on "Strip namespace prefixes" to remove them from key names, e.g. converting ns:item to item.

Ready to use XML to JSON?

Free, private, and ready right now — no signup required.

Scroll to XML to JSON