JSON to YAML Converter
Convert JSON to YAML and YAML back to JSON for Kubernetes manifests, CI files and configs.
How to use this tool
Steps for using the JSON to YAML.
- Pick a direction: JSON → YAML or YAML → JSON. Paste your input, click Upload file (a
.yaml/.ymlor.jsonfile sets the direction for you), or click Sample. The output updates as you type. - For JSON → YAML, choose the Indent, how Strings are quoted, and toggle YAML 1.1 safe (keep it on unless every consumer uses YAML 1.2), Sort keys and the
---marker. - For YAML → JSON, choose 2 or 4 spaces or Minified, Sort keys, and whether several
---documents become a JSON array or JSON Lines. - Errors show the line and column with an excerpt; click Go to line to jump there. If the input looks like the other format, a banner offers to switch direction.
- Click the round arrow button to swap direction and convert the output back, then Copy, Download or Expand the result. The status bar shows the number of keys, array items, nesting depth and the size change.
Example
JSON to YAML
{"service": "api", "replicas": 2, "debug": false, "flag": "on", "hosts": ["a.example.com", "b.example.com"]}service: api
replicas: 2
debug: false
flag: "on"
hosts:
- a.example.com
- b.example.comCommon use cases
- Turning JSON from
kubectl get -o jsonor an API into a readable Kubernetes or Helm values file. - Converting GitHub Actions, GitLab CI or Docker Compose YAML to JSON to inspect it or process it with
jq. - Writing configuration in YAML while generating the JSON version a program expects.
- Checking how a YAML 1.2 parser interprets ambiguous values such as
yes,onor0123. - Splitting a multi-document YAML file into a JSON array for scripting.
How JSON and YAML conversion works
YAML 1.2 is a superset of JSON: every JSON document is valid YAML, and YAML adds indentation-based structure, comments, multi-line strings, anchors and multiple documents per file. Converting JSON to YAML parses the JSON strictly and writes block-style YAML with one key per line and list items marked with -. Strings that would be read back as another type — "true", "123", "null", or text containing : or starting with # — are quoted, multi-line strings become | block scalars, and long lines are never folded, so the data round-trips exactly.
The Quote YAML 1.1 booleans option exists because of the "Norway problem". YAML 1.1, still used by PyYAML, older Ruby and many Kubernetes-adjacent tools, reads unquoted yes, no, on, off, y and n as booleans, so the country code NO can turn into false. With the option on, those strings are quoted (flag: "on"). The output is still valid YAML 1.2, so leaving it on is the safe default.
Converting YAML to JSON uses YAML 1.2 rules, so yes and on stay strings, as in the example above. Anchors and aliases (&base / *base) are expanded into copies, comments are dropped because JSON has no comments, and .nan / .inf become null with a warning because JSON cannot represent them. Duplicate keys are reported as errors rather than silently keeping one value. Alias expansion is capped to protect your browser from "billion laughs" documents.
A YAML file can contain several documents separated by ---, as in Kubernetes manifests that bundle a Deployment and a Service. JSON has no equivalent, so when there is more than one document the result is a JSON array with one element per document, and the tool tells you it did this. A single document converts to a single JSON value.
Limitations
- Comments in YAML input are not preserved in JSON, and JSON → YAML output contains no comments.
- Custom tags such as
!Ref(AWS CloudFormation) or!reference(GitLab) are not resolved: the tag is dropped with a warning and the underlying value is kept, so!Ref BucketNamebecomes the string"BucketName". - Binary (
!!binary) values have no JSON equivalent and are not converted meaningfully. - For checking YAML without converting, use the YAML Validator. Input is limited to 2 million characters.
Frequently asked questions
Why is "on" quoted in my YAML output?
YAML 1.1 parsers read unquoted on, off, yes, no, y and n as booleans. Quoting keeps them strings in every parser. Turn off Quote YAML 1.1 booleans if you prefer plain output and only use YAML 1.2 tools.
What happens to multiple YAML documents?
When the input contains more than one document separated by ---, the JSON output is an array with one item per document, in order, and an info message says how many were found.
Are YAML anchors and aliases supported?
Yes. Aliases are expanded into full copies in the JSON output, since JSON has no references. Extremely repetitive alias use is rejected to prevent memory exhaustion.
Does key order survive the conversion?
Yes. Keys are written in the order they appear in the input, in both directions.
Is my configuration sent to a server?
No. Conversion runs entirely in your browser, which makes it safe for manifests and CI files that contain internal hostnames or other sensitive values.