How to convert JSON to YAML
- Paste JSON, for example an API response, a
package.jsonor the output ofkubectl get -o json. - The JSON is validated first; errors are reported with their position.
- Clean YAML appears on the right, with 2-space indentation by default. Long strings are not wrapped, so values stay on one line.
- Copy it or download a
.yamlfile.
When to use YAML
YAML is the standard format for configuration in modern tooling: Kubernetes, Helm, Docker Compose, GitHub Actions, GitLab CI, Ansible, Serverless Framework, OpenAPI and many static site generators. It is easier to read and review than JSON and allows comments. Converting from JSON is the fastest way to turn an example from documentation, an API response or exported resource into a config file you can edit and annotate.
The converter quotes strings that would otherwise be misread as numbers, booleans or dates, so values round-trip safely. Keys keep their original order. Because every JSON document is also valid YAML, the output can be loaded by any YAML 1.2 parser.
Conversion uses the js-yaml library in your browser. Your data is never uploaded.
FAQ
Why are some values quoted in the YAML?
Strings that look like numbers, booleans, dates or null, such as "1.0" or "no", are quoted so they keep their string type when the YAML is read back.
Can I add comments to the output?
Yes. Once converted, you can add # comments anywhere in the YAML. They will not be kept if you convert it back to JSON.
Which indentation should I use?
Two spaces is the common convention for Kubernetes, Compose and CI files. Some teams prefer four for readability.