UtilDojo

Popular

Menu

XML to JSON Converter Online

  • This tool runs entirely in your browser. Nothing you enter or upload is sent to a server.

XML

Tab indents · Shift+Tab outdents · Esc then Tab moves on

JSON

Your JSON shows up here

Paste or type on the left, upload a file, or drop one onto the input.

Waiting for input

JSON & data

About this tool

Paste XML and see the equivalent JSON as you type. Elements become keys, nested elements become nested objects, and an element that holds only text becomes a string. Comments and processing instructions are dropped, a <!DOCTYPE> is skipped, entities such as &amp; and &#65; are decoded, and CDATA sections are kept as text exactly as written.

The conversion follows the convention most XML-to-JSON tools use. Attributes become keys that start with @ (or _, if you choose that prefix). When an element has both text and attributes or children, its text goes under the #text key. Repeated sibling elements become an array, so three <item> tags give you "item": [ … ]. A single <item> stays a plain value, which is worth remembering if your code expects an array every time.

Values are never converted to numbers or booleans: <n>12345678901234567890</n> stays the string "12345678901234567890", so nothing is rounded, and you can convert types in your own code. The root element is kept as the top-level key.

If the XML is not well-formed, you get a message with the line and column, for example a closing tag that does not match, a tag that is never closed, or more than one root element. Everything runs in your browser, so internal feeds and config files stay private.

Frequently asked questions

How are XML attributes represented in JSON?

As keys beginning with @, for example <book id="7"> gives {"book": {"@id": "7"}}. You can change the prefix to an underscore in the options.

Why is a repeated element sometimes an array and sometimes not?

The converter cannot know your schema, so one occurrence stays a single value and two or more become an array. If your code needs an array always, wrap the result: Array.isArray(x) ? x : [x].

Why are my numbers strings?

XML stores everything as text, and converting guesses would risk rounding long numbers or turning values like 007 into 7. Convert the types you need in your own code.

What happens to comments, CDATA and the XML declaration?

Comments, processing instructions and the declaration are dropped, and a DOCTYPE is skipped. CDATA content is kept as text, with no escaping needed.

What if text is mixed between child elements?

Text next to child elements is joined and stored under #text, trimmed at both ends. The exact position of the text between elements is not preserved, so this tool is best for data XML rather than documents such as HTML.

Is my XML uploaded anywhere?

No. The conversion runs in your browser and nothing is sent to a server, so configuration files, API payloads and customer data stay on your device.

Related tools