Utilia

JSON to YAML Converter

Convert JSON to YAML and YAML to JSON in your browser, with anchors, merge keys and multi-document files supported. Nothing is uploaded.

Conversion

How to use the JSON to YAML converter

  1. Choose the direction: JSON → YAML or YAML → JSON.
  2. Paste your data, or click Open a file to load a .json, .yaml or .yml file (up to 10 MB).
  3. Choose the Indentation (2 or 4 spaces) and, if you like, Sort keys alphabetically.
  4. Click Convert, or just keep typing: the result updates automatically. If the input is invalid, the error message gives the line and column of the problem.
  5. Copy or download the result. Swap direction sends the output back to the input to convert it the other way.

JSON and YAML: same data, different syntax

YAML is a superset of JSON in practice: every JSON document describes data that YAML can express, and YAML adds a lighter syntax that is easier for people to read and edit. That is why Kubernetes manifests, Docker Compose files, GitHub Actions and GitLab CI pipelines, Ansible playbooks and OpenAPI specifications are usually written in YAML, while APIs and programs exchange JSON.

The same data in both formats:

{"name": "web", "ports": [80, 443], "env": {"DEBUG": false}}
name: web
ports:
  - 80
  - 443
env:
  DEBUG: false

JSON → YAML

The converter writes block-style YAML: one key per line, lists with dashes, and nested objects indented. Long strings are never folded, and multi-line strings use the literal | style so that line breaks are kept exactly. Strings that YAML would otherwise read as another type are quoted: "yes", "1.0" or "null" stay strings after a round trip. Sort keys orders the keys of every object alphabetically, which makes two configuration files easier to compare.

YAML → JSON

The YAML is read with the YAML 1.2 core schema, the same rules most modern tools use:

  • true/false, numbers and null (or ~) become JSON values; yes, no, on and off stay strings, as the YAML 1.2 specification requires.
  • Anchors and aliases (&base, *base) are expanded, and merge keys (<<: *base), common in CI files, are supported.
  • A file with several documents separated by --- becomes a JSON array with one element per document, and a message tells you how many were combined.
  • Comments are dropped, since JSON has no comments.
  • .inf and .nan have no JSON equivalent; they are written as the strings "Infinity" and "NaN".

To protect your browser from “billion laughs” files, in which a few aliases expand into billions of values, a document that expands to more than a million values is refused.

Common YAML mistakes

  • Tabs for indentation: YAML only allows spaces.
  • Inconsistent indentation: items of the same list or object must start in the same column.
  • Missing space after the colon: key:value is a single string, while key: value is a key-value pair.
  • Unquoted special characters: a value that starts with @, a backtick, *, & or !, or that contains : or #, must be quoted.

Frequently asked questions

Is my file sent to a server?

No. The conversion runs in your browser, and your configuration files, secrets or API data never leave your computer.

Why are "yes" and "no" not converted to booleans?

Since YAML 1.2, only true and false are booleans. Older YAML 1.1 parsers treated yes, no, on and off as booleans, which caused the famous “Norway problem” (the country code NO read as false). This tool follows YAML 1.2.

Are YAML comments preserved?

No. JSON has no comments, so they are lost in YAML → JSON. When converting JSON → YAML, you can add comments to the result afterwards.

Can I convert a Kubernetes file with several resources?

Yes. Each resource separated by --- becomes one element of a JSON array. Converting that array back to YAML gives a single document containing a list.

Does the converter change key order?

Not unless you tick Sort keys: keys keep the order in which they appear in your input. The one exception comes from JavaScript itself: keys that are whole numbers, such as "10" or "2", are placed first, in ascending order.