YAML to JSON

Convert YAML into JSON.

Updated
Loading tool…

Convert YAML into JSON.

How to use YAML to JSON

  1. Paste your YAML into the input box
  2. Let it parse the nested keys, lists, and comments
  3. Copy the converted JSON output
Try next →JSON FormatterFormat, repair and validate JSON.

About YAML to JSON

Paste YAML and get the equivalent JSON, formatted with clean two-space indentation and ready to drop into an API request, a settings file, or a bit of code. It handles the YAML you actually meet day to day — nested keys, lists, quoted strings, comments — so it works just as well on a Docker Compose file, a Kubernetes manifest, an OpenAPI or Swagger spec, or a CloudFormation template written in YAML that some tool now wants as JSON.

A few YAML details are worth knowing. JSON has no place for comments, so they are dropped, and any anchors and aliases are resolved into the real values they point to, since JSON cannot store references. If a file holds more than one document, only the first is converted. Get the indentation wrong — a stray tab, a missing colon — and you will see a plain error rather than broken JSON, which makes it easy to spot where the source YAML is off.

Everything runs in your browser: the YAML is parsed with JavaScript on your own device, so nothing is uploaded to a server, which suits config files that carry private keys or hostnames. It is free, needs no account, and has no limits or watermarks. Need to go the other way and turn JSON back into YAML? Use the JSON to YAML converter instead.

Frequently asked questions

Is this converter free?
Yes. It is free with no account or sign-up, and there are no usage limits or watermarks. Convert as many files as you like.
Is my YAML uploaded anywhere?
No. The conversion runs entirely in your browser, so your YAML never leaves your device. Nothing is sent to or stored on a server, which suits configuration files that hold private values.
How do I convert YAML to JSON?
Paste or type your YAML into the input box and click convert, and the JSON appears alongside it. Copy the result out or download it when you are done. There is nothing to install and no setup.
Can this also convert JSON to YAML?
This page only goes one way, from YAML to JSON. If you have JSON and want YAML, use the separate JSON to YAML converter, which does the reverse and keeps everything in your browser the same way.
Can I convert an OpenAPI or Swagger YAML spec to JSON?
Yes. Paste the full OpenAPI or Swagger document written in YAML and you get the equivalent JSON, which many tools and validators expect. Anchors used to reuse schema fragments are expanded into their real values, since JSON cannot reference them.
Does it handle CloudFormation or Kubernetes YAML?
It does. A CloudFormation template, Kubernetes manifest, or Docker Compose file written in YAML converts to JSON like any other YAML. Only the first document in the file is converted, so split multi-document manifests apart first if you need each one.
How do I convert YAML to JSON in Python instead?
In code, read the YAML with PyYAML's yaml.safe_load() and write it out with json.dumps(). To go the other way, load with json.loads() and dump with yaml.safe_dump(). This tool does the same conversion without installing anything.
Do I need yq or a command-line tool for this?
No. yq is a handy CLI for converting and querying YAML and JSON in the terminal, but this page does the plain YAML-to-JSON conversion in the browser with nothing to install. Reach for yq when you want to script conversions or pipe them between commands.
How is the JSON output formatted?
The result is pretty-printed with two-space indentation so it is easy to read and diff. You can copy it straight out or download it as a .json file if you would rather save it.
What happens to comments and anchors in my YAML?
JSON has no way to store comments, so any comments are dropped during conversion. Anchors and aliases are resolved into the actual values they point to, since JSON cannot represent references.
What if my YAML has an error?
If the YAML cannot be parsed — a bad indent, a missing colon, a stray tab — the converter shows an error instead of JSON. YAML is strict about indentation, so check that first. Only the first document in a multi-document file is converted.