Convert YAML to JSON and JSON to YAML
Convert YAML config files to JSON, or JSON to YAML.
- Nothing is uploaded
- Free · no account
- Tested on 400k-row files
Reference
YAML to JSON: how it works
The tool is above. Below: a short overview, optional step-by-step detail, honest browser limits, and answers to common questions.
Last updated 3 min read
About this tool
PrivateCSV converts YAML to JSON as you paste it, and JSON back to YAML. Anchors and aliases are resolved, a file with several documents separated by --- becomes a JSON array, and syntax errors such as a bad indent are reported with their line. In the other direction, strings that some YAML parsers would read as booleans or numbers, like yes, on or 02139, are quoted. Your files are converted in your browser and never uploaded.
Read the step-by-step guideHow-to, example and use cases (~3 min)
How to convert YAML to JSON
- Paste the YAML in the left box, or open a .yaml or .yml file.
- The JSON appears on the right. An error message gives the line to fix if the YAML is invalid.
- Choose the JSON indent, or Minify for one line.
- Copy the JSON or download it. Click JSON → YAML to convert the other way.
Example
A small service config.
service:
name: api
ports: [80, 443]
zip: '02139'{
"service": {
"name": "api",
"ports": [
80,
443
],
"zip": "02139"
}
}When you need it
- Kubernetes, Docker Compose and CI files
- Turn a manifest or a GitHub Actions workflow into JSON to check its structure, query it with jq, or send it to an API that only accepts JSON.
- OpenAPI and Swagger specs
- API specs are written in YAML or JSON. Convert between the two for tools that only read one of them.
- App settings
- Move settings between apps that use YAML (Home Assistant, Ansible, Hugo) and apps or libraries that expect JSON.
How YAML values become JSON
- Mappings become objects and sequences become arrays.
- Numbers, true/false and null become JSON numbers, booleans and null. Quoted values stay strings.
- Dates such as 2026-01-15 stay strings, as in YAML 1.2.
- Anchors (&name) and aliases (*name) are expanded; the merge key << is kept as a key.
- Several documents separated by --- become a JSON array, one item per document.
- Comments are dropped: JSON has no comments.
JSON to YAML
The YAML is written with 2 or 4 spaces and block style. Strings are quoted when a YAML 1.1 parser would read them as something else (yes, no, on, off, numbers with leading zeros), so tools such as PyYAML get back exactly the JSON values. For a top-level array, an option writes one YAML document per item, as Kubernetes manifests do.
Browser and file limits (not a trial)
These are technical limits of running in your browser—device memory, encoding and what this tool does not do. They are not a free trial, account quota or paid plan. There is no subscription.
- The text box holds up to 20 MB.
- Custom YAML tags (such as !Ref in CloudFormation) are reported as warnings and their values kept as plain values.
- Duplicate keys in one mapping are reported as errors, as the YAML specification requires.
Frequently asked questions
How do I convert YAML to JSON?
Paste the YAML in the box above or open the file. The JSON appears at once; copy it or download it as a .json file.
How do I convert JSON to YAML?
Click JSON → YAML, then paste the JSON. The YAML appears on the right, with 2-space indentation by default, ready to copy or download.
What happens to YAML comments when converting to JSON?
They are dropped, because JSON has no comment syntax. Keep the YAML file as the source if the comments matter.
Why is my YAML invalid?
The most common causes are tabs used for indentation (YAML only allows spaces), inconsistent indentation inside a list, a missing space after a colon, and an unclosed bracket or quote. The error message gives the line where the parser stopped.
Is YAML a superset of JSON?
Since YAML 1.2, almost: valid JSON is valid YAML. That is why converting JSON to YAML never loses data, while YAML features such as comments, anchors and multiple documents have no JSON equivalent.
Related tools
Go further
Your files never leave your device
PrivateCSV runs this tool in your browser. No upload, no account, no trial and nothing to install.