YAML to JSON Converter
Convert YAML to JSON and JSON to YAML, reformat a config file, and get a line number for the indentation mistake instead of a stack trace.
YAML
JSON
Paste YAML to convert it to JSON.
Parsing runs in your browser — the manifest never leaves the page, which matters when it contains secrets or internal hostnames. Constructs this parser does not support stop the conversion with a line number instead of being dropped.
About the YAML to JSON Converter
Convert YAML to JSON, JSON to YAML, or reformat a YAML file in place. YAML is the format your compose files, CI workflows and Kubernetes manifests are written in, and JSON is the format everything downstream actually consumes — so this conversion sits between you and every config problem you have ever debugged at the wrong end of a stack trace.
The parser reports where a file goes wrong, with a line number and an explanation. A tab used for indentation is named as such rather than surfacing as a scanner error thirty lines later; a duplicate key is refused rather than silently collapsed to whichever copy came last; an alias with no anchor is an error rather than a null. Anything outside the supported subset — a tag, a complex `?` key — stops the conversion instead of quietly disappearing from the output.
It also flags the values that change meaning depending on which YAML version reads them. `yes`, `no`, `on` and `off` are booleans in YAML 1.1 and plain strings in YAML 1.2, and the loader in front of your config may not be the one you assumed. A 20-digit integer is another: JSON numbers are doubles, and anything past 2^53 cannot round-trip. Both are warned about rather than silently resolved.
- Both directions: YAML to JSON and JSON to YAML, with indentation and key-sorting options
- Block mappings and sequences, flow collections, block scalars, comments, anchors, aliases and merge keys
- Multi-document files, split on `---`, converted to a JSON array
- Errors with a line number and a plain-English cause, including the tab-indentation trap
- Warnings for YAML 1.1 versus 1.2 booleans and for integers too large for JSON
- Emitted YAML quotes any string that would otherwise change type when read back
How to use it
- Pick a direction: YAML → JSON or JSON → YAML.
- Paste your file on the left, or load the sample compose file.
- Read the converted output on the right; it updates as you type.
- Check the warnings panel for values whose meaning depends on the YAML version.
- Copy the result, or switch direction to round-trip it back and see what a strict parser makes of your file.
Real-world use cases
Backend & platform engineers
Convert a Kubernetes manifest or a CI workflow file to JSON to feed into a script or a jq pipeline, where JSON tooling is more plentiful than YAML tooling.
DevOps & SRE teams
Round-trip a Docker Compose or Helm values file through this parser to catch a tab-indentation mistake or an unquoted version number before it reaches a cluster.
Frontend & full-stack developers
Convert a JSON config or API response into YAML for a project that reads its configuration that way, with strings quoted automatically wherever leaving them bare would change their type.
QA & release engineers
Reformat a hand-edited YAML file with consistent indentation before a code review, so the diff shows the actual content change rather than whitespace noise.
New team members onboarding
Convert an unfamiliar multi-document CI file to JSON to see its real structure at a glance, without mentally tracking indentation levels across a long file.
Examples
A nested mapping and a list
server:
host: localhost
ports:
- 8080
- 8443{
"server": {
"host": "localhost",
"ports": [8080, 8443]
}
}Indentation is the only thing expressing structure. This is why a stray tab or a misaligned dash changes the shape of the document rather than failing loudly.
The quoting that decides your type
version: 3.9 tag: "3.9" enabled: yes padded: "007"
{
"version": 3.9,
"tag": "3.9",
"enabled": "yes",
"padded": "007"
}Unquoted `3.9` is a number, and `"3.9"` is a string — the reason compose files quote their version. `yes` is a string in YAML 1.2, but a boolean in 1.1, so it is warned about.
Anchors and merge keys
defaults: &defaults adapter: postgres host: localhost development: <<: *defaults database: dev_db
{
"defaults": { "adapter": "postgres", "host": "localhost" },
"development": { "adapter": "postgres", "host": "localhost", "database": "dev_db" }
}`&name` anchors a node, `*name` reuses it, and `<<` merges a mapping in. Keys already present win over merged ones — which is how you override a default.
Block scalars
script: | npm ci npm test summary: > this text is folded onto one line
{
"script": "npm ci\nnpm test\n",
"summary": "this text is folded onto one line\n"
}`|` keeps newlines, `>` folds them into spaces. Add `-` (`|-`) to drop the final newline. A `#` inside a block scalar is content, not a comment.
Common errors
| Message | Cause | Fix |
|---|---|---|
| Tab used for indentation | A literal tab in the leading whitespace. YAML forbids tabs there, and most editors will insert one silently. | Replace tabs with spaces and set your editor to expand tabs for .yml and .yaml. This is the single most common YAML error. |
| Duplicate key "x" | The same key twice in one mapping — often a merge conflict resolved badly, or a key added twice in a long file. | Delete one. Most loaders keep the last silently, which means the wrong one can win for months without anyone noticing. |
| This line is not part of the document above it | Indentation that does not line up with any open block, typically a list item indented one space too few after a key. | Line every item of a list up in the same column. The reported line is the first one that could not be attached to anything. |
| mapping values are not allowed here | An unquoted value containing `: ` — a Windows path, a time, or a sentence with a colon in it. | Quote the value. A colon followed by a space is what separates a key from a value, wherever it appears. |
| A version number lost its trailing zero | Unquoted `3.10` is the number 3.1, and `1.0` is 1. YAML resolves it before anything sees the text. | Quote every version string. This is why `version: "3.9"` is written that way in every compose file you have seen. |
| Tags such as "!!binary" are not supported | A tag changes how a node is constructed, and there is no JSON equivalent to construct it into. | Convert the value by hand, or remove the tag. It is reported rather than dropped so the output can never look complete when it is not. |
Frequently asked questions
›Is my file uploaded anywhere?
No. Parsing and conversion run entirely in your browser. Compose files and CI workflows routinely contain internal hostnames, registry paths and secrets; none of it leaves this page, and nothing is stored or logged.
›Is JSON really valid YAML?
Yes — YAML 1.2 is a strict superset of JSON, so any JSON document is already a valid YAML document. The reverse is not true: YAML has anchors, comments, multiple documents per file and non-string keys, none of which JSON can express.
›Why is `yes` a string here when my parser reads it as true?
Because YAML 1.2 removed the 1.1 rule that resolved `yes`, `no`, `on` and `off` to booleans, and this parser follows 1.2. Plenty of loaders — PyYAML by default, and Docker Compose for specific fields — still follow 1.1. The tool warns wherever this applies rather than picking silently. Writing `true` and `false` avoids the question entirely.
›What happens to comments?
They are dropped, because JSON has nowhere to put them. This is worth knowing before you round-trip a hand-maintained config through JSON and back: the values survive, the explanations do not.
›Which parts of YAML are not supported?
Tags (`!!str`, `!!binary`), complex `?` keys, and directives other than a document marker. Anchors, aliases, merge keys, block scalars, flow collections, multi-document files and comments all work. Anything unsupported stops the parse with a line number — it is never dropped from the output.
›How do I handle a file with several documents?
Paste it as it is. Documents separated by `---` become a JSON array, one element per document, in file order.
›Is my YAML or JSON uploaded anywhere?
No. Parsing and conversion both run in your browser. Kubernetes manifests, CI workflows and Compose files routinely carry internal hostnames and registry paths — none of it is sent anywhere, and nothing is stored or logged.
›Why does converting JSON to YAML sometimes add more quotes than I expected?
Because the emitter checks whether a bare version of each string would be resolved to something other than a string — a boolean, a number, or null — and quotes it if so. A JSON string "3000" that happens to look like an integer is quoted in the YAML output for exactly the same reason a Compose file writes version: "3.9" instead of version: 3.9.
Last updated