Nested object with an array and a null
Input
{"name":"John","age":30,"tags":["a","b"],"meta":null}Output
name: John
age: 30
tags:
- a
- b
meta: nullBraces and commas disappear; the array becomes a hyphenated block.
Further reading
YAML can represent the objects, arrays, strings, numbers, booleans and null values produced by parsing JSON. This converter parses with JSON.parse and emits YAML 1.2; duplicate keys and numeric precision can already be lost during parsing. What changes is the syntax: non-empty collections normally use indentation and hyphens rather than braces, brackets and commas.
The usual reason to convert is configuration. Kubernetes manifests, GitHub Actions workflows, Docker Compose files and Ansible playbooks all expect YAML, while APIs and code tend to produce JSON. YAML also supports comments, which JSON does not, so converting is often the first step before documenting a config by hand.
Each example below is executed against this tool by the test suite, so what you see is what the tool actually produces.
Input
{"name":"John","age":30,"tags":["a","b"],"meta":null}Output
name: John
age: 30
tags:
- a
- b
meta: nullBraces and commas disappear; the array becomes a hyphenated block.
Input
{"zip":"01234","flag":"true","version":"1.0"}Output
zip: "01234"
flag: "true"
version: "1.0"Each value is quoted so it stays a string. Without quotes, a YAML 1.2 core-schema parser would read these as 1234, a boolean and a float.
The details that decide whether a conversion is correct, and where information can be lost without any error being raised.
Turn a single YAML document into JSON, with limits on what carries over.
Indent and beautify JSON, with syntax error locations when available.
Turn JSON into TOML for Cargo, pyproject and similar config files.
Migrate a YAML config to TOML.
Turn JSON into well-formed XML with a configurable root element.