Private by defaultFree. Always useful.
Markup to objectsTHE SMALL TOOLS THAT MAKE A BIG DIFFERENCE

XML to JSON.

Convert XML to JSON in your browser with attributes, repeated elements, mixed content, and namespace prefixes preserved. No uploads or sign-up.

100% browser-based
Ctrl + Enter to convert or Command + Enter on Mac

Input

XML
10 lines · 277 bytesUTF-8

Output

JSON

A clearer view, coming right up.

Your converted JSON will appear here.

Hit “Convert to JSON” to get started
Waiting for your input JSON
Only your browser sees your data. 2 MB input limit.No uploads. No sign-up. Just tools.
A QUICK WALKTHROUGH

Good data, in three steps.

Simple by design. Ready when you are.

  1. 01

    Bring your data

    Paste well-formed XML with one root element, or choose a local XML file.

  2. 02

    Make it yours

    Choose JSON indentation and select Convert to JSON.

  3. 03

    Keep things moving

    Copy or download the result. Review the mapping rules for attributes and mixed content.

A few things under the hood

Know exactly how your data is handled.

XML to JSON conversion rules
  • The root element is retained. Text-only elements become strings; empty elements become "". All attribute and text values stay strings.
  • Attributes are grouped under @attributes. Elements with attributes and no child elements store their text under #text.
  • In elements containing only children, repeated siblings with exactly the same qualified name become an array. A single occurrence stays a single value.
  • Namespace prefixes and xmlns declarations are preserved literally: book:item stays book:item and xmlns:book is an attribute. Prefixes are not expanded to namespace URIs or merged.
  • CDATA becomes text, including whitespace-only CDATA. Leaf whitespace is preserved. Indentation-only text between children is omitted unless inherited xml:space="preserve" applies; xml:space="default" resets preservation. The XML parser normalizes line endings and attribute whitespace per XML rules.
  • For mixed text and child elements, #text concatenates direct text and #content preserves their order as strings and element objects. Children appear only in this ordered array, including repeated children. Child-only order across different names is not represented.
  • Comments and processing instructions are omitted. DOCTYPE and ENTITY declarations are rejected before parsing, including declarations embedded in comments or CDATA. External entities are never fetched or resolved. Built-in XML entities and numeric character references are decoded.
  • All tools accept UTF-8 text up to 2 MB and nesting up to 80 levels. Results are limited to 8 MB. CSV tables are limited to 1,000,000 cells including headers; XML is additionally limited to 50,000 elements. Results are held only in this page’s memory; refreshing or navigating away clears them.
COMMON QUESTIONS

XML to JSON questions

Answers for working with real data.

How are XML attributes and repeated elements converted?

Attributes appear under @attributes. Text-only elements become strings, and repeated siblings with the same qualified name become arrays in child-only elements. For example, <item id="7">Ready</item> becomes {"item":{"@attributes":{"id":"7"},"#text":"Ready"}}.

Are namespace prefixes and mixed-content order preserved?

Namespace prefixes remain literal: book:item stays book:item, and xmlns declarations remain attributes. Mixed-content elements use #text for their direct text and #content for an ordered sequence of text and children. Order across differently named child-only elements is not retained.

Does the XML converter load external entities or DTDs?

No. DOCTYPE and ENTITY declarations are rejected before the browser parses the XML. Built-in entities such as &amp; and numeric references are decoded. The converter does not fetch external resources.

Keep your workflow flowing.

THERE’S A TOOL FOR THAT