CraftTools

XML ⇄ JSON Converter

Guide: JSON vs YAML vs XML vs CSV: Choosing a Data Format

Nothing you enter or choose here leaves your device. This tool runs in your browser.

How to use

  1. 1Choose XML to JSON or JSON to XML.
  2. 2Paste your data into the input box.
  3. 3Set the attribute prefix and other options if you need to.
  4. 4Click Copy output, or use the output as the next input.

Frequently asked questions

How are XML attributes shown in JSON?

Attributes become keys that start with a prefix, @ by default, such as "@id": 42. Text next to attributes or child elements goes in a "#text" key. Both names can be changed.

How does it decide what is a list?

An element that appears more than once under the same parent becomes a JSON array. A single element becomes a single value, so add a second one to your sample if you expect a list.

Does JSON to XML work with any JSON?

Yes. If the JSON has one top-level key it becomes the root element, otherwise your chosen root name is used. Keys that aren't valid XML names are cleaned up, and arrays turn into repeated elements.

Is my data uploaded?

No. The conversion runs in your browser and nothing is sent to a server.

Read the guides

Learn how this works and how to get the most from it.

Developer

JSON vs YAML vs XML vs CSV: Choosing a Data Format

The strengths and weaknesses of JSON, YAML, XML and CSV, with simple advice on which to use for APIs, config files and spreadsheets.

1 min read

Developer

Turn JSON or XML Into Classes (DTOs) in Java, C# and More

What a DTO is, how generated classes map JSON and XML, and the details to check before you trust a generated model.

1 min read

XML to DTO Generator

Turn XML into Java (JAXB), C#, TypeScript, Kotlin, Python or Go classes.

JSON Formatter & Validator

Prettify, minify and validate JSON, with error line numbers.

YAML ⇄ JSON Converter

Convert YAML to JSON and JSON to YAML with error line numbers.

CSV ⇄ JSON Converter

Convert CSV to JSON and JSON to CSV, with any delimiter.