Home

Writing & Content

AI Tools27Text Tools25PDF Tools24

Developer & Build

Developer Tools24File Converters9Color & Design18SEO & Web13

Media

Image Tools23Fun & Games27

Everyday

Calculators27Health & Fitness11Utility Tools12Time & Productivity9Lifestyle9
Browse all 258 tools
Guides

ToolWise

Free Online Tools

258+ free online tools for students, developers, designers, and professionals. No signup required. 100% free forever, and most tools run entirely in your browser for total privacy.

Browse by Category

  • AI Tools
  • Text Tools
  • PDF Tools
  • Image Tools
  • File Converters
  • Developer Tools
  • SEO & Web
  • Calculators
  • Color & Design
  • Time & Productivity
  • Lifestyle
  • Health & Fitness
  • Fun & Games
  • Utility Tools
  • All 258Tools →

AI & Text Tools

  • AI Summarizer
  • Grammar Checker
  • Paraphraser
  • Word Counter
  • Case Converter
  • AI Email Writer

Image & PDF Tools

  • PDF Merger
  • PDF Compressor
  • PDF to Word
  • Background Remover
  • Image Compressor
  • Image to Text (OCR)

Calculators & Dev

  • Compound Interest
  • BMI Calculator
  • SIP Calculator
  • Loan EMI Calculator
  • JSON Formatter
  • Regex Tester

Popular Guides

  • 10 Developer Tools
  • SEO Meta Tags Guide
  • Image Compression Guide
  • Secure Passwords Guide
  • Compound Interest Guide
  • JSON Debugging Guide

Company

  • All Tools
  • Topic Hubs
  • All Guides
  • About FreeToolWise
  • Our Founder
  • Editorial Policy
  • Contact

© 2026 FreeToolWise — 258+ Free Online Tools. All rights reserved.

Privacy PolicyTerms of ServiceEditorial PolicyContactX (@ToolWise86)

FreeToolWise offers 258+ free online tools — including an AI summarizer, grammar checker, paraphraser, JSON formatter, word counter, image compressor, background remover, PDF converter, QR code generator, BMI calculator, and many more browser-based utilities for students, writers, and developers. No signup, no usage limits — image, PDF and text tools run entirely in your browser, while our AI tools send your text to our server with the AI provider to generate the result. Each tool page states which one it is.

HomeToolsFile ConvertersFree XML to JSON & JSON to XML Converter

Part of JSON Tools

File ConvertersConvert

Free XML to JSON & JSON to XML Converter

Convert XML to JSON and JSON to XML bidirectionally. Handle attributes, namespaces, repeated elements, and mixed content. 100% client-side.

TA
Tanbir Ahamed·Founder of ToolWise · Software Engineer
Published June 2026

Interactive Tool Workspace

XML JSON

How to Use

  1. 1Choose the conversion direction with the swap button: XML to JSON or JSON to XML.
  2. 2Paste your XML or JSON data, or upload a file directly.
  3. 3Configure options such as array detection and attribute handling.
  4. 4Click Convert to generate the output.
  5. 5Copy the result or download it with the correct file extension.

Features

  • ✓Bidirectional XML to JSON and JSON to XML conversion
  • ✓Real XML parsing using native DOMParser API
  • ✓Smart array detection for repeated elements
  • ✓XML attributes prefixed with @ in JSON output
  • ✓Mixed content preserved as #text
  • ✓CDATA section support
  • ✓Configurable indentation for XML output
  • ✓Upload .xml or .json files directly
  • ✓Statistics showing element and attribute counts
  • ✓Download with correct MIME type and file extension
  • ✓100% client-side processing — no server upload
Comprehensive Guide & Reference

The Complete Guide to Converting Between XML and JSON

Learn why XML-to-JSON is lossy by design, the three conventions for representing attributes and mixed content, and how to pick the convention your downstream tool expects.

1. Why XML-to-JSON Is Always Lossy

XML and JSON have different native concepts. XML has element order, attributes, mixed content (text interleaved with child elements), namespaces, and comments. JSON has neither attributes nor mixed content natively; everything is either a primitive, an array, or an object. Any XML-to-JSON conversion therefore projects extra XML features onto JSON conventions, and choosing the right convention depends on what your downstream tool expects.

The single most important convention choice is how to represent XML attributes. Without a rule, an attribute and a child element with the same name would collide destructively in the resulting JSON object. Establish the convention upfront and document it; that is the only path to clean downstream parsing.

2. The Three Common Conventions for Attributes

The Parker convention simply discards XML attributes and keeps only element text content, producing the smallest JSON. It is useful when attributes carry only redundant metadata. The BadgerFish convention prefixes every attribute with an at-sign so attributes and child elements never collide: an attribute named id becomes a JSON key @id. Text content lives in $ or $t. The GData convention places attributes into a nested $ object and text content into $t, preserving a clean separation.

ToolWise defaults to the GData convention because it integrates well with most frontend data layers, but you can switch the convention in the UI when your downstream parser expects Parker (lossy minimal) or BadgerFish (maximally lossless).

3. Element Order, Namespaces, and Mixed Content

Three structural features deserve special handling. Element order matters when you have multiple children with the same name (the converter produces a JSON array to preserve order). Namespaces are typically preserved verbatim with the original prefix, because flattening them loses information. Mixed content is the hard case: a paragraph of text interleaved with child elements must split the text into chunks that surround each child, otherwise the resulting JSON loses the text content entirely. The converter handles all three so that the round-trip from XML through JSON back to XML reconstructs the original document as closely as possible within the chosen convention.

4. When To Pick Lossy Versus Lossless

Pick the lossy Parker convention when the XML is configuration-shaped and attributes are merely redundant IDs. Pick BadgerFish when you need to round-trip the document through other tools that also expect the full-attribute representation. Pick the GData convention as the safe default for general-purpose API integrations where lossless fidelity matters but the structure should remain simple for frontend consumption.

5. Converting JSON Back to XML

Reversing the conversion requires the same convention the original XML-to-JSON walk used. The BadgerFish convention round-trips a nested JSON object back to the same XML document because each attribute lives in its own key namespace and the textual content stays distinct from child elements. The Parker convention cannot round-trip because attributes were discarded, so the reverse walk has nothing to work with. The GData convention round-trips but reconstructs attributes out of nested namespace keys, which requires the consumer of the JSON to know that convention is in effect.

When your pipeline spans a producer that emits XML and a consumer that wants JSON, document the chosen convention at the API layer and pick BadgerFish or GData rather than Parker so that downstream consumers can convert back if necessary.

Pick the Convention, Keep the Round-Trip

XML-to-JSON conversion is never free, but choosing the right convention upfront makes the round-trip clean enough for everyday data flow. ToolWise Free Online XML to JSON Converter offers all three conventions, supports the reverse direction, and runs entirely in your browser without uploading the document. Paste the XML, pick the convention, copy the JSON.

Real example

Worked example: a simple record

Input
XML: <book><title>Dune</title><author>Frank Herbert</author></book>
Output
→{ "book": { "title": "Dune", "author": "Frank Herbert" } } — element names become keys, text content becomes values.

XML attributes land under a reserved key (commonly "_attributes" or "@attributes"), so check the preview when your tags carry attributes.

Worked example: repeated elements become arrays

Input
XML: <basket><fruit>apple</fruit><fruit>kiwi</fruit></basket>
Output
→{ "basket": { "fruit": [ "apple", "kiwi" ] } } — two same-named siblings collapse into one JSON array.

A single fruit element would stay a plain string — the classic XML-to-JSON gotcha when writing code against both shapes.

Privacy & data handling

This tool runs entirely in your browser. What you enter is processed on your own device using JavaScript and WebAssembly — it is not uploaded to our servers, and there is no account, no signup and no per-use limit. Read our privacy policy.

Frequently Asked Questions

Does this tool convert in both directions?
Yes. Use the swap button to toggle between XML to JSON and JSON to XML. The same interface handles both conversions, so you can iterate quickly without switching pages.
How are XML attributes handled?
By default, XML attributes are prefixed with @ in the JSON output (e.g., id="1" becomes @id:"1"). In JSON to XML mode, @-prefixed properties are converted back to XML attributes.
What about repeated XML elements?
Repeated elements at the same level are automatically collected into arrays. You can control this with the array detection setting: auto (only when repeated or mixed), always, or never.
Can I preserve text content mixed with child elements?
Yes. Text content mixed with child elements is stored under the #text key. When converting back to XML, #text is used as the element content.
How are namespaces handled?
Namespace prefixes are preserved as part of the element name. Full namespace URIs are not resolved to prefixes in this simplified converter.
Is my data secure?
Yes. All parsing happens in your browser using the native DOMParser API. No data is uploaded to any server.

Related Tools

JSON ↔ CSV Converter
JSON ↔ YAML Converter
JSON ↔ TOML Converter
YAML ↔ TOML Converter
CSV ↔ XML Converter
SQL to JSON Converter

Topical Collection

Explore all tools in JSON Tools

View collection

Related Guides

JSON Formatter Guide: Pretty-Print, Minify & Validate