JSON to YAML Converter
Convert JSON to YAML online. Choose 2 or 4 space indent, plain or double quotes, optional key sorting and line wrapping. Multi-line strings become block scalars.
How to use JSON to YAML
- 1Paste JSON into the input box, or open a .json file.
- 2Pick the indent, quote style and whether to sort keys or wrap long lines.
- 3Copy the YAML or download it as a .yaml file. The Mode switch also turns YAML back into JSON, formats, minifies, validates or browses it.
What makes it better
- YAML 1.2 output with 2 or 4 space indentation
- Multi-line strings written as readable block scalars
- Plain or double-quoted strings, optional key sorting and line wrapping
- Integers beyond 2^53 are kept exactly as typed
- Same page also does YAML to JSON, Format, Minify, Validate and Tree, with a validity line in every mode
About JSON to YAML
JSON to YAML rewrites a JSON document as YAML 1.2, the format used by Kubernetes manifests, GitHub Actions, Docker Compose and many config files. Multi-line strings become readable block scalars, and strings that YAML would read as another type, such as "true" or "123", are quoted so the data survives a round trip. A status line always says whether the input is valid and gives the line and column of any error, and the Mode switch turns the same box into a YAML converter, formatter, minifier, validator or tree viewer.
Common uses
- Turn a JSON API response or exported config into a YAML file for Kubernetes, Helm or Docker Compose.
- Convert an OpenAPI or CloudFormation template from JSON to the more readable YAML form.
- Move settings from a JSON file into a CI pipeline such as GitHub Actions or GitLab CI.
- Sort keys while converting so two config files produce a cleaner diff.
Example
Input
{
"name": "Acme API",
"version": "1.4.0",
"ports": [8080, 8443],
"database": { "host": "db.internal", "retries": 3, "ssl": true },
"banner": "Welcome\nBack"
}Result
name: Acme API version: 1.4.0 ports: - 8080 - 8443 database: host: db.internal retries: 3 ssl: true banner: |- Welcome Back
Good to know
- JSON has no comments, so the YAML has none either. Anything you add by hand afterwards is yours to keep, and the Format mode re-indents YAML without dropping comments.
- Duplicate keys in the JSON are merged by the last value, the way JavaScript reads them. Numbers with decimals go through JavaScript floating point, but whole numbers beyond 2^53 are kept exact.
- Repeated objects are written out in full rather than as YAML anchors and aliases, so the file stays easy to read and edit.
JSON to YAML FAQ
How do I convert JSON to YAML?
Paste the JSON into the left box and the YAML appears on the right as you type. Objects become indented key: value lines and arrays become lists with a dash. Use Copy or Download to take the result.
Why are some of my strings quoted in the YAML?
A plain YAML value such as true, null, 123 or 2024-01-15 would be read as a boolean, null, number or date. The converter quotes strings that look like those, and strings with characters such as a colon followed by a space, so reading the YAML back gives the same data.
What happens to multi-line strings?
Text that contains line breaks is written as a block scalar introduced by a pipe character, with each line indented underneath. It is far easier to read and edit than one long line full of \n escapes, and it means exactly the same string.
Is the YAML output indented with tabs?
No. YAML forbids tabs for indentation, so the output always uses spaces. You can choose 2 or 4 spaces per level in the options.
Can I turn the YAML back into JSON?
Yes. Choose YAML → JSON in the Mode switch above the box, or press Use as input to send the result straight into it. With the default options the round trip returns the same data, and the key order stays as it was in the JSON.