When to convert JSON to YAML
You convert JSON to YAML when you want a human to edit it. API responses, database dumps, and tool exports all default to JSON because every parser handles it. But config files - Kubernetes manifests, GitHub Actions, Docker Compose, Helm values, OpenAPI specs - usually live as YAML so engineers can scan and edit them quickly.
What the converter does
- Indentation - choose 2 spaces (the YAML community default and what Kubernetes uses) or 4 spaces.
- Key sorting - alphabetize map keys at every level for diff-friendly output.
- Multiline strings - long strings with newlines are emitted as literal block scalars (
|) for readability. - Type fidelity - JSON booleans, numbers, and null map to native YAML scalars without quoting.
FAQs
How do I convert JSON to YAML?
Paste your JSON in the left panel and the equivalent YAML appears on the right instantly. Pick 2 or 4 space indentation, optionally sort keys, then copy the YAML or download it as a .yaml file.
What indentation options are available?
You can choose 2 or 4 space indentation. 2 spaces is the YAML community default, used by Kubernetes, GitHub Actions, and Docker Compose. 4 spaces is common in Ansible and some style guides.
Can I sort keys alphabetically?
Yes. Toggle the Sort keys option to alphabetize map keys at every nesting level. This produces deterministic output, which makes diffs cleaner in version control.
How are JSON strings with newlines converted?
Multi-line strings are emitted as YAML literal block scalars (|) so the source remains readable. Short strings stay on a single line.
Can I convert JSON files larger than a few hundred KB?
Yes. The converter handles up to 5 MB. For larger files, split the JSON into smaller payloads or run the conversion in your build pipeline.
Does the converter preserve number precision?
JSON numbers are converted to YAML scalars without modification. Numbers that exceed JavaScript's safe integer range (greater than 2^53 - 1) may lose precision because they pass through native JSON parsing.
Is my JSON data sent to a server?
No. Conversion happens entirely in your browser, so your data never leaves your device. The tool is safe for sensitive payloads, internal config, and proprietary infrastructure files.
How does the converter handle null values?
JSON null becomes YAML null. The output uses the explicit null keyword rather than the tilde ~ shortcut for maximum clarity.
Can I convert JSON to YML?
Yes. .yml and .yaml are the same format - the extension is just shorter. Use this converter the same way and rename the downloaded file if your tooling requires .yml.
What if my JSON is invalid?
The converter shows the line and approximate column where the JSON parser failed, along with the underlying error message from the JavaScript engine.