JSON ↔ YAML Converter · Encoding
Convert JSON ↔ YAML — and see exactly what changes.
Every converter turns YAML into JSON. This one also tells you what it cost: the comments it dropped, the anchors it expanded, the date it rewrote, the integer it rounded. Real YAML 1.2 parser, entirely in your browser.
Runs in your browser — nothing you paste leaves this page. How we prove that
JSON ↔ YAML Converter playground
Every JSON file is already valid YAML — YAML 1.2 is a superset of JSON. The reverse is not true, which is why the direction is yours to pick.
Off by default: the order you wrote is kept, except for integer-like keys.
Results update as you type — press Enter to run now.
Press Esc to release keyboard focus from the editor; ⌘/Ctrl + Enter converts and leaves the editor. Nothing you paste is uploaded.
An anchor (&name) marks a value so an alias (*name) can reuse it. JSON has neither, so every alias is written out as a full copy.
Paste JSON or YAML above — or tap an example — to see the converted document here, plus every comment, anchor, timestamp and out-of-range number the conversion costs you.
The Gap
Silent converters, and answers that depend on the parser.
The dozen ad-funded converters at the top of the search results all do the same thing: they print the other format and say nothing. Your comments are gone. Your anchors were expanded into copies. That unquoted date is now a string with a timezone you never wrote. The 19-digit ID lost its last two digits. Nothing on the page mentions any of it, so the first time you find out is in review — or in production.
Ask an AI assistant instead and you get a second problem: the answer depends on which YAML version the model happened to learn from. verify: no is the string "no" under YAML 1.2 and the boolean false under YAML 1.1, and both answers get asserted with equal confidence. 0777 is 777 in one and 511 in the other — which, for a file mode, is the difference between a broken deploy and a working one.
This tool answers with ground truth instead of a guess: a real YAML 1.2 parser runs in your tab, the output is deterministic, and every lossy step is named with the line or path it happened at. The reference table below pins the values the two YAML versions disagree on, so you can check a claim in seconds.
Working on a pipeline? The GitHub Actions Validator and GitLab CI Validator lint the YAML itself.
The Pipeline
How it works.
Four deterministic steps run as you type — all inside your browser tab, and every lossy one reports itself.
-
Parse with a real parser.
js-yaml 4 on the YAML 1.2 core schema, or JSON.parse — never a regex. If it does not parse, you get the line and column, not "invalid".
-
Normalise, and log it.
One walk converts timestamps to ISO-8601 strings, !!binary to base64 and ±Infinity/NaN to null — each one emitting a diagnostic with the path it happened at.
-
Emit deterministically.
No line folding and no generated anchors, so the same input always produces the same bytes and the output re-reads exactly as it looks.
-
Report every loss.
Comments, anchors, merge keys, extra documents, reordered numeric keys and rounded integers are listed beside the output, so you decide whether the conversion was acceptable.
By Example
Four losses in six lines.
A comment, an anchor, a merge key and an unquoted date — the everyday YAML that no converter can carry across intact.
Input
Ordinary YAML: one comment, one anchor, one merge key, one bare date.
# rollout defaults, shared by both jobs
defaults: &defaults
retries: 2
verify: no # a string in YAML 1.2, false in YAML 1.1
release:
<<: *defaults
date: 2024-01-15 Output, with the receipt
Four reported losses: the comment is gone, *defaults was copied, <<: was flattened, and the date became an ISO-8601 string. no stayed a string — and is flagged, because PyYAML would read it as false.
{
"defaults": { "retries": 2, "verify": "no" },
"release": {
"retries": 2,
"verify": "no",
"date": "2024-01-15T00:00:00.000Z"
}
} Reference
Where YAML 1.2 and YAML 1.1 disagree.
The same unquoted scalar, read by this tool (js-yaml 4, YAML 1.2 core schema) and by a YAML 1.1 parser such as PyYAML. When a tool and a teammate disagree about a value, the answer is almost always in this table.
| Unquoted input | YAML 1.2 — this tool | YAML 1.1 — PyYAML |
|---|---|---|
| no | "no" (string) | false (boolean) The Norway problem. Same for yes / on / off / y / n. |
| true | true (boolean) | true (boolean) The two versions agree on true and false only. |
| ~ | null | null null, Null, NULL, ~ and an empty value are all null in both. |
| 2024-01-15 | 2024-01-15T00:00:00.000Z | 2024-01-15T00:00:00.000Z Both resolve an unquoted date to a timestamp; JSON has no date type, so it is written as an ISO-8601 string. |
| 0777 | 777 (decimal) | 511 (octal) The single most dangerous disagreement — file modes silently change meaning. Write 0o777. |
| 0o777 | 511 | "0o777" (string) The explicit YAML 1.2 octal form is not understood by YAML 1.1 at all. |
| 1:30 | "1:30" (string) | 90 (sexagesimal) YAML 1.1 read colon-separated numbers as base 60. YAML 1.2 removed it. |
| .inf | Infinity | Infinity JSON has no infinity, so it becomes null — with a warning. |
| 9007199254740993 | 9007199254740992 | 9007199254740993 Not a YAML disagreement but a JavaScript one: past 2^53 − 1 the exact value is gone. |
Quoting removes every disagreement in this table. When a scalar has to stay a string in both worlds, quote it — and when this tool emits YAML it quotes them for you.
Next Step
Now check that the YAML itself is valid.
Converting proves a document parses; it does not prove the pipeline will accept it. Run workflow YAML through the GitHub Actions Validator or the GitLab CI Validator to catch the schema and security problems a converter cannot see.
YAML → JSON · 2 docs · 31 keys · 1 warning · 3 notes
note: comments were dropped
note: 1 alias expanded into a copy
note: "no" stayed a string (YAML 1.1 reads false)
warning: 9007199254740993 → 9007199254740992 FAQ
Questions, answered.
Tap a question to expand the answer.
What does the JSON ↔ YAML Converter do?
It converts JSON to YAML or YAML to JSON in your browser, and then tells you what the conversion cost. Comments, anchors and aliases, merge keys, timestamps, multi-document streams and integers too large for JavaScript to hold exactly cannot survive the trip — so each one is reported as a named warning or note next to the output instead of disappearing quietly.
Which YAML version does it use?
YAML 1.2, via js-yaml 4 and its default (core) schema — the same reader used by most modern JavaScript tooling. That matters because YAML 1.2 dropped the YAML 1.1 boolean spellings: no, yes, on and off are plain strings here, and only true and false are booleans. PyYAML, Ruby's Psych and older Kubernetes tooling still follow YAML 1.1, so the reference table on this page pins the values where the two versions disagree.
What is the "Norway problem"?
A YAML 1.1 parser reads the unquoted scalar NO as the boolean false, so a country list containing Norway's ISO code turns into a list containing false. The same trap catches ON, OFF, YES, Y and N. This converter follows YAML 1.2, so those stay strings — and it flags every one it sees so you know a YAML 1.1 tool downstream would disagree. In the other direction it quotes them on output ("NO" becomes 'NO'), which is what keeps the file safe to feed to PyYAML.
Does my document ever leave my browser?
No. Parsing, conversion and reporting all run 100% client-side in your tab — there is no server, no account and no logging. You can safely paste production manifests, CI configs and files containing internal hostnames or secrets.
What happens to YAML comments?
They are lost, and the tool says so. JSON has no comment syntax, and preserving comments through a round trip would require a comment-aware syntax tree rather than a value parser — that is a deliberate non-goal here. If you need comments to survive, edit the YAML directly instead of round-tripping it through JSON.
How are YAML anchors and aliases converted?
They are expanded in place. An anchor (&defaults) marks a value; an alias (*defaults) reuses it. JSON has neither, so every alias becomes a full copy of the anchored value — the document means the same thing, but it is longer and the sharing is gone. Merge keys (<<:) are expanded the same way, with the inherited keys written out in full. A recursive alias, where a node contains itself, cannot be represented in JSON at all and is reported as an error rather than crashing the page.
Why did my big number change?
JavaScript holds numbers as IEEE-754 doubles, so integers beyond 2^53 − 1 (9007199254740991) cannot be represented exactly. 9007199254740993 becomes 9007199254740992 the moment it is parsed — by this tool, by JSON.parse in your own code, and by any other browser-based converter. The difference is that this one warns you and quotes the original digits. If the value is an ID rather than a quantity, keep it as a quoted string.
How do I convert a Kubernetes YAML manifest to JSON for kubectl patch?
Paste the manifest, keep the direction on YAML → JSON, and copy the output. kubectl patch --type=merge -p accepts a JSON document, and a multi-document manifest (several resources separated by ---) becomes a JSON array here, which kubectl will not accept as a patch — split it and convert one resource at a time. Quantities such as 256Mi and 500m stay strings in both formats, which is what Kubernetes expects.
Can I convert a CloudFormation template?
Not while it uses the shorthand tags. !Ref, !GetAtt and !Sub are CloudFormation-specific YAML tags, not part of the standard schema, so a standards-compliant parser rejects them — this tool says exactly which tag it choked on and where. Rewrite them in their long form (Ref: BucketName instead of !Ref BucketName) and the template converts.
Does the output order match my input?
Yes, with one unavoidable exception. Key order is preserved by default, and "Sort keys" sorts every level when you want a stable diff. The exception is integer-like keys: JavaScript objects always enumerate keys such as "1" and "2" first, in ascending numeric order, before any other key — whatever order they were written in, and whether or not they were quoted. The tool warns when your document contains them.
More free, private DevOps tools.
The JSON ↔ YAML Converter is one tool in OpsCanopy — a growing canopy of browser-based validators, converters and testers that never touch a server.
More in Encoding
39 free tools, every one offline-capable — opscanopy.com works with no signup and nothing uploaded.
Related: the GitHub Actions Validator and GitLab CI Validator for linting pipeline YAML, the Docker Run to Compose converter for turning a command into YAML, the Alertmanager Route Tester for walking a routing tree, and the Base64 Encoder / Decoder when the payload is encoded rather than structured — or browse the full tools directory.
Provided as-is for convenience; always confirm critical configuration against the tool that will consume it. OpsCanopy is free and open.