JSON to YAML

JSON to YAML

Convert JSON into tidy YAML, with control over indentation.

YAML Indent:
JS

JSON Input

πŸ“„

YAML Output

JSON β†’ YAML

Features

  • Convert JSON to YAML with configurable indentation
  • Handles nested objects, arrays, strings, numbers, booleans, and null
  • Preserves key order from the source JSON
  • Optional: sort keys alphabetically in output
  • Syntax error reporting for invalid JSON input
  • Copy converted YAML to clipboard

Common Use Cases

  • Convert API responses (JSON) to YAML for use in config files
  • Transform package.json or tsconfig.json to YAML for tooling that prefers it
  • Create Kubernetes manifests from JSON resource definitions
  • Convert OpenAPI/Swagger JSON specs to YAML format
  • Migrate JSON-based configuration to YAML for improved readability

JSON to YAML Conversion

YAML is a superset of JSON: every valid JSON document is also a valid YAML document. Converting from JSON to YAML therefore never loses data β€” it is a lossless transformation that changes only the representation.

The key differences in the output: YAML replaces {} with indentation-based mappings, [] with --prefixed lists, removes quotes from simple strings, and drops commas and braces entirely. The result is typically more compact and human-readable.

Special cases to be aware of: strings that look like numbers, booleans, or null values must be quoted in YAML to preserve their string type (e.g., the string "true" must be written as 'true' in YAML).

Examples

Valid - JSON input
{"name": "app", "port": 8080, "tags": ["web", "api"]}
Valid - YAML output
name: app
port: 8080
tags:
  - web
  - api

Frequently Asked Questions

Is YAML always better than JSON for config files?

YAML is more human-readable and supports comments, making it popular for config files. JSON is simpler (no indentation issues) and has universal parser support. For machine-to-machine communication (APIs), JSON is the clear winner. For files humans edit frequently (Kubernetes manifests, CI configs), YAML is often preferred.

Will string values like "true" or "null" be preserved?

The converter detects JSON strings that look like YAML reserved words (true, false, null) and wraps them in quotes to preserve their string type. Without quotes, true would be parsed as a boolean, changing the meaning of your data.

What happens to JSON null values?

JSON null is converted to YAML null (or an empty/tilde ~). Both are valid representations. This tool outputs the explicit null spelling for clarity.

πŸ’‘ Tips

  • After converting, run the result through the YAML Formatter to ensure consistent indentation.
  • If the source JSON has numeric string keys, they will be preserved as strings in YAML (quoted). Review manually if this matters for your use case.
  • For large JSON files, the YAML output may be significantly shorter β€” a good sign for config readability.