JSON ↔ YAML converter

Convert between JSON and YAML in either direction, preserving types and key order.

What this does

This converter parses one format into an in-memory data structure and serializes it as the other. JSON is parsed with the native JSON.parse; YAML is parsed with js-yaml using its JSON-compatible schema, which keeps type coercion predictable. Because both formats describe the same underlying model — maps, sequences, strings, numbers, booleans, null — the conversion is lossless for data, though format-only details like comments, blank lines, and quote style are not carried across.

It runs entirely in your browser. Kubernetes manifests, CI pipeline definitions, and application config with secrets in them can be converted here without leaving the page.

When you'd use it

  • Turning a JSON API response into YAML to paste into a config file.
  • Converting a Docker Compose or GitHub Actions YAML file to JSON so a script can read it with a standard parser.
  • Checking whether a hand-written YAML file parses to the structure you expect by viewing it as JSON.
  • Normalising a YAML file's formatting by round-tripping it through the tool.

Worked example

Input (JSON):

{"service":"web","replicas":3,"env":[{"name":"LOG_LEVEL","value":"info"}],"tls":true}

Output (YAML):

service: web
replicas: 3
env:
  - name: LOG_LEVEL
    value: info
tls: true

Converting that YAML back to JSON with 2-space indent returns the original object exactly. Now change value: info to value: yes in the YAML and convert to JSON: you get "value": true, because bare yes is a YAML boolean. Quote it as value: "yes" and it stays the string "yes".

Limits and gotchas

  • Comments and layout are not preserved in either direction.
  • YAML-only types such as !!timestamp, !!binary, and custom tags are not represented in JSON and will error or be stringified.
  • Multi-document YAML (files separated by ---) is not supported; convert one document at a time.
  • Key order is preserved as written. JSON object keys and YAML mapping keys both keep insertion order here.
  • Very deep or very large documents are converted synchronously and will briefly block the tab.
  • This is a syntax converter, not a schema or policy validator — it will happily convert a manifest that your cluster would reject.

Frequently asked questions

Why did my YAML comments disappear?
YAML comments are not part of the parsed data model — they exist only in the source text. Any converter that goes YAML → data → JSON or YAML → data → YAML drops them. If comments matter, keep the original file and treat the converted version as generated.
My string "yes" / "no" / "on" turned into true / false.
That is the YAML 1.1 boolean rule, which treats yes, no, on, off, and y/n as booleans. This tool loads YAML with the JSON-compatible schema to reduce that surprise, but if you are reading YAML produced elsewhere, quote those values ("yes") to keep them as strings.
Numbers like 007 or 1.10 came back different.
YAML and JSON both parse 007 as the integer 7 and 1.10 as the number 1.1 — the leading and trailing zeros are not preserved because they carry no numeric meaning. Values where the exact text matters (version strings, zip codes, phone numbers) must be quoted so they stay strings.
Can it handle YAML anchors and aliases?
On input, yes — anchors (&name) and aliases (*name) are resolved and the referenced data is expanded inline in the JSON output. On output, this tool does not emit anchors; repeated structures are written out in full.