Need the opposite? Convert JSON to XML

Convert XML into structured JSON directly in your browser. Paste XML or upload a local .xml file, choose how attributes, arrays, text, and values should be represented, then copy or download the JSON result.

XML Input

Paste XML or load a local file.

0 lines 0 characters 0 B

Conversion Options

XML and JSON do not have one universal mapping, so the representation is explicit.

Applies to elements such as <empty/> when they have no included attributes.

Formatting only; this does not change the JSON data structure.

Mapping: attributes use @name; object text uses #text; repeated sibling elements become arrays.

XML parsing and JSON generation happen locally in this browser. No conversion library, upload service, or server request is required.

XML to JSON Converter

This XML to JSON converter turns XML documents into structured JSON directly in your browser. Paste XML or open a local XML file, choose the mapping options, and copy or download the result.

How XML Is Mapped to JSON

XML and JSON model data differently, so there is no single official XML-to-JSON representation. This converter uses predictable rules: element names become object keys, repeated sibling elements become arrays, attributes use an @ prefix, and element text uses #text when the value also needs attributes or child data.

For example:

<book id="101">
  <title>Example Book</title>
  <price currency="USD">19.95</price>
</book>

with the default options becomes approximately:

{
  "book": {
    "@id": "101",
    "title": "Example Book",
    "price": {
      "@currency": "USD",
      "#text": "19.95"
    }
  }
}

How to Convert XML to JSON

  1. Paste XML into the editor or upload a local .xml file.
  2. Choose how attributes, arrays, empty elements, whitespace, and values should be represented.
  3. Click Convert XML to JSON.
  4. Review the diagnostics and generated JSON.
  5. Copy the result or download it as a .json file.

Attributes and Repeated Elements

When attributes are enabled, an attribute such as id="42" becomes "@id": "42". Repeated sibling elements with the same qualified name automatically become arrays. An optional setting can force every child element name to use an array even when it appears only once.

Text, CDATA, and Mixed Content

Simple text-only elements can be compacted directly to strings. CDATA is treated as text. If an element contains both direct text and child elements, the direct text is stored under #text. Because this is an object-style mapping, the exact interleaving order between mixed text and child elements is not retained; the tool reports mixed-content elements so that limitation is visible.

XML Values Stay Strings by Default

XML text does not inherently distinguish 00123 from a string identifier. Type inference is therefore disabled by default. If enabled, exact boolean, null, and unambiguous numeric values can be converted to native JSON scalar types.

DOCTYPE Declarations

This browser converter rejects XML documents containing a real DOCTYPE declaration. DTD and entity-expansion behavior is unnecessary for ordinary data conversion and is intentionally outside the scope of this tool.

Private Browser-Side Conversion

The converter uses the browser's built-in XML parser and JavaScript JSON serializer. The XML document does not need to be uploaded to Flipper File or sent to a third-party conversion service.

Our Full Dev Tool Library

Flipper File