JSON to YAML

Convert JSON to YAML.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

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

1
Step 1
Paste valid JSON.
2
Step 2
Press Run.
3
Step 3
Copy the YAML into your config file.

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?
Paste the JSON and press Run. The tool prints equivalent YAML with two-space indentation.
Is YAML a superset of JSON?
YAML 1.2 can parse most JSON, but the converter writes the more readable block style rather than JSON-style braces.
Can I convert YAML back to JSON?
Yes, use the YAML to JSON tool on this site.
Are my config files uploaded?
No. The conversion happens in your browser.

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 YouTube
  • TypeScript 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.