How to use the YAML to JSON converter
- Paste or drop a
.yamlor.ymlfile into the left pane. The output updates as you type. - Indent: 2 spaces, 4 spaces, tabs, or Minify for a single line.
- YAML: 1.2 (the current spec, and the default) or 1.1 (legacy boolean, octal and date rules).
- Multiple docs: As array or First only.
- Copy or Download the result as
output.json.
Example
services:
api:
image: ghcr.io/acme/api:2.4.1
ports:
- "8080:8080"
becomes
{
"services": {
"api": {
"image": "ghcr.io/acme/api:2.4.1",
"ports": ["8080:8080"]
}
}
}
YAML 1.1 vs 1.2
The same file can mean different things depending on the spec version:
| YAML | 1.2 (default) | 1.1 |
|---|---|---|
country: NO |
"NO" |
false |
ok: yes / flag: on |
"yes" / "on" |
true / true |
mode: 0755 |
755 |
493 (octal) |
day: 2026-09-27 |
"2026-09-27" |
"2026-09-27T00:00:00.000Z" |
In 1.1 mode the tool shows a warning whenever it turns date-like values into timestamps. Keys are affected too: in 1.1 mode a bare key named y or n is read as a boolean and ends up in the JSON as the key "true" or "false".
Details that matter
- Anchors, aliases and merge keys are resolved.
<<: *defaultscopies the shared keys into each service, so the JSON shows each service’s effective config. - Big integers stay exact.
id: 9007199254740993is written to JSON unchanged instead of being rounded. - Tabs are rejected. YAML only allows spaces for indentation, and the error points to the offending line.
- Duplicate keys are errors, not silent overwrites.
When to use it
Common reasons to convert YAML to JSON:
- Debugging config. See the resolved structure of a Kubernetes manifest, Helm values file or GitHub Actions workflow, with anchors and merge keys already expanded.
- Feeding tools that only read JSON, or generating types for a config file with JSON to TypeScript.
- Querying manifests. A multi-document file becomes an array with one element per resource, so the JSONPath Tester can list every resource name with
$[*].metadata.name. - Reviewing changes. Convert two versions of a config and compare them in JSON Diff, which ignores key order and reports each change by path.
Converting in code
# yq (mikefarah/yq v4)
yq -o=json '.' config.yaml
# Python — PyYAML (a YAML 1.1 parser)
import json, yaml
with open("config.yaml") as f:
data = yaml.safe_load(f)
print(json.dumps(data, indent=2, default=str)) # default=str handles dates
// Node.js — the "yaml" library this tool uses
import YAML from 'yaml';
const json = JSON.stringify(YAML.parse(text), null, 2);
Need the reverse? Click Reverse above the output or open JSON to YAML. To describe the converted data’s structure, generate a schema with the JSON Schema Generator.
Frequently asked questions
Does it validate YAML?
Yes. Syntax errors are reported with their line and column, and the line is highlighted in the editor. Common ones are tabs used for indentation ("Tabs are not allowed as indentation"), bad nesting, and duplicate keys in the same mapping ("Map keys must be unique").
What happens with a file that has several documents separated by ---?
By default every document becomes one element of a JSON array, which suits Kubernetes manifests that bundle several resources. Set Multiple docs to "First only" to convert just the first document.
Why did "NO" become false?
You selected YAML 1.1, where NO, yes, on and off are booleans and 0755 is an octal number. The default, YAML 1.2, keeps them as strings and numbers as written. Only use 1.1 to match how an older parser such as PyYAML or go-yaml v2 reads the file.
Are anchors and aliases supported?
Yes. Aliases (*name) are expanded into full copies of the anchored value, and merge keys (<<: *defaults), which Docker Compose and GitLab CI use, are merged into the surrounding mapping. This works with both YAML 1.2 and 1.1.
Is my YAML uploaded?
No. Parsing happens in your browser, and nothing is uploaded.
Last updated