YAML to JSON
Convert YAML to JSON.
About this tool
Paste YAML and get indented JSON. Mappings become objects, dashed lists become arrays, and numbers, booleans and null keep their real types. If the YAML is malformed, the error names the line and column.
How to use
How it works
The text is parsed by js-yaml, and the resulting value is written with JSON.stringify and two-space indentation. Only a single YAML document is read, so a file with several --- sections is rejected with an error.
Worked example
Config with a list and a nested map
- Input
- name: api port: 8080 tags: - a - b db: host: localhost ssl: false
- Output
- { "name": "api", "port": 8080, "tags": [ "a", "b" ], "db": { "host": "localhost", "ssl": false } }
- Walkthrough
- 8080 becomes a number and false a boolean, because YAML scalars are typed.
Limitations
- Comments, anchors and ordering hints in the YAML do not survive in JSON.
- Multi-document YAML (several --- sections) is not split into an array.
Questions
How do I convert YAML to JSON?
Why does my YAML fail to convert?
Are comments kept?
Does the YAML value no become false?
Features
- Typed numbers and booleans
- Error with line and column
- Pretty-printed output
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Learn JSON - Full Crash Course for Beginners
freeCodeCamp.org
Solid JSON syntax and nesting basics for formatter and validator tools.
Watch on YouTubeTypeScript in 100 Seconds
Fireship
Typed JSON payloads show up constantly next to format/validate tools.
Watch on YouTube
- Base64
MDN
When Base64 is appropriate versus raw binary transfer.
- RFC 8259 — The JavaScript Object Notation
IETF
The standards text behind modern JSON interoperability rules.