About YAML to JSON Converter
Turn a Kubernetes manifest, a CI pipeline or an OpenAPI file into JSON for a script or an API, or turn a JSON response into YAML that is easier to read and edit. The swap button reverses the direction, and a syntax error is reported with its line and column instead of a blank result.
Values are read by the YAML 1.2 rules, so words like yes and off stay text and 1.10 is a number. Anything JSON cannot hold exactly, such as .nan or an integer longer than 2^53, is pointed out rather than changed in silence.
How it works
- The input is parsed as YAML 1.2 with the core schema. JSON is valid YAML, so either can be pasted without choosing first.
- Converting to JSON expands anchors and aliases in place and applies << merge keys. A file with several documents separated by --- becomes a JSON array with one item per document.
- Converting to YAML writes plain block style with quotes only where a value would otherwise change meaning, such as the string "yes" or "1.0". Choose "Keep original style" to keep the quotes, flow lists, block text and anchors you wrote, re-indented.
- Aliases are counted before anything is expanded, so a file built to expand into billions of values, or an anchor that refers to itself, is refused instead of freezing the page.
Questions
Are comments kept?
No. JSON has no comments, and converting rebuilds the YAML from its data, so comments are not carried over in either direction. The result says so when the input looked as if it had some.
Why is "yes" still a string in my JSON?
YAML 1.2, the current version, only treats true and false as booleans. The older 1.1 rules also turned yes, no, on and off into booleans, which surprised many people. This tool follows 1.2.
What happens to dates?
They stay as text, exactly as written, because the YAML 1.2 core schema has no date type and JSON has none either.
Is there a size limit?
The input can be up to 5 MB, and once aliases are expanded the data may hold up to a million values nested at most 1,000 levels deep. The parser accepts up to 500 levels of nesting as written.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.