Skip to content

JSON to YAML Converter - Convert JSON to YAML Online

Input JSON
YAML Output

Convert JSON to YAML

Paste JSON on the left and the YAML version appears on the right, ready to copy into a Kubernetes manifest, Docker Compose file or CI workflow. Objects become indented mappings, arrays become - lists, and empty objects and arrays are written as {} and []. The conversion runs in your browser, so configs with secrets or internal hostnames are not uploaded.

Example

{"service":"api","replicas":3,"country":"NO","backup_time":"12:30",
 "debug":false,"ports":[80,443],"motd":"Line one\nLine two","limits":{}}

becomes:

service: api
replicas: 3
country: "NO"
backup_time: "12:30"
debug: false
ports:
  - 80
  - 443
motd: |-
  Line one
  Line two
limits: {}

"NO" and "12:30" are quoted because a YAML 1.1 parser would read them as false and 750. This is the "Norway problem", and it has broken real configs: country lists, version strings and cron-like times are the usual victims.

Things YAML Adds That JSON Lacks

Once converted you can add comments (# like this), which JSON does not allow, and use anchors (&defaults) and aliases (*defaults) to reuse a block instead of repeating it. The converter does not create anchors for repeated data; it writes every value out in full. To check that a hand-edited YAML file still means what you think, paste it into the YAML to JSON converter and look at the result.

Related Tools

Frequently Asked Questions

Why are some of my strings quoted in the YAML?
Because unquoted they would be read as something else. YAML 1.2 already turns true, null, 0123 or 1e3 into booleans, nulls and numbers. Older YAML 1.1 parsers such as PyYAML go further: yes, no, on, off, y and n become booleans, 12:30 becomes the number 750, and 2024-01-05 becomes a date. The converter quotes all of these, so a country code "NO" stays a string everywhere.
Is the output valid YAML 1.2?
Yes. It is generated with the yaml library in YAML 1.2 mode, with 2-space indentation and no line wrapping. The extra quoting for YAML 1.1 values is still valid 1.2, so the file reads the same in Kubernetes, Docker Compose, GitHub Actions, Ansible or PyYAML.
How are multi-line strings written?
As literal block scalars with |-, which keeps line breaks exactly and drops the final newline. A JSON string "Line one\nLine two" becomes motd: |- followed by the two lines indented underneath.
Does the conversion keep number formatting?
Values are kept, spelling is not always. Large integers such as 64-bit IDs stay exact, but 1.0 is written as 1 and 1e3 as 1000, because the JSON is parsed before it is written out as YAML. If a value must keep its exact spelling, make it a string in the JSON.
Can I convert YAML back to JSON?
Yes, with the YAML to JSON converter. Comments you add to the YAML will be lost on the way back, since JSON has no comments.