JSON to YAML Converter (and YAML to JSON)

Convert between JSON and YAML in either direction. JSON becomes readable block-style YAML, with strings such as yes, no, 1.10 or values containing a colon quoted so they keep their meaning. YAML (mappings, lists, inline [ ] and { } collections, comments, literal | and folded > blocks, and several --- documents) becomes formatted JSON. Unsupported features such as anchors are reported with a line number instead of being converted wrongly.

Convert
Indentation

Input

257 characters

Output

YAML
name: web
image: nginx:1.27
replicas: 3
ports:
- 80
- 443
env:
  NODE_ENV: production
  DEBUG: 'false'
  VERSION: '1.10'
healthcheck:
  path: /health
  interval: 30s
command: nginx -g 'daemon off;'

Checks

  • Pass Converted to YAML 1.2 block style. Strings that YAML would read as another type are quoted.

Runs entirely in your browser. Nothing you paste or open here is uploaded or stored.

How to use the converter

  1. Choose the direction: JSON → YAML or YAML → JSON.
  2. Paste your file or press Sample (a small service definition in each format).
  3. Pick 2 or 4 spaces of indentation.
  4. Read any error shown with its line number, fix it and the output updates instantly.
  5. Copy or download data.yaml or data.json.

How it works

JSON → YAML. Objects become key: value lines, arrays become - item lines, and nested structures are indented. Multi-line strings use the literal block style (|), so scripts and certificates stay readable. Empty objects and arrays are written as {} and []. Every string is checked against YAML’s rules and quoted only when necessary. Plain is preferred, then single quotes, then double quotes when escapes are needed.

YAML → JSON. The parser reads indentation to build mappings and sequences, accepts flow collections such as [80, 443] and {ssl: true}, removes comments outside quotes, and applies YAML 1.2 core-schema typing: true/false, null/~, integers, floats and hex/octal numbers. Everything else is a string.

Worked examples

Example 1: a container definition

Load the JSON sample. The environment value "false" and the version "1.10" stay quoted in YAML. Without quotes they would become a boolean and the number 1.1, a classic source of broken deployments.

Example 2: Docker Compose to JSON

Load the YAML sample. Port mappings like "80:80" are quoted strings, DEBUG: false becomes a JSON boolean, the inline volume list becomes an array and db-data: {} becomes an empty object. Comments are dropped because JSON has no comments.

Example 3: Kubernetes manifests

Paste a file with a Deployment and a Service separated by ---. The result is a JSON array with two objects, ready for tools that expect JSON input.

YAML pitfalls the converter avoids

  • The “Norway problem”. Country code NO was read as false by YAML 1.1 parsers. Strings like yes, no, on and off are always quoted in the output.
  • Version numbers. 1.10 and 1.1 are different versions but the same number. Quoting keeps the zero.
  • Colons and hashes. note: see: below and color: #fff need quotes; the converter adds them.

Common mistakes

  • Tabs for indentation. YAML forbids tabs; the converter tells you the line.
  • Inconsistent indentation. A key indented one space too far is an error, not a nested key.
  • Expecting comments in JSON. They can’t be represented; keep the YAML as your source if comments matter.
  • Anchors and aliases. Expand them first (many YAML tools can), then convert.

Frequently asked questions

Why are some values quoted in the YAML output?

YAML guesses types from plain text. Unquoted, yes and no can become booleans in older parsers, 1.10 becomes the number 1.1, and a value containing “: ” looks like a new key. The converter quotes exactly those strings so the YAML means the same as your JSON.

Which YAML features are supported?

Block mappings and sequences, inline collections on one line, single- and double-quoted strings, plain scalars, literal (|) and folded (>) blocks with chomping indicators, comments and multiple documents. Anchors, aliases, tags, merge keys (<<) and complex keys are reported as unsupported.

Is YAML a superset of JSON?

YAML 1.2 is designed so that almost any JSON document is also valid YAML. The reverse isn't true: YAML has comments, multi-line strings and references that JSON can't express, so converting YAML to JSON drops comments.

What happens with several YAML documents?

Documents separated by --- (as in Kubernetes manifests) are returned as a JSON array, one item per document.

Can I convert YAML config files like docker-compose or GitHub Actions?

Yes, as long as they don't rely on anchors, aliases or merge keys, which are reported as unsupported. Comments are dropped in the JSON output because JSON has no comments.

Sources