Free XML to JSON Converter

Paste XML, upload a file or load a public URL, then convert it to JSON and view it in a code, tree or form editor. Free, no account needed.

Upload File

Result

Free XML to JSON Converter: What It Does

Quick answer: This free XML to JSON converter runs in your browser. Paste markup into the box above, upload an .xml file or load a public URL, press Convert to JSON, then copy the result or save it as text. Every value stays a string.

Developers use it to turn an Atom feed, SOAP response or sitemap.xml into a REST API, and analysts who want a tree structure from legacy XML data. One fixed mapping applies: attributes get an underscore, text gets __text and repeated elements become arrays.

How to Convert XML to JSON Online

  1. Add your XML. Paste into Enter or Paste XML, use the upload button for an XML file (the picker shows .xml only, so paste RSS or Atom or rename it), or type an address into Load from URL, which loads after a short pause or when you press Enter.
  2. Press Convert to JSON. A Result card opens.
  3. Review it. Check tree view and code view. Format will pretty print the JSON and Compact strips whitespace. Skip Sort when key order matters.
  4. Copy or save. Copy to Clipboard copies the JSON output. Save as TXT downloads xml-to-json.txt.

Rename the download: the saved file is plain text holding JSON, so change the extension to .json yourself.

XML to JSON Example: Attributes, Text and Repeated Tags

Every output below comes from this page, unedited.

XML featureJSON resultNote
book with id and lang, title child, price with currencytitle "XML Guide", price with _currency "USD" and __text "44.95", _id "bk101", _lang "en"Attributes land after children
Three book siblings A, B, Cbook is an array of A, B, CRepeated elements
One book sibling Abook is the string "A"Not an array
x:item with an x:id attributeitem with _x:id "1", __prefix "x", __text "v"Root gets _xmlns:x
RSS feed with two item elementsitem is an array of two objectsrss has _version "2.0"
CDATA holding bold markupA plain stringMarkup kept as text
Empty a and b, c with an attributea "", b "", c with _attr "1"Attributes stay
Number 007"007"Stays a string

Loops over book break when one sibling arrives as a string.

How the Converter Maps XML Into JSON

The browser's XML parser rejects anything that is not well formed. Valid documents go to X2JS 1.2.0, which returns one JSON object with nested elements as key value pairs. The output follows RFC 8259.

XML featureJSON resultNote
AttributeKey with a leading underscoreid becomes _id
XML entitiesDecoded& becomes &
Comments and declarationDroppedText is trimmed
Attribute plus text_attr and __textBoth kept
Repeated siblingsArrayOne stays a string
Namespaced elementPrefix moves to __prefixPrefixed attributes keep it
Attribute and child, one nameBoth keptid and _id
Empty elementEmpty stringUnless it has attributes

The XML sitemap generator makes a sitemap.xml.

What This Converter Cannot Do

Every value is a string. The values 44.95, 007, true, 1e400 and 9007199254740993 come out quoted and unchanged.

Order is not kept, and mixed content suffers most. In <p>Hello <b>bold</b> world</p>, b becomes its own key and the two text runs join into one __text string. Siblings a, b, a give a as 1 and 3. A round trip cannot match the original; the XML vs JSON guide explains why.

The underscore prefix and the __text key are fixed. Your browser does the work, so big files slow down faster than they grow: on our test machine, converting and displaying about 1.2 MB took 3 seconds and about 5 MB took 24 seconds. Load from URL stops at 3 MB.

Is Your XML Sent to a Server?

Pasted text and files are parsed on your device by DOMParser; we saw no request to our server during a conversion. Load from URL is the exception: only that address goes to our server, which fetches the public file. For private files, paste instead.

Why You Get an Invalid XML Error

The tool checks for well-formed XML first, per Extensible Markup Language (XML) 1.0, and a parse error shows Invalid XML with line and column. Fixes:

  • Mismatched tag or unclosed tag: the error often points past the mistake. Close tags in reverse order.
  • Plain text: start with a real element.
  • Undefined entity such as &nbsp;: use &#160;.

An empty box answers XML is required as input. Tidy a file with the XML Formatter or read how to format XML online.

Related Free JSON and XML Tools

These free tools pick up where the converter stops.

Last updated

Frequently Asked Questions

Frequently Asked Questions (FAQs) is a list of common questions and answers provided to quickly address common concerns or inquiries.

How do I convert XML to JSON online?

Paste your XML into Enter or Paste XML, upload an .xml file, or use Load from URL. Press Convert to JSON, then use Copy to Clipboard or Save as TXT. The saved file is .txt, so rename it to .json yourself.

How are XML attributes shown in the JSON?

Each attribute becomes a key with a leading underscore, so id turns into _id. If the element also holds text, that text sits under __text beside the attributes. A price with a currency attribute gives _currency and __text. An item with id 5 and the text x becomes _id 5 and __text x.

Why did a repeated tag turn into an array?

Two or more siblings that share a name become an array, while a single sibling stays a plain value. The converter cannot know your schema, so your code must handle both shapes. Test with one item and with several before trusting a loop.

Are numbers kept as numbers?

No. Every value comes out as a string, so 007, 1.10 and 9007199254740993 survive exactly as written, with nothing rounded. The page has no option for numbers or booleans, so convert types in your own code after you copy the JSON.

Is my XML uploaded to a server?

Pasted and uploaded XML is converted in your browser, and we saw no request to our server during a conversion. Load from URL is different: the address goes to our server, which fetches the public file for you, up to 3 MB.

Can I convert JSON back to XML?

Yes, the JSON to XML converter does the reverse job, but do not expect the original back. Comments, the XML declaration and sibling order are lost, so the result will not match your source. Always keep your source XML file.
Share on Social Media: