All Over Tools logo
Tool Combiner
Text Cleanup Text Formatting Text Analysis Text Parsing Data Validation Text Transformation Text Generation
File Converters File Compressors Image Tools Video Tools
Blog About Us Contact Us

XML to JSON Converter

Convert XML files into JSON - choose how attributes are represented, pick which element becomes the JSON root, output pretty-printed or compact JSON, and handle non-UTF-8 encodings. Invalid XML is flagged with a clear, readable error. Everything runs locally in your browser.

Your XML files are never uploaded. Parsing and the JSON file are both generated locally in your browser - nothing is sent to a server.

Drop XML files here

or

XML

File Nodes Size

What This Tool Does

The XML to JSON Converter turns an XML document into clean JSON you can feed into a JavaScript app, a REST API, or any pipeline that expects JSON instead of markup. It parses your XML with the browser's own XML parser, converts elements and attributes into a JSON structure using rules you control, and shows you a live preview before you download anything.

How to Convert XML to JSON

  1. Upload: Drop one or more .xml files onto the drop zone, or click browse files.
  2. Check for errors: If a file isn't well-formed XML, a plain-language error appears instead of a preview, naming the problem and, when the browser reports it, the line and column.
  3. Set encoding: Leave it on Auto-detect to read the encoding from the XML declaration, or pick a specific encoding like ISO-8859-1 if your file doesn't declare one correctly.
  4. Choose attribute handling: Decide whether attributes become prefixed keys, a grouped @attributes object, plain merged keys, or are dropped entirely.
  5. Pick the JSON root: Use the document root as-is, or select a repeated child element (like <item> in a list) to become the JSON root instead.
  6. Choose output format: Pretty-printed JSON with your choice of indent width, or a compact, minified single line.
  7. Review the preview: Scroll the JSON preview to confirm the structure looks right.
  8. Convert and download: Click Convert, then download each JSON file individually or as a ZIP.

Attribute Handling Options

XML attributes don't have a single obvious JSON equivalent, so the tool gives you four ways to handle them. Prefix keys turns an attribute like id="42" into "@_id": "42" alongside the element's other fields - the convention used by many XML-JSON libraries. Group under @attributes nests all of an element's attributes inside their own @attributes object, keeping them visually separate from child elements. Merge with elements writes attributes as plain keys with no prefix, which is simplest but can collide with child element names. Ignore attributes drops them entirely, useful when only element content matters.

Selectable Root Paths

By default, the JSON output mirrors the XML document exactly, with the root element as the top-level key. If your XML is a list wrapped in a container - like <catalog><product>...</product><product>...</product></catalog> - the tool detects repeated child elements and lets you pick <product> as the JSON root instead, producing a JSON array of products rather than one object wrapping an array.

Pretty vs. Compact Output

Pretty output is indented with your choice of 2 spaces, 4 spaces, or a tab, making the JSON easy to read and diff. Compact output strips all unnecessary whitespace into a single minified line, useful when file size matters or the JSON is only ever consumed by code.

Encoding Support

Not every XML file is UTF-8. With Auto-detect, the tool reads the encoding attribute from the XML declaration (<?xml version="1.0" encoding="ISO-8859-1"?>) and decodes the file accordingly. If a file's declared encoding is wrong or missing, you can override it manually - UTF-8, UTF-16 LE, ISO-8859-1, and Windows-1252 are supported.

XML Validation

Invalid XML is caught before anything else runs, using the browser's built-in XML parser. Instead of a cryptic parser exception, you get a readable message describing what's wrong, so you know where to look in your source file.

Batch Conversion

Drop multiple files at once. Each gets its own row showing its converted node count and output size. Download files individually as they finish, or grab everything at once as a ZIP.

Privacy & Security

Your XML file never leaves your device. Parsing, converting, and the JSON file itself are all generated entirely inside your browser - no files are uploaded to any server, no account is needed, and there are no usage limits.

Frequently Asked Questions

What happens to XML text content mixed with child elements?

When an element has both text and child elements (mixed content), the text is stored under a dedicated key - #text by default, or a key you choose - alongside the child elements.

Are CDATA sections supported?

Yes. CDATA content is treated the same as regular text content and included in the element's text or value.

What if an element repeats multiple times under the same parent?

Repeated sibling elements with the same tag name are automatically collected into a JSON array, matching how most XML-to-JSON conventions handle repeated nodes.

Is there a file size limit?

No artificial limit - the practical limit is your device's memory. The live preview shows the first 20,000 characters of the generated JSON for very large documents, but the full JSON is still included in the downloaded file.

Can I convert multiple XML files at once?

Yes. Drop as many files as you like, convert them into separate JSON files, and download them individually or as a ZIP.

34 views