JSON to YAML
Convert JSON into tidy YAML, with control over indentation.
JSON Input
YAML Output
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
{"name": "app", "port": 8080, "tags": ["web", "api"]}name: app
port: 8080
tags:
- web
- apiFrequently Asked Questions
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.
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.
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.