Navigation

Convert JSON to XML

Transform JSON data into well-formed XML for integration with legacy systems, SOAP APIs, and configuration files.

Last updated:

XML remains a critical format in enterprise environments, SOAP APIs, configuration systems, and document interchange standards. DataLensia lets you convert JSON to valid XML instantly.

๐Ÿšฉ The Problem

You have a JSON API response that you need to import into a system that only accepts XML:

{
  "catalog": {
    "book": [
      {"id": "1", "title": "Clean Code", "author": "Robert Martin", "year": 2008},
      {"id": "2", "title": "The Pragmatic Programmer", "author": "David Thomas", "year": 1999}
    ]
  }
}

You need valid XML output:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <catalog>
    <book>
      <id>1</id>
      <title>Clean Code</title>
      <author>Robert Martin</author>
      <year>2008</year>
    </book>
    <book>
      <id>2</id>
      <title>The Pragmatic Programmer</title>
      <author>David Thomas</author>
      <year>1999</year>
    </book>
  </catalog>
</root>

๐Ÿ› ๏ธ How to Convert

  1. Open the JSON Convert tool.
  2. Paste your JSON into the editor (or upload a file).
  3. Select XML from the Config category in the format grid.
  4. Preview the generated XML instantly in the output panel.
  5. Copy the result or click Download to save as a .xml file.

โš™๏ธ Conversion Rules

DataLensia applies the following rules when converting JSON to XML:

JSON StructureXML Equivalent
Object keysXML element names
String/Number valuesText content inside elements
Boolean valuestrue / false text content
Null valuesEmpty element or xsi:nil="true"
ArraysRepeated elements with the same tag name
Nested objectsNested XML elements

๐Ÿ’ก Use Cases

  • Legacy system integration: Many enterprise systems (SAP, Oracle) use XML for data exchange.
  • SOAP APIs: SOAP web services require XML request and response bodies.
  • RSS/Atom feeds: Publishing content in RSS requires XML formatting.
  • Android resources: Android strings.xml and layout files are XML-based.
  • Configuration files: Maven pom.xml, Spring configs, .NET app.config.

โš ๏ธ Things to Keep in Mind

  • Key naming: JSON keys that contain spaces or special characters may not produce valid XML element names. Use the Transform Builder to rename keys before converting.
  • Root element: DataLensia wraps the output in a <root> element if the source JSON doesn't have a single top-level key.
  • Arrays: Array items are repeated elements โ€” this is the standard XML representation of collections.

๐Ÿ”„ Combined Workflow

  1. Fetch โ†’ Use a workspace with API Fetch to pull live JSON from an endpoint.
  2. Transform โ†’ Rename keys to be XML-friendly (remove spaces, use camelCase).
  3. Convert โ†’ Export as XML.
  4. Download โ†’ Save the .xml file for import into your target system.

๐Ÿš€ Try it now

Paste your JSON into the Convert Tool and select XML to get a well-formed XML document instantly.