YAML JSON XML Converter

Convert YAML, JSON and XML in any direction, with line-numbered error messages

From
To
14 lines

Runs entirely in your browser. Nothing you type or upload is sent to us or stored.

Results are for general guidance. Please check anything important before relying on it. Terms of use

How to Use

  1. Choose what you have under From (YAML, JSON or XML) and what you need under To. The button swaps the direction.
  2. Paste your data into the input box, or tap Open a file to load a .yaml, .json or .xml file. The converted result appears on the right as you type.
  3. If the input has a mistake, the result box turns red and shows the line and column. Tap Show in input to jump to that spot.
  4. Set the Indent (2 or 4 spaces). For XML, choose whether to keep attributes as @keys, whether to detect numbers, and the root element name.
  5. Tap Copy or Download, or Convert back to check the round trip.

YAML, JSON and XML in one place

All three formats store the same kind of structured data: keys and values, lists and nested sections. JSON is what web APIs and JavaScript use. YAML is the easy-to-read, indentation-based format of Kubernetes manifests, Docker Compose files, GitHub Actions workflows and Spring Boot's application.yml. XML is still everywhere in banking and government data exchange, SOAP services, Android layouts, Maven pom.xml files and RSS feeds. This YAML to JSON converter turns any one of them into any other, and checks the syntax along the way.

Worked example

This YAML:

app:
  name: dailytools
  ports:
    - "8080:80"
  env:
    TZ: Asia/Kolkata

becomes this JSON:

{
  "app": {
    "name": "dailytools",
    "ports": [
      "8080:80"
    ],
    "env": {
      "TZ": "Asia/Kolkata"
    }
  }
}

and this XML (the single top-level key app becomes the root element):

<?xml version="1.0" encoding="UTF-8"?>
<app>
  <name>dailytools</name>
  <ports>8080:80</ports>
  <env>
    <TZ>Asia/Kolkata</TZ>
  </env>
</app>

How the formats map

IdeaJSON / YAMLXML
Key and value"city": "Pune"<city>Pune</city>
Attribute"@id": "b1"<book id="b1">
Text beside attributes"#text": "350"<price currency="INR">350</price>
List[ โ€ฆ ] or - itemthe same element repeated
Empty / nullnull<note></note>

XML has no real list type, so an element that appears once becomes a single value and a repeated element becomes a list. If your code expects a list, check the case with only one item. XML also needs exactly one root element. When your JSON has several top-level keys or is a list, the converter wraps it in <root> (you can rename it). Keys that aren't valid XML names, such as first name or 2fa, are renamed to first_name and _2fa, and the tool tells you.

Common errors it catches

  • JSON: a trailing comma before } or ], single quotes instead of double quotes, comments, True instead of true, a missing comma between items, and numbers with leading zeros.
  • YAML: wrong indentation, tabs used for indentation (YAML allows only spaces), an unclosed bracket or quote, and duplicate keys.
  • XML: a tag that is never closed, closing tags in the wrong order, and unescaped & or < in text.

Tips and caveats

  • This tool reads YAML 1.2, where yes, no, on and off are plain text. Some tools, such as Python's PyYAML, follow the older YAML 1.1 and read them as true/false, so the country code NO can turn into false. Quote such values to be safe.
  • JSON numbers longer than 15โ€“16 digits (bank account numbers, some IDs) lose their last digits in JavaScript. The tool warns you about this. Store such numbers as strings.
  • YAML comments are dropped when converting, because JSON and this XML output don't carry them.
  • It all runs in your browser. Config files with passwords or API keys aren't uploaded anywhere.

Frequently Asked Questions

Choose YAML under From and JSON under To, then paste your YAML or open the .yaml file. The JSON appears straight away, and you can copy it or download it as a .json file. If the YAML has an indentation or syntax error, the tool shows the line and column to fix.

Because YAML uses indentation to show nesting. Items at the same level must line up exactly, and only spaces are allowed, not tabs. Check the line shown in the error and the line above it. A key or list item that's one space off is the usual cause.

With 'Keep XML attributes' on, each attribute becomes a key starting with @, for example becomes {"book": {"@id": "b1"}}. If an element has both attributes and text, the text goes under "#text". Converting back to XML turns @keys into attributes again.

Because XML has no list type, so the converter only knows an element is a list when it repeats. One becomes an object and two or more become an array. If your program always expects an array, handle the single-item case in code.

Yes, almost. Nearly every valid JSON document is also valid YAML 1.2, so you can paste JSON with From set to YAML and it will still parse. The reverse isn't true. YAML features like comments, anchors (&), aliases (*) and multiple documents have no JSON equivalent, so aliases are expanded and comments are dropped.

No. Conversion runs in your browser, using JavaScript libraries loaded with the page. Your files and configs, including any passwords or keys inside them, never leave your device.