Convert YAML to JSON and back
Paste YAML on the left and the JSON appears on the right as you type. Switch the direction to turn JSON into YAML. Swap feeds the result back in, which is a quick way to check that nothing is lost in a round trip. If the input has a syntax error, the tool shows the line and column.
Where you meet YAML
Kubernetes manifests, Docker Compose files, GitHub Actions and GitLab CI pipelines, Ansible playbooks, OpenAPI specs and Spring Boot's application.yml are all YAML. APIs, on the other hand, almost always speak JSON. YAML is a superset of JSON, so every JSON document is also valid YAML, but not the other way round.
Indentation errors
YAML uses indentation instead of brackets, so a single misplaced space changes the meaning or breaks the file. Use spaces, never tabs, and keep items in the same list or mapping at exactly the same depth. When the tool reports “bad indentation”, look at the line it points to and the line above it.
# Wrong: "image" is indented one space too far
containers:
- name: api
image: orders-api:1.4.2
# Right
containers:
- name: api
image: orders-api:1.4.2Several documents in one file
A line with --- starts a new document, which is common in Kubernetes files that define several resources. This tool converts a multi-document file into a JSON array with one item per document.
Values that change type
YAML guesses types for unquoted values. port: 8080 is a number, enabled: true is a boolean and zip: 01234 becomes the number 1234. Older YAML 1.1 parsers also read yes, no, on and off as booleans, which famously turns the country code NO (Norway) into false. When a value must stay text, put it in quotes. When converting JSON to YAML, this tool quotes strings such as "true", "null" and "01234" so they stay text. It follows YAML 1.2, which treats yes and no as text and leaves them unquoted; if an older YAML 1.1 tool will read the file, quote those yourself.
Comments and anchors
JSON has no comments, so YAML comments are dropped when converting to JSON. Anchors and aliases (&defaults and *defaults) are expanded into full copies. Files that expand aliases an excessive number of times are rejected, so a malicious file can't freeze your browser.