JSON to YAML
Convert JSON to YAML.
About this tool
Paste JSON and get the same data as YAML: nested objects become indented maps and arrays become dashed lists. Handy when you turn an API response or a config object into a YAML file. Invalid JSON reports its line and column.
How to use
How it works
The JSON is parsed, then written by js-yaml with two-space indentation, line width 120 and no anchors or aliases. Strings that would be ambiguous in YAML, such as a value that looks like a number or a boolean, are quoted automatically.
Worked example
A small service config
- 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
- The db object becomes an indented map and tags becomes a dashed list. Numbers and booleans stay unquoted.
Limitations
- JSON has no comments, so the YAML has none either.
- Long strings are folded at about 120 characters.
Questions
How do I convert JSON to YAML?
Is YAML a superset of JSON?
Can I convert YAML back to JSON?
Are my config files uploaded?
Features
- Block-style YAML output
- Two-space indent
- Auto-quotes ambiguous strings
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
What Is A RESTful API?
Traversy Media
Most APIs exchange JSON—context for pretty-print and schema checks.
Watch on YouTubeTypeScript in 100 Seconds
Fireship
Typed JSON payloads show up constantly next to format/validate tools.
Watch on YouTube
- Introducing JSON
json.org
Canonical JSON grammar—handy when a formatter rejects a trailing comma.
- Working with JSON
MDN
Parse and stringify patterns that pair with browser-side JSON tools.