JSON is a data tree of objects, lists, numbers and strings. YAML is the same data as JSON, written for people to read and edit. Python sits between the two, and this page says exactly what happens to a JSON file on the way to becoming a YAML one.
What runs when a JSON file becomes YAML
Python and its standard library, on a machine we rent and watch. Your JSON file is uploaded once, Python runs once, the YAML comes back, and neither file is kept. JSON to YAML is one of the 3649 pairs that engine was probed on with a real file, which is why it has a page here and why the pairs the probe could not prove do not.
What survives from the JSON into the YAML
Every value, and the names you gave them. This pair reads your JSON into memory and writes it back out as YAML: no field is renamed, reordered into something else or quietly dropped. The engine reads its own output back and counts the elements, and refuses the result if the count moved.
The whole structure, at any depth. JSON and YAML describe the same shapes, so nesting, lists, numbers, booleans and null all cross over as themselves. This is the one part of the family where nothing at all is at risk.
What JSON to YAML costs you
The formatting, which is all there was to lose. A JSON has no comments to drop, the format having none: the conversion reads the data and writes it afresh, so indentation and line breaks are the writer's choice and not yours. Every value is untouched.
Where JSON and YAML files come from
YAML. Written in 2001 to be readable where JSON is merely parseable. It holds exactly the same shapes, so the conversion between the two loses nothing. It is what most tools reach for when a human will have to open the file: Kubernetes, GitHub Actions, Docker Compose.
If a model is going to read the YAML
Structure is what survives from the JSON file, and structure is what a model needs. JSON in, YAML out, with the heading tree intact instead of flattened into one long paragraph.
JSON to YAML, measured rather than promised
Running JSON to YAML against the real engine with a real file, Python wrote 68 bytes of YAML in under a tenth of a second, machine otherwise idle. That is one JSON file on one day and not an average, which is why the number is given together with the file that produced it.
The JSON to YAML verdict was reached by parsing the data back and finding a witness word, meaning the output was read back and recognised. Which check was used matters, because they do not all prove the same thing, and a status code of 200 proves nothing whatsoever about whether the YAML file has anything inside it.
The same JSON file, sent somewhere else
Other outputs the probe measured out of a JSON file, so the cost of choosing YAML can be read against something. Sizes do not compare across engines, because each family was probed with its own JSON witness file.
JSON to MD: 266 bytes in under a tenth of a second, verified by a pandoc round trip.
JSON to DOCX: 10,106 bytes in 0.1 seconds, verified by a pandoc round trip.
JSON to EPUB: 5,035 bytes in 0.1 seconds, verified by a pandoc round trip.
JSON to TXT: 264 bytes in under a tenth of a second, verified by reading the text back.
JSON to HTML: 4,018 bytes in 0.1 seconds, verified by a pandoc round trip.
JSON to RTF: 687 bytes in 0.1 seconds, verified by a pandoc round trip.
Other ways into YAML, and what they measured
Among the published routes into YAML, JSON is the first largest output of the 2 measured. The witness files differ, so this ranks the probe run and not your document.
CSV to YAML: 68 bytes in under a tenth of a second.
What we will not pretend about JSON to YAML
A JSON file over 25 MB is refused before the upload finishes rather than after it, so you do not wait for a rejection.
A JSON to YAML run that passes 50 seconds is killed, and the Python process is killed with it. A run left behind would sit on one of the machine's two cores until somebody noticed.
Whether this pair works depends on your data and not only on the two formats. A JSON whose shape does not suit YAML is refused with 422 and a message naming what is missing, which is different from "this format is not supported" and is said differently on purpose. The refusal is immediate and costs nothing.
Note on the word JSON, because it means two things here. Converting Markdown or a Word file to JSON gives pandoc's syntax tree, which describes the document. Converting a JSON gives your data. Both are JSON and they are not the same thing; the site picks by source, which is the only way to tell them apart.
XML is not in this family, and it is the obvious absence. It has no evident mapping to this model: attributes against elements, mixed text, significant order. Every conversion would mean inventing a convention, and an invented convention is a trap for whoever reads the file next. The family stays with what translates without arbitrary choices.
One JSON file at a time, chosen in the browser. There is nothing else to set up and nothing else on offer.
JSON to YAML: what people ask
What actually converts my JSON file to YAML?
Python does it, and its standard library, on a machine we rent and watch. Not a browser trick and not somebody else service: the JSON file is uploaded once, Python runs once, the YAML comes back, and neither file is kept afterwards.
How long does JSON to YAML take?
On the file the probe used, Python took under a tenth of a second and wrote 68 bytes of YAML. That is one real measurement on one real JSON file, not an average and not a promise about yours: a larger JSON takes longer, and past 50 seconds the run is stopped.
What do I lose going from JSON to YAML?
The one to know about first: The formatting, which is all there was to lose. A JSON has no comments to drop, the format having none: the conversion reads the data and writes it afresh, so indentation and line breaks are the writer's choice and not yours. Every value is untouched.
Will my comments survive?
No. The conversion reads the data and writes it afresh, so comments and layout are the writer's. The data itself is untouched, at any depth.
Is my data sent anywhere else?
No. It goes to one machine we rent and watch, is read by Python and written back out, and neither file is kept. There is no third-party service in this family and no model reading your data.
Is JSON to YAML free?
There is a free allowance every month, and one JSON to YAML conversion costs half a credit against it. When the allowance runs out the tool says so and stops, rather than quietly handing you a worse YAML.