How to use the converter
- Choose the direction: JSON → YAML or YAML → JSON.
- Paste your file or press Sample (a small service definition in each format).
- Pick 2 or 4 spaces of indentation.
- Read any error shown with its line number, fix it and the output updates instantly.
- Copy or download
data.yamlordata.json.
How it works
JSON → YAML. Objects become key: value lines, arrays become - item lines, and nested structures are indented. Multi-line strings use the literal block style (|), so scripts and certificates stay readable. Empty objects and arrays are written as {} and []. Every string is checked against YAML’s rules and quoted only when necessary. Plain is preferred, then single quotes, then double quotes when escapes are needed.
YAML → JSON. The parser reads indentation to build mappings and sequences, accepts flow collections such as [80, 443] and {ssl: true}, removes comments outside quotes, and applies YAML 1.2 core-schema typing: true/false, null/~, integers, floats and hex/octal numbers. Everything else is a string.
Worked examples
Example 1: a container definition
Load the JSON sample. The environment value "false" and the version "1.10" stay quoted in YAML. Without quotes they would become a boolean and the number 1.1, a classic source of broken deployments.
Example 2: Docker Compose to JSON
Load the YAML sample. Port mappings like "80:80" are quoted strings, DEBUG: false becomes a JSON boolean, the inline volume list becomes an array and db-data: {} becomes an empty object. Comments are dropped because JSON has no comments.
Example 3: Kubernetes manifests
Paste a file with a Deployment and a Service separated by ---. The result is a JSON array with two objects, ready for tools that expect JSON input.
YAML pitfalls the converter avoids
- The “Norway problem”. Country code
NOwas read as false by YAML 1.1 parsers. Strings like yes, no, on and off are always quoted in the output. - Version numbers.
1.10and1.1are different versions but the same number. Quoting keeps the zero. - Colons and hashes.
note: see: belowandcolor: #fffneed quotes; the converter adds them.
Common mistakes
- Tabs for indentation. YAML forbids tabs; the converter tells you the line.
- Inconsistent indentation. A key indented one space too far is an error, not a nested key.
- Expecting comments in JSON. They can’t be represented; keep the YAML as your source if comments matter.
- Anchors and aliases. Expand them first (many YAML tools can), then convert.