Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

JSON to YAML and YAML to JSON Converter

Convert between JSON and YAML in either direction.

Use via API

Convert JSON to YAML or YAML to JSON. Send JSON, get JSON back.

POST https://pithlab.com/api/v1/tools/json-yaml-converter

curl https://pithlab.com/api/v1/tools/json-yaml-converter \
  -H "Authorization: Bearer $PITHLAB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":"{\"service\":\"billing\",\"replicas\":3,\"enabled\":\"yes\"}","to":"yaml"}'

Fields and responseOpenAPI documentGet an API key

About the JSON to YAML Converter

Convert JSON to YAML or YAML to JSON instantly in your browser. Supports anchors, multi-document YAML and block strings, with clear error messages and line numbers.

How to use the JSON to YAML Converter

  1. Choose JSON → YAML or YAML → JSON.
  2. Paste your input, or press Example. The output updates as you type.
  3. Pick the indentation you prefer. When writing YAML, keep 1.1-safe quoting on if older tools will read the file.
  4. Copy the result or download it as a file. Use Swap to convert the output back.

Examples

JSON to YAML

Input

{"service":"web","replicas":2,"ports":[80,443],"enabled":"yes"}

Output

service: web
replicas: 2
ports:
  - 80
  - 443
enabled: "yes"
YAML to JSON

Input

name: demo
tags:
  - api
  - beta
limits: {cpu: 0.5, memory: 512Mi}

Output

{
  "name": "demo",
  "tags": [
    "api",
    "beta"
  ],
  "limits": {
    "cpu": 0.5,
    "memory": "512Mi"
  }
}

Frequently asked questions

Is every JSON file valid YAML?

Almost: YAML 1.2 was designed as a superset of JSON, so practically any JSON document is also valid YAML. The reverse is not true, because YAML adds comments, anchors, multiple documents and more.

Why is yes quoted in my YAML output?

Older YAML 1.1 parsers, including PyYAML, read unquoted yes, no, on, off, y and n as booleans. Quoting them keeps your strings as strings everywhere. Turn the option off for pure YAML 1.2 output.

What happens to comments and anchors when converting to JSON?

JSON has no comments, so they are dropped. Anchors and aliases (& and *) and merge keys (<<) are expanded into full copies of the data they refer to.

How are dates and special numbers handled?

Values are read with the YAML 1.2 core schema, so 2026-10-19 stays a string rather than becoming a date. .inf and .nan have no JSON equivalent and become null, with a warning.

Guides that use this tool

  • JSON vs YAML: when to use which

    JSON and YAML describe the same data, but they fail in different ways. A practical guide to choosing between them, with the YAML gotchas that bite in production.