Tools Viewer

How to Convert JSON to XML Online (and XML to JSON)

Published on August 2, 2026 by Tools Viewer

How to Convert JSON to XML Online (and XML to JSON)
How to Convert JSON to XML Online (and XML to JSON)

Toconvert JSON to XML online, paste a JSON object or array intoJSON Formatter & Converter, choose XML as the output format, and download the result if you need a file. The conversion runs in your browser, the tool is free, and you do not need to create an account.

JSON and XML often describe the same kind of structured data, but they make different trade-offs. JSON is compact and common in modern APIs. XML is still common in older integrations, document feeds, enterprise systems, publishing workflows, and some partner exports. A converter is useful when you need a quick bridge between those formats without rewriting every key, nesting level, and array by hand.

When JSON to XML conversion helps

The most common use case is turning a JSON sample into something an XML-based system can accept for testing. You might have a payload from an API response, a fixture from a bug report, or a small data file from a teammate. Converting it to XML gives you a starting point that keeps the same hierarchy, field names, and values.

Conversion is also helpful in the other direction. If you receive XML from a legacy feed, converting it to JSON can make the structure easier to inspect, validate, format, minify, flatten, compare, or export to CSV, YAML, TypeScript, C#, Java, and other formats. The point is not to replace a carefully designed data contract. It is to make common format-shifting tasks faster while you review the output.

How to convert JSON to XML online

  1. OpenJSON Formatter & Converter.
  2. Paste JSON into the editor, or use Import URL when the remote site allows a browser fetch with CORS.
  3. UseValidateorFormatfirst if you want to confirm the JSON parses cleanly.
  4. ChooseXMLas the output format and run the conversion.
  5. Review the generated XML, make any needed adjustments, then useDownloadto save it.

For XML to JSON, set the input format to XML or leave Auto-detect on, paste the XML, and convert to JSON. Once the data is JSON, you can use the same workspace to format, minify, sort keys, strip null values, parse JSON strings, stringify values, flatten or unflatten objects, inspect the tree, compare documents, and check the size panel.

A good habit is to keep the source JSON visible until the converted XML has been reviewed. Copying the output immediately can hide small mapping choices such as wrapper names, repeated item elements, and empty values. If the XML will be shared with another team, include both the original JSON and the generated XML in your review notes so everyone can see how each field moved across formats.

JSON to XML example

Here is a small JSON order:

json
{
  "order": {
    "id": 1001,
    "customer": {
      "name": "Ada Lovelace",
      "email": "ada.lovelace [at] example.com"
    },
    "items": [
      { "sku": "notebook", "qty": 2 },
      { "sku": "pen", "qty": 5 }
    ],
    "paid": true
  }
}

A typical XML conversion keeps the nesting and values readable:

xml
<order>
  <id>1001</id>
  <customer>
    <name>Ada Lovelace</name>
    <email>ada.lovelace [at] example.com</email>
  </customer>
  <items>
    <item>
      <sku>notebook</sku>
      <qty>2</qty>
    </item>
    <item>
      <sku>pen</sku>
      <qty>5</qty>
    </item>
  </items>
  <paid>true</paid>
</order>

Arrays are the part to inspect most carefully. JSON arrays have a clear syntax, while XML needs repeated elements or a wrapping element. A best-effort converter can choose a practical shape, such as repeateditemelements, but your target system may expect a different element name. Treat the output as a strong draft, then adjust tags or wrappers to match the receiving schema.

Best-effort conversion limits

JSON and XML are not perfect mirrors. JSON has objects, arrays, strings, numbers, booleans, and null. XML has elements, attributes, text nodes, repeated tags, namespaces, comments, and processing instructions. Because the models differ, any automatic converter has to make choices.

  • Attributes vs elements:JSON keys usually become elements, but some XML systems prefer attributes for IDs or metadata.
  • Arrays:repeated XML nodes may need a specific item name expected by your partner or import tool.
  • Null values:XML does not have one universal null representation. You may want to strip nulls before converting.
  • Namespaces:XML namespaces can be important for feeds and documents, and generated XML may need manual namespace cleanup.

That is why Tools Viewer describes these converters as best-effort. They are designed for common objects, arrays, data exchange samples, and inspection tasks. If you are preparing a production feed with a strict XML schema, validate the final XML against that schema after conversion.

Troubleshooting JSON to XML output

If the converter reports an error, check that the input is valid JSON before looking at XML-specific issues. JSON does not allow trailing commas, comments, single-quoted strings, or unquoted keys. A small syntax issue near the top of a document can prevent the entire conversion from running.

If the XML is valid but does not match the target system, compare the generated tags against the schema, sample file, or import instructions from that system. Many XML workflows require exact element names, expected wrappers around arrays, or attributes instead of child elements. Those are business rules outside the JSON document itself, so they usually need a short manual cleanup step after conversion.

If values look surprising, check the JSON types. The string"false"and the booleanfalsemay look similar after conversion, but they can mean different things to a receiving system. The same is true for numbers stored as strings, empty strings, and explicitnullvalues.

Prepare JSON before converting

Clean input produces cleaner output. Start by validating the JSON so trailing commas, single quotes, comments, or unquoted keys do not cause parse errors. The validate JSON online workflow is built into the same page: paste the document, format it, and fix any syntax errors before converting.

If the JSON is hard to read, use Format first. If the payload is too large, check theJSON size calculator panel to compare formatted and minified size. If optional fields are empty, Strip nulls can reduce noise before XML generation. If key order matters to your review process, Sort keys can make two documents easier to compare.

Import URL, files, and privacy

You can paste JSON directly, open a local file through the browser, or use Import URL for a public endpoint. Import URL is a browser fetch from your device to the remote host. It only works when that host allows the request with CORS, and Tools Viewer does not proxy the request for you. If a URL import is blocked, paste the JSON manually or download the source file and open it locally.

Formatting, validation, minifying, XML conversion, tree inspection, size checks, compare, flattening, and downloads run in your browser. The tool is free, no signup is required, and your pasted content stays on your device unless you explicitly fetch something with Import URL or export a file yourself.