JSON to YAML Converter
Convert JSON to YAML while preserving the nesting
What is JSON to YAML Converter?
A JSON to YAML converter turns a JSON object into YAML indentation syntax level by level, which is what you need when moving an API response or a config fragment into YAML-first formats such as Kubernetes manifests and CI pipelines. The conversion runs inside the browser and nothing is uploaded.
How to use JSON to YAML Converter
- 1Paste your JSON into the input box; the tool validates that it is well-formed first.
- 2Choose an indentation width — 2 spaces is the norm across the Kubernetes ecosystem.
- 3Copy the YAML on the right and paste it into your target config file.
- 4For the opposite direction, switch to the YAML to JSON tool.
How do I do this in code?
Use the tool above for one-off work; for anything you repeat, move it into a script or your project.
import yaml from 'js-yaml';
const text = yaml.dump(JSON.parse(raw), { indent: 2, lineWidth: 120 });Common errors and how to fix them
| Symptom | Cause | Fix |
|---|---|---|
| The quotes around converted strings are gone | Most YAML strings do not need quotes, so dropping them is ordinary normalization. | Add the quotes back by hand for values like true, 123, or on that would otherwise be read as a different type. |
Frequently asked questions
Does converting JSON to YAML lose any data?+
No — JSON is a subset of YAML, so every value survives the conversion. Quoting is the one thing to watch: YAML strips unnecessary quotes, so a string value that looks like a boolean or a number may be read back as that type. Keep those values quoted.
Why does my YAML output contain |- or >-?+
Those are YAML block scalars, used for long strings that contain line breaks. |- keeps the newlines and trims the trailing blank line, while >- folds newlines into spaces. Both are equivalent representations of the same string and do not change the parsed result.
Related tools
All toolsYAML to JSON Converter
Convert YAML to JSON, multi-document files included
JSON to CSV Converter
Convert a JSON array of objects to CSV, with nested fields flattened automatically
CSV to JSON Converter
Convert CSV to JSON with automatic header and delimiter handling
JSON to TypeScript
Infer TypeScript type definitions from JSON
JSON to Go Struct
Convert JSON to Go structs with json tags filled in
JSON to Python Dataclass
Convert JSON to Python dataclasses or Pydantic models