KickSolve • Free • Private

XML Formatter & XML to JSON

Pretty print or minify XML, spot syntax errors, and convert XML to JSON. Everything runs in your browser and nothing is uploaded.

Format and minifyXML to JSONNever uploaded

How to use XML Formatter & XML to JSON Converter on KickSolve

Three quick steps, no account needed.

Paste or open your XMLPaste XML into the box or open an .xml file. It is checked as you type.
Choose Format, Minify or To JSONFormat adds indentation, Minify strips whitespace and To JSON converts the document to JSON.
Copy or downloadCopy the result or download it as an .xml or .json file.

Why choose KickSolve

Built for speed, privacy and clean results.

Private by designEverything runs in your browser. What you paste or open is never uploaded or stored.
Instant, no signupFree to use with no account, no limits on how often you use it, and no software to install.
Finds syntax errorsInvalid XML is reported with the parser’s message so you can find the broken tag.
Predictable JSON outputAttributes become @name keys, mixed text becomes #text and repeated tags become arrays.

What you can do with XML Formatter & XML to JSON Converter

Everything this tool is good for.

Reading API and feed outputFormat a dense SOAP response, RSS feed or sitemap.
Validating well-formednessCheck that every tag is closed and properly nested.
Config filesTidy Android, Maven or .NET XML configs.
XML to JSON migrationMove data from an XML source into a JSON-based system.
Shrinking XMLStrip whitespace before sending or embedding it.
Debugging integrationsMake payloads readable when two systems disagree.
Sitemaps and feedsCheck structure before publishing.
Learning XMLSee how elements, attributes and text relate.

About XML Formatter & XML to JSON Converter on KickSolve

What it does, how it works and how to get the best results.

What an XML formatter does

It parses your XML and writes it back with consistent indentation, so the hierarchy of elements is visible. Whitespace between tags is normalised, but names, attributes and text are kept. The declaration, comments, CDATA sections and processing instructions are preserved.

Checking for errors

The parser reports the first problem it finds, such as a mismatched closing tag, an unquoted attribute or an unescaped ampersand. Fix it and the message updates immediately. The result is well-formedness checking, not validation against a schema.

How XML becomes JSON

Each element becomes a key under its parent. Attributes are written as keys starting with @, text next to attributes or child elements goes in #text, and a tag that repeats becomes an array. Elements that only contain text become plain strings.

A common gotcha

A tag that appears once is a single value, and the same tag appearing twice is an array. If your code expects an array, handle both cases, or make sure the sample you convert contains the repeated element.

Related tools

After converting, tidy the result with the JSON Formatter, query it with the JSONPath Tester, or switch formats with JSON to YAML.

Worked example: XML to JSON

Attributes, text and a repeated tag.

XML:
<library name="City">
  <book id="1">Dune</book>
  <book id="2">Emma</book>
</library>

JSON:
{
  "library": {
    "@name": "City",
    "book": [
      {"@id": "1", "#text": "Dune"},
      {"@id": "2", "#text": "Emma"}
    ]
  }
}

The repeated book tag became an array, the attributes got an @ prefix and the text went into #text.

XML to JSON mapping

How each part of XML appears in the JSON.

XMLJSON
Attribute id="1"Key "@id": "1"
Element with text onlyA plain string value
Text plus attributes or childrenKey "#text"
Repeated tagAn array of values
Empty elementAn empty string
CDATAText value

Frequently asked questions

Quick answers.

How do I format XML online?

Paste your XML, keep Format selected and choose an indent. The formatted XML appears as you type, and you can copy or download it.

How do I find the error in my XML?

The status line shows the parser’s message. Common causes are mismatched tags, unquoted attributes, unescaped & or < characters and more than one root element.

How does XML to JSON work here?

Attributes become @name keys, text next to attributes or children becomes #text and repeated tags become arrays.

Why is one of my elements not an array?

A tag that appears only once is converted to a single value. Only repeated tags become arrays, so handle both cases in your code.

Does it keep comments and CDATA?

In Format and Minify modes yes. Comments, CDATA sections, processing instructions and the XML declaration are preserved.

Does it validate against an XSD or DTD?

No. It checks that the XML is well-formed, not that it follows a schema.

Can I convert JSON back to XML?

Not on this page. For JSON tidying and validation use the JSON Formatter.

Is my XML uploaded?

No. Parsing and conversion use your browser’s built-in XML parser and nothing is sent to a server.

More free tools from KickSolve

Related free tools. Each one runs in your browser too.