JSON, YAML, TOML & XML Converter
Convert a document between JSON, YAML, TOML and XML — any direction, formatting preserved, running entirely on your device.
—
What this converter does
JSON, YAML, TOML and XML are four ways of writing the same underlying thing: nested data — objects, lists, strings, numbers and booleans. Each format exists because a different audience needed it. JSON is the lingua franca of APIs and the web. YAML trades punctuation for indentation to make configuration readable to humans. TOML is an explicit, unambiguous config format that has become the default for Rust and Python projects. XML is the elder statesman, still everywhere in enterprise systems and documents. This tool moves a document from any one to any other, in the browser, without a round trip to a server.
The conversion model
Three of the four formats describe exactly the same data model, so converting between JSON, YAML and TOML is lossless: the parser reads the source into an ordinary object and the writer serialises it in the target syntax. XML needs one convention to fit, since markup is not the same as data:
| XML construct | Becomes | Example |
|---|---|---|
| Attribute | a key prefixed with @ | id="1" → "@id": 1 |
| Text content | the #text key | <n>hi</n> → {"#text": "hi"} |
| Repeated children | an array | two <tag> → "tag": ["a", "b"] |
| Single child | a nested object | <address>… → "address": { … } |
Choosing a format
For a REST or GraphQL API, JSON is the right default — it parses identically everywhere and its strictness prevents ambiguity. For a file a person edits by hand, YAML’s lack of punctuation is a real advantage, but its indentation sensitivity is a real hazard. TOML avoids that hazard: it is explicit and cannot be broken by a stray space, which is why cargo, Poetry and many modern tools use it. Reach for XML when something you must talk to already speaks it.
What is intentionally not supported
Full parsers for these formats are enormous, and pulling one in would slow every page on the site. This tool implements the practical subset and says so plainly rather than failing silently: YAML anchors, aliases, tags and multi-document streams are not handled; TOML multi-line strings are not handled; XML namespaces, DTDs and CDATA are not handled. For everyday config and data files — the vast majority of real use — it converts exactly. Anything outside the subset produces an error message rather than a wrong answer.
Frequently asked questions
Which conversions does this tool support?
Any direction between JSON, YAML, TOML and XML — twelve combinations from one set of controls. JSON, YAML and TOML all describe the same kinds of object (maps, lists, strings, numbers, booleans), so the conversion is lossless for that shared shape. XML is a markup language with its own conventions, so its mapping is explained below.
How is XML mapped to the others?
An element’s attributes become keys prefixed with @ (so id="1" becomes "@id"), its text content becomes "#text", and repeated child elements of the same name collapse into an array. A single occurrence stays a scalar or object. This is the same convention used by xml2js and other common converters, so the output is familiar.
Is YAML or JSON better for a config file?
YAML is easier for a human to read and edit — it drops the braces and quotes and allows comments — which is why Kubernetes, GitHub Actions and most CI systems use it. JSON is stricter, unambiguous and universally parsed, which makes it the safer choice for data that is only ever read by machines. Converting between them is exactly what this page is for.
Will my comments survive?
No. Comments are metadata about the file, not part of the data, and none of JSON, YAML, TOML and XML agree on how to represent them in the others. Comments in the input are dropped. Keep your commented source; convert copies.
Does this preserve key order?
Yes. Keys are written out in the order they appear in the input, which matters when you are diffing configuration files by eye.
Is anything sent to a server?
No. All four parsers and writers run entirely in your browser; your data never leaves the page. That matters when the file holds credentials, tokens or customer records.
Go deeper
Longer explanations of the problems this tool solves:
Everything runs in your browser — nothing you type is uploaded.