To convert JSON to YAML, paste your JSON into the Input box or upload a .json file. With Live Convert on, the YAML appears right away; otherwise select Convert Now. Objects become indented key: value lines and arrays become - lists. The same box converts YAML to JSON: paste YAML and the output switches to JSON.
How to convert JSON to YAML
- Paste or upload. Paste JSON or YAML into Input, or choose Select File for a .json, .yaml, .yml or .txt file. Load JSON Sample and Load YAML Sample show both directions.
- Check the direction. Conversion is on Auto detect: input that starts with
{or[and parses as JSON goes to YAML, and anything else is read as YAML. Pick JSON → YAML or YAML → JSON to force it. - Adjust the output. Set YAML Indent, JSON Indent and YAML Line Width, and tick Sort keys if you want alphabetical order.
- Save it. Select Copy Output or Download. The file is saved as .yaml or .json with your original file name.
What a JSON to YAML converter changes
YAML 1.2 can represent everything JSON can, so the conversion keeps all your data and only changes the syntax. Braces and brackets give way to indentation, quotes are dropped where they aren't needed, and arrays become dash lists. This JSON:
{"app": "api", "replicas": 3, "debug": false, "ports": [80, 443],
"db": {"host": "db.local", "user": null}, "enabled": "yes"}converts to:
app: api
replicas: 3
debug: false
ports:
- 80
- 443
db:
host: db.local
user: null
enabled: "yes"Notice that "yes" keeps its quotes. Older YAML 1.1 parsers read a bare yes as the boolean true, so the converter (built on the js-yaml 4.1.0 library) quotes strings like that to keep them strings everywhere. Compact YAML arrays is on by default and writes list items flush with their key; untick it to indent them by two spaces, the style many Kubernetes and Ansible files use.
Convert YAML to JSON
Paste YAML and the output switches to JSON with 2-space indentation, or 4 spaces, or minified on one line. Tick Escape unicode in JSON to write characters like é as \u00e9. A few YAML features have no JSON equivalent, so check these before you rely on the output:
| YAML input | JSON output | Why |
|---|---|---|
# comment | Removed | JSON has no comments |
&base and *base | Copied in full | Anchors and aliases are expanded, and << merge keys are applied |
when: 2026-10-11 | "2026-10-11T00:00:00.000Z" | Unquoted dates are read as timestamps |
version: 1.10 | 1.1 | Unquoted, it's a number, so the trailing zero goes |
country: NO | "NO" | YAML 1.2 keeps it a string; YAML 1.1 tools like PyYAML read it as false |
Quote values such as versions and dates in your YAML if you need them as exact strings. A file with several documents separated by --- fails with "expected a single document in the stream"; split it and convert one document at a time.
YAML vs JSON: which one to use
Use YAML for files people edit by hand: Docker Compose, Kubernetes manifests, GitHub Actions workflows, OpenAPI specs. It allows comments and has less punctuation to get wrong. Use JSON for data machines exchange: API payloads, package.json, browser storage. Every major language parses JSON with its standard library, while YAML usually needs an extra package.
Indentation is the classic YAML trap. A list item one space off changes which key it belongs to, and tabs aren't allowed for indentation at all. If a YAML file behaves oddly, convert it to JSON here and the braces show exactly how it was parsed. For JSON that won't parse, use the JSON formatter to find the bad line, and for tabular JSON try the JSON to CSV converter.
YAML output options
- YAML Line Width: No wrap keeps long strings on one line. 80 or 120 rewrites long strings as folded blocks (
>-) that wrap at that width; they still load as the same single-line string. - YAML Quote Style: Auto and Double quotes use
"..."when quoting is needed; Single-like output uses'...'. - Force YAML quotes: quotes every string value (keys stay bare), so nothing can be misread as a number, boolean or date.
- Sort keys: orders keys alphabetically at every level, in both directions.
Analyze Input (Ctrl+K) shows the root type, object and array counts, total keys, maximum depth and a tree preview. Everything runs locally in your browser, so secrets in config files aren't uploaded.
Frequently asked questions
How do I convert YAML to JSON?
Paste the YAML into the input box. Auto detect recognizes it as YAML and shows JSON in the output, or you can set Conversion to YAML → JSON. Then copy or download the .json file.
Is JSON valid YAML?
Almost always. YAML 1.2 was designed so that JSON documents are valid YAML, which is why YAML tools can read most JSON files directly.
Are YAML comments kept when converting to JSON?
No. JSON has no comment syntax, so comments are dropped. Converting the JSON back to YAML won't restore them.
Why does my YAML fail to convert?
The most common causes are tab characters used for indentation, inconsistent indentation, an unquoted value containing : , or several documents separated by ---. The status line under the buttons shows the parser's message, usually with a line number.
Can I convert a JSON file to YAML for Kubernetes?
Yes. Upload or paste the JSON manifest, untick Compact YAML arrays if your team indents list items, and download the .yaml file.
Is my config data uploaded?
No. The conversion runs in your browser with the js-yaml library, so API keys or passwords in your files stay on your device.