YAML to JSON

Convert YAML to JSON.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

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

1
Step 1
Paste your YAML.
2
Step 2
Press Run.
3
Step 3
Copy the JSON.

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?
Paste the YAML and press Run. The tool outputs formatted JSON.
Why does my YAML fail to convert?
Usually indentation or an unclosed bracket. The error message shows the line and column of the problem.
Are comments kept?
No. JSON has no comments, so they are dropped.
Does the YAML value no become false?
No. Bare yes and no stay strings; only true and false are booleans.

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 YouTube
  • TypeScript in 100 Seconds

    Fireship

    Typed JSON payloads show up constantly next to format/validate tools.

    Watch on YouTube