Tools

YAML ⇄ JSON Converter

Convert YAML and JSON both ways with error lines

How to convert YAML to JSON (and back)

  1. Choose YAML → JSON or JSON → YAML.
  2. Paste your Kubernetes manifest, Docker Compose file, GitHub Actions workflow, OpenAPI spec or any other document. It converts as you type.
  3. If the input has a syntax error, the exact line and column are shown, which makes indentation mistakes easy to find.
  4. Choose 2 or 4 spaces of indentation, then copy or download the result. Use Swap to convert the output back again.

YAML vs JSON

YAML and JSON describe the same kinds of data: maps, lists, strings, numbers, booleans and null. JSON is strict and easy for machines, so APIs use it. YAML is easier for people to write, with comments, no braces and indentation-based nesting, so it is popular for configuration. In fact, every JSON document is also valid YAML 1.2.

When converting YAML to JSON, comments are dropped, since JSON has no comments. Multiple YAML documents separated by --- become a JSON array. Anchors and aliases (&base, *base) are expanded into full copies.

Common YAML gotchas

Conversion uses the well-tested js-yaml library loaded into your page; your data is processed locally and is never uploaded.

Why did my value turn into a number?

YAML guesses types for unquoted values. Values such as 010, 1e3 or 1.10 become numbers. Wrap them in quotes to keep them as strings.

Are comments kept when converting JSON to YAML?

JSON has no comments, so there are none to keep. When converting YAML to JSON, comments are removed because JSON cannot store them.

Does it support YAML 1.1 booleans like yes and no?

The converter follows YAML 1.2, where only true and false are booleans. yes, no, on and off stay strings, which avoids the classic "Norway problem".