Skip to main content
CalcChef

JSON to YAML

Convert JSON to YAML in block or flow style. Text such as yes or 017 is quoted so it stays a string, and a JSON error shows its line and column. How it works

Use the JSON to YAML

Runs in your browser; nothing is uploaded or saved. Limit: 100,000 characters. Numbers are read as 64-bit floats, so whole numbers beyond 9,007,199,254,740,991 are flagged.

YAML Output
name: John
age: 30
active: true
tags:
  - dev
  - ops

About the JSON to YAML

JSON to YAML conversion turns {"name": "John", "age": 30} into two lines, name: John and age: 30: braces and most quotes go, and nesting becomes indentation. Strings that a YAML reader would take for another type, such as "yes", "017" or "2024-01-15", keep quotes in the YAML so they stay strings.

How JSON values come out in YAML

JSONYAML output
{"a":"yes"}a: 'yes'
{"a":"no"}a: 'no'
{"a":"on"}a: 'on'
{"a":"true"}a: 'true'
{"a":"null"}a: 'null'
{"a":"123"}a: '123'
{"a":"017"}a: '017'
{"a":"2024-01-15"}a: '2024-01-15'
{"a":""}a: ''
{"n":1}'n': 1
{"a":[]}a: []
{"a":1.0}a: 1
{"a":9007199254740993}a: 9007199254740992
{"a":1e999}a: .inf

Output with the default options, without the final line break. The last three rows change the value: JSON.parse reads 1.0 as 1, and the last two get a warning, for a whole number beyond 9,007,199,254,740,991 and for a number too large for a 64-bit float.

Frequently asked questions

Why are some values quoted in the YAML?
Without quotes a YAML reader would turn them into another type: 123 into a number, yes into a boolean under YAML 1.1, 2024-01-15 into a date in readers that follow YAML 1.1. The quotes keep them strings, so the YAML reads back as the same JSON.
What is the difference between block and flow style?
Block style puts each key on its own line and nests by indentation, the usual look of config files. Flow style writes everything on one line in braces and brackets: the example JSON becomes {name: John, age: 30, active: true, tags: [dev, ops]}.
Why does my JSON give an error?
The first problem is reported with its line and column. Comments and trailing commas are frequent causes: they are not part of JSON, so {"a":1,} is an error.
Are long numbers and IDs kept?
Only up to 9,007,199,254,740,991, the largest whole number a 64-bit float holds exactly. 9007199254740993 becomes 9007199254740992, and the converter lists it in a warning. Put such values in quotes in the JSON.
Why is my key on quoted as 'on'?
YAML 1.1 reads on, off, y, n, yes and no (in any of their listed capitalizations) as booleans, so the converter quotes them, even as keys: {"on": {"push": null}} becomes 'on': with push: null under it. A quoted 'on' is still the plain string on, which is the key a GitHub Actions workflow uses, so the file reads back the same.
Is my JSON uploaded or saved?
No. The conversion runs in your browser, an uploaded .json file is read there too, and the JSON is not saved; reloading the page brings back the example.

Related Tools

View all tools