Developer Tools

JSON / YAML / XML Converter

Convert between JSON, YAML and supported XML in your browser. Choose compact or indented output, swap formats and copy results. Review the XML mapping limits before use.

Input
Output
YAML → JSON

0 / 200,000 UTF-16 code units

Output (JSON)
Enter data to see the conversion result.
XML conversion rules

• XML attributes become JSON/YAML keys prefixed with @, such as @id. In the reverse direction, attribute values must be strings, numbers or booleans.

• Text next to child elements is stored in #text. Repeated child elements with the same name become an array.

• XML text and attributes become strings. Original number and boolean types are not restored.

• Empty arrays, empty objects and null become empty elements. A one-item array cannot be distinguished from a single value. Nested arrays are rejected.

• One ordinary top-level key with a non-array value becomes the root element name. Array-valued keys, multiple keys and objects containing only @attributes or #text are wrapped in root. A root array uses root/item.

• Comments, formatting-only whitespace between child elements, mixed-content order and ordering across different child names are lost. Explicit whitespace from character references or CDATA and leading/trailing whitespace in leaf elements are preserved.

• DOCTYPE, ENTITY declarations, processing instructions, namespace prefixes (colons in names), invalid XML names and characters outside XML 1.0 are rejected. Reserved XML namespace URIs cannot be used as the default xmlns namespace.

About JSON / YAML / XML Converter

Convert data between JSON, YAML and XML

Choose an input and output format to convert in any of the six directions. JSON is common in APIs, YAML in configuration files, and XML in structured documents. This tool converts supported data structures; it does not validate an API contract, application configuration or XML schema.

Processing takes place in your browser. The conversion feature does not upload, save or reuse your input. Shared page resources, analytics and advertising may still use the network.

Supported values and limits

The tool uses eemeli/yaml with YAML 1.2 support and a limited XML 1.0 parser. Select compact output or indentation of two or four spaces. Swap uses a successful result as the new input; an invalid draft is retained when formats change.

Input and output are each limited to 200,000 UTF-16 code units, nesting depth to 64, and data to 50,000 values. Some characters, including many emoji, count as two code units. Circular aliases, unsupported YAML tags, non-string YAML keys and duplicate JSON keys are rejected. Aliases are also subject to the parser's expansion limit.

Numbers whose decimal value or sign would change during conversion are rejected, as are non-finite numbers and integers outside JavaScript's safe range. This is not an arbitrary-precision converter. Use quoted strings when the exact representation is part of the data, such as an identifier.

How XML maps to JSON and YAML

Attributes become keys such as @id, mixed text is stored in #text, and repeated children with the same name become an array. XML text and attributes become strings: number and boolean types are not restored. In the reverse direction, attributes must be strings, numbers or booleans.

Empty arrays, empty objects and null become empty elements. A one-item array cannot be distinguished from a single value. Nested arrays are rejected. One ordinary top-level key with a non-array value names the root element; array-valued keys, multiple keys and objects containing only @attributes or #text are wrapped in root. A root array becomes root/item.

Comments, formatting-only whitespace between child elements, mixed-content order and ordering across different child names are lost. Whitespace explicitly represented by character references or CDATA and leading/trailing whitespace in leaf elements are preserved. Indentation is not added inside mixed text.

DOCTYPE, ENTITY declarations, processing instructions, namespace prefixes and names or characters outside the supported XML 1.0 rules are rejected. Reserved XML namespace URIs cannot be used as the default xmlns namespace. Namespace-prefixed SOAP documents are therefore outside this tool's scope. Inspect converted data before using it elsewhere.

Frequently asked questions

Q. Are comments preserved?
YAML comments are discarded during conversion to JSON or XML. XML comments are discarded when converting to JSON or YAML.
Q. How are XML attributes represented?
An attribute becomes an @-prefixed key. For example, <user id="1"/> becomes {"user":{"@id":"1"}}. The reverse mapping uses the same convention for string, number or boolean attribute values.
Q. Can I use YAML anchors and aliases?
Yes, if the references are non-circular and remain within parser expansion and data limits. Special values such as Map, Set, binary and unknown tags are not supported.
Q. Can I convert large files?
Input and output are each limited to 200,000 UTF-16 code units, with nesting depth up to 64 and at most 50,000 values. Exceeding a limit produces an error instead of partial output.
Q. Is conversion through XML lossless?
No. XML does not preserve original number or boolean types, empty collection distinctions, one-item arrays or mixed-content order in this mapping. The on-page XML rules explain the supported subset.
Q. What if copying does not finish?
After ten seconds, a warning explains that copying is still unconfirmed. The pending native request cannot be cancelled and may later overwrite the clipboard. Avoid other copy operations until it finishes. If it reports a failure, you can select the result and copy it manually.

Sources and specifications

Related tools

Questions or feedback? Contact NanToo

Rate this tool
—(0 ratings)