How to Convert YAML to JSON
Paste YAML maps or lists and switch to YAML-to-JSON mode. Check the result before copying it. This tool uses a lightweight parser, so advanced YAML features should be checked with a full YAML implementation in your build pipeline.
YAML Maps and Lists in JSON
Indented key-value mappings become JSON objects and sequences become arrays. The converter must infer hierarchy from indentation. Mixed indentation or missing spaces after structural punctuation can lead to an unexpected shape.
YAML Data Types and Quoting
Quote identifiers, dates and values that must remain strings. Unquoted scalar interpretation varies across YAML parsers and versions. JSON cannot represent YAML-specific tags or arbitrary object types without an explicit mapping.
Common YAML Parse Errors
Inspect indentation first when a parse fails. Anchors, aliases, merge keys, complex keys and multi-document streams are not a guaranteed part of this lightweight converter’s support. Simplify a sample to isolate the failing construct.
YAML to JSON Examples
A list under users should become a JSON array under the users property. Comments are omitted because JSON has no comment syntax. Validate the produced JSON against the application’s schema before deployment.
More examples and technical details
Why Convert YAML to JSON
YAML is written by people. JSON is consumed by programs. Almost every reason to convert in this direction comes down to that split.
- HTTP APIs overwhelmingly speak JSON. If your configuration lives in YAML but has to be posted to an endpoint, it has to be converted first.
- JavaScript parses JSON natively and at speed. Loading YAML in a browser means shipping a parser library that is considerably larger than the config it reads.
- JSON is unambiguous. There is one way to write a mapping and one way to write a list, so there is nothing to disagree about and no implicit typing to trip over.
- Tooling is broader. Query languages, diff tools, schema validators, and log processors all assume JSON as a lowest common denominator.
- Machine generated output should not be YAML. If nobody is going to read it, the readability advantage buys you nothing and the parsing cost is real.
Side by Side Example
A continuous integration workflow, converted to JSON. Notice what does not survive.
YAML input
JSON output
Both comments are gone without a trace. The block scalar has been resolved into a single string with real newline escapes. The cron expression stayed a string because it was quoted in the source, which is exactly why it was quoted.
What YAML Features Cannot Survive
| YAML feature | Fate in JSON | Practical consequence |
|---|---|---|
| Comments | Dropped entirely | Round tripping YAML through JSON destroys documentation |
| Anchors and aliases | Expanded into duplicated data | File size grows, and the shared identity is lost |
| Merge keys | Resolved into literal keys | Overrides are baked in and no longer traceable |
| Multi-document files | Cannot be one JSON value | Emit a JSON array or separate files |
| Non-string keys | Illegal in JSON | Keys such as 1 or true are coerced to strings |
| Complex keys | No equivalent | A mapping used as a key has to be restructured |
| Block scalar style | Collapsed to one string | The pipe and fold distinction disappears once parsed |
| Explicit tags | Ignored | Custom types resolve to plain maps or strings |
| Trailing formatting and ordering | Not guaranteed | Key order preservation depends on the serialiser |
Anchors expand, they do not link
One anchor used three times
The JSON is correct and the values are right, but the intent is gone. Change the retry count later and you now have three places to edit instead of one. This is why the YAML file should stay the source of truth and the JSON should be treated as a build artefact.
Multiple documents in one file
A line consisting of three hyphens starts a new document, and Kubernetes manifests use this constantly to put several resources in one file. JSON has no document separator, so a three document YAML file becomes either a JSON array of three objects or three separate files. Choose deliberately, because a consumer expecting a single object will fail on an array.
Type Coercion Differences
YAML resolves untagged scalars using pattern rules. JSON has explicit syntax and no inference at all. The conversion therefore locks in whatever the YAML parser decided, and the decision is invisible in the output.
| YAML source | Parsed value | JSON output |
|---|---|---|
| version: 1.20 | Float | 1.2 |
| version: "1.20" | String | "1.20" |
| enabled: yes | Boolean under 1.1 | true |
| code: NO | Boolean false under 1.1 | false |
| zip: 01234 | Octal or string, parser dependent | 668 or "01234" |
| value: ~ | Null | null |
| blank: | Null | null |
| big: 12345678901234567890 | Integer beyond safe range | Precision loss in JavaScript |
YAML 1.1 Versus 1.2
The boolean rules changed between versions and most parsers did not follow. YAML 1.1 treats y, yes, on, true, n, no, off, and false as booleans in a range of casings. YAML 1.2 narrowed this dramatically, with the core schema recognising only true and false.
The catch is that many popular libraries still implement 1.1 semantics by default even though 1.2 was published in 2009. So the same file can convert differently depending on which language and which library you run it through, which is a genuinely unpleasant class of bug when a deployment pipeline and a local script disagree.
The defence is simple and costs nothing: quote any scalar whose string identity matters. Country codes, version numbers, times, zero padded ids, and single letter flags should all be quoted in the source. Then no parser has a decision to make.
Strict JSON is usually a stepping stone. Head to the full converter collection for JSON to YAML to return to a human friendly config, JSON Schema to validate the structure you just produced, and JSON to TypeScript to type it in application code.
Standards and references
Frequently asked questions
How do I convert YAML to JSON?
Paste a supported YAML mapping or list and select YAML-to-JSON mode.
How are YAML lists converted?
YAML sequences become JSON arrays, with maps inside the list becoming objects.
What happens to YAML comments?
Comments are omitted; JSON does not support them.
Why can YAML types be surprising?
Unquoted scalars may be interpreted as numbers or booleans, and YAML versions differ. Quote values that must remain strings.
Is my YAML uploaded?
No. Input is processed in this browser tab and is not uploaded by the tool. Copy and download are actions you control; ordinary page analytics do not receive tool input.