YAML to JSON Converter guide
Edit YAML on one side and JSON on the other; each updates as you type. Invalid input gets a precise line and column so you can fix Kubernetes manifests, CI configs, and API payloads fast.
YAML and JSON describe the same data
JSON and YAML both describe maps (objects), lists (arrays), and scalars (strings, numbers, booleans, null). YAML 1.2 is designed so that almost any JSON document is also valid YAML. The difference is syntax: JSON uses braces, brackets, and quotes; YAML uses indentation and dashes. That is why Kubernetes, Docker Compose, GitHub Actions, and Ansible pick YAML for files people write by hand, and APIs pick JSON for data machines exchange.
This converter goes both ways. Edit the YAML side and the JSON updates; edit the JSON side and the YAML updates. It uses the js-yaml library, loaded only on this page, and runs entirely in your browser. Secrets in a values.yaml or a CI config never leave your machine.
Worked example: a Kubernetes manifest
The preloaded example is a Deployment. In YAML, spec: is followed by indented keys, and containers: is a list where each item starts with a dash. In JSON, the same structure becomes "spec": { "replicas": 3, ... } and "containers": [ { "name": "web", ... } ]. kubectl accepts both formats, so converting is safe. The JSON form is handy for jq queries, for kubectl patch, or for pasting into code.
Comments do not survive. JSON has no comment syntax, so # lines in your YAML are dropped when you convert to JSON. If you round-trip back to YAML, they are gone for good. Keep the original file under version control.
Reading YAML error messages
When the YAML is invalid, the tool shows the line and column where the parser gave up, plus the reason. The most common ones:
Bad indentation: a key is indented by a different number of spaces than its siblings. YAML does not care whether you use 2 or 4 spaces, but every sibling must use the same amount.
Tabs: YAML forbids tab characters for indentation. An editor that inserts tabs will break your file in a way that is invisible on screen. Replace them with spaces.
Missing space after a colon: key:value is read as a single string, not a key and a value. It needs to be key: value.
Unquoted special characters: a value that starts with @, `, *, &, !, |, >, %, or { or [ must be quoted. So must a string containing ": " or " #".
Duplicate keys: the same key twice in one map is an error in js-yaml, which protects you from silently losing the first value.
The type traps
YAML guesses types from unquoted values, and the guesses depend on the YAML version. This tool follows YAML 1.2 (the core schema): true, false, and null are special, numbers are numbers, and everything else is a string.
The famous Norway problem comes from YAML 1.1, where NO, no, off, and yes were booleans, so a country code list with NO turned into false. YAML 1.2 fixed that, but older parsers (including PyYAML and many Ruby and Go tools) still use 1.1 rules. If a value must be a string, quote it: "NO", "on", "1.10".
Version numbers and zip codes. version: 1.10 is the number 1.1. zip: 02134 is the number 2134 in YAML 1.2. Quote them. The same problem hits JSON in reverse: once converted, an unquoted 1.10 is a number and the trailing zero is gone.
Large integers. Numbers beyond 2^53 lose precision in JavaScript, so a 19-digit ID can change by the time it reaches JSON. Quote big IDs in the YAML.
Multiple documents and anchors
A YAML file can hold several documents separated by ---, common in Kubernetes files that bundle a Deployment and a Service. The converter turns multiple documents into a JSON array, one element per document, and tells you how many it found.
Anchors (&name) and aliases (*name) are expanded during conversion, so the JSON shows the full, repeated data. Merge keys (<<: *defaults) are a YAML 1.1 extension that YAML 1.2 dropped, so here they show up as a literal "<<" key. Tools like Docker Compose and GitLab CI still honor them; if you need the merged result in JSON, merge by hand. Going the other way, from JSON to YAML, the tool writes plain output without anchors, so it is easy to read and diff.
How we calculate: sources
Frequently asked questions
How do I convert YAML to JSON?
Paste YAML into the left box. The JSON appears on the right as you type. Copy or download it when you are done.
Can it convert JSON back to YAML?
Yes. Edit the JSON box and the YAML box updates with clean block-style YAML using your chosen indent.
Does it validate YAML?
Yes. Invalid YAML shows the line, column, and reason, such as bad indentation, tab characters, or duplicate keys.
What happens to YAML comments?
JSON has no comments, so they are dropped when converting to JSON and cannot come back on the reverse trip.
Does it support multiple YAML documents?
Yes. Documents separated by --- are converted into a JSON array with one item per document.
Which YAML version is used?
YAML 1.2 core schema via js-yaml. Values like yes, no, and on stay strings, which avoids the Norway problem from YAML 1.1.
Are my config files and secrets uploaded?
Everything runs in your browser. Nothing you enter is uploaded to a server or stored by us.
Is JSON valid YAML?
Almost always. YAML 1.2 was designed as a superset of JSON, so a standard JSON document parses as YAML. Rare edge cases involve duplicate keys and very long keys.
Why did my YAML comments disappear?
JSON has no comment syntax, so comments are dropped when converting YAML to JSON. They cannot be recovered on the way back.