JSON appears here.How to use
Add your YAML
Paste YAML into the left pane, drop or upload a .yaml or .yml file, use Load URL, or press Try sample to load a two-document file with an anchor, an alias and a << merge key.
Choose the output
Pick the Schema, how several documents are written, and the Indent. The JSON updates as you type; untick Convert as you type to convert only when you press the button.
Fix errors or copy
If the YAML is invalid, the line is highlighted and the error shows the column and nearby lines, with Go to line to jump there. Otherwise copy the JSON or download .json or .jsonl.
Why YAML to JSON Converter
- Handles multi-document YAML as a JSON array, JSON Lines or the first document only.
- Highlights the error line and explains common mistakes such as tabs and bad indentation.
- Schema choice controls typing, from full YAML 1.2 with dates to Failsafe, where every value is text.
- Expands anchors, aliases and merge keys, so the JSON shows final values.
Anchors, aliases and merge keys: YAML input vs JSON output
Anchors let a YAML file define a block once and reuse it. The sample on this page defines &defaults with an image and a replica count, then pulls it into web with <<: *defaults and adds a port. JSON cannot express that reuse, so the converter writes the final values out in full.
The sample also has a second document after ---, so the whole output is a JSON array with two objects.
| YAML | JSON |
|---|---|
| defaults: &defaults with image: nginx:1.27 and replicas: 2 | "defaults": {"image": "nginx:1.27", "replicas": 2} |
| web: with <<: *defaults and port: 80 | "web": {"image": "nginx:1.27", "replicas": 2, "port": 80} |
| --- followed by a second document | The output becomes an array: [ {first}, {second} ] |
| ports: with - port: 80 and targetPort: 8080 | "ports": [{"port": 80, "targetPort": 8080}] |
Which schema to choose
The schema decides how unquoted values are typed. The same line, version: 1.10, can come out differently depending on the choice, so pick the one that matches the tool that will read your YAML.
| Schema | Numbers and booleans | Dates | Merge keys (<<) |
|---|---|---|---|
| YAML 1.2 + merge keys and dates (default) | Typed | Become ISO timestamps | Expanded |
| YAML 1.2 core | Typed | Stay strings | Not expanded |
| JSON schema (strict) | Only JSON-style values are typed | Stay strings | Not expanded |
| Failsafe | Everything is a string | Stay strings | Not expanded |