What is JSON to YAML conversion?
JSON is compact and API-native; YAML is human-authored config. Converting turns machine output (API responses, generated manifests) into the readable, comment-friendly format that DevOps tooling expects. The tricky part is knowing which strings to quote so they don't get coerced (the “Norway Problem” in reverse), and that's handled automatically.
Edge cases & gotchas
- Auto-quoting triggers: boolean-like strings (
yes/no/on/off), numeric-looking strings ("1.10", IDs), leading/trailing whitespace, and special chars (#,&,*,@,:). - Norway Problem in reverse: a string
"NO"must stay quoted or it reads back asfalse. - Multiline: literal
|preserves newlines vs folded>collapses them. - Null: emitted as
null(or~). - Indentation: 2-space, no tabs. YAML forbids tabs.
- Key order: preserved from JSON insertion order.
When strings get quoted
| Trigger | Example | Why |
|---|---|---|
| Boolean-like | no, on | avoid coercion to bool |
| Numeric-like | 1.10, 01234 | keep as string |
| Special char | key: value #1 | : / # ambiguous |
| Leading/trailing space | " x " | preserved literally |
How to use
- Paste JSON into the Input pane, upload, or load text.
- The repair-aware parser tolerates trailing commas and minor errors on input.
- Pick indentation (2-space is the Kubernetes convention).
- Convert: js-yaml emits YAML, auto-quoting ambiguous strings.
- Copy the result or download it as
.yaml.
Examples
Object → key-value YAML
{ "name": "api", "port": 8080, "ssl": true }name: api port: 8080 ssl: true
Multiline string → block scalar
{ "description": "Line 1\nLine 2\nLine 3" }description: |- Line 1 Line 2 Line 3
Coercion-safe quoting
{ "version": "1.10", "enabled": "no", "note": "key: value #1" }version: "1.10" enabled: "no" note: 'key: value #1'
FAQ
Why convert JSON to YAML?
YAML is more readable for config and is the native format for Kubernetes, Helm, Ansible, and CI pipelines.
Is JSON valid YAML?
Yes: YAML is a superset of JSON, but converting produces the readable, indented style people expect.
How are multiline strings handled?
Strings with \n become literal block scalars (|), preserving line breaks.
Why did my string get quoted?
To prevent coercion. Values that look like numbers or booleans, or contain :, #, &, *, or leading zeros, are quoted.
How do I convert JSON to YAML in CLI or Python?
yq -P (CLI) or yaml.safe_dump(json.load(...)) (Python).
Is my data uploaded?
No. js-yaml runs in your browser; verify zero requests in DevTools. Need the reverse trip? Use YAML to JSON.