JSON to YAML Converter — and YAML Back to JSON
Paste JSON and get block-style YAML with safe quoting, or switch to YAML → JSON to turn a config file into JSON. Everything runs locally in your browser; nothing is uploaded.
Related tools
- XML to JSON Converter Convert XML to JSON with attributes, repeated elements as arrays and CDATA, ideal for SOAP responses, RSS feeds and sitemaps.
- Data Converter Convert between JSON, XML, YAML and CSV formats and Unix timestamps. Format conversion with clear error messages and customizable output formatting.
- Unix Timestamp Converter Convert Unix timestamps to readable dates and dates back to epoch time, in seconds or milliseconds.
- CSV to JSON Converter Convert CSV to a JSON array of objects, with comma, semicolon or tab delimiter and the header row as keys.
Features
- JSON to YAML and YAML to JSON in one tool
- Block-style YAML with two-space indentation
- Quotes strings YAML would misread, such as "yes", "8080" or "nginx:1.27"
- Reads comments, quoted strings, nested lists and lists of objects
- JSON output with 2 or 4 spaces, tabs or compact
- Runs entirely in your browser, nothing is uploaded
JSON or YAML: When You Need to Convert
YAML holds the same data as JSON (objects, lists, strings, numbers, booleans and null) but uses indentation instead of braces and allows comments. That is why configuration lives in YAML: Kubernetes manifests, docker-compose.yml, GitHub Actions workflows and many OpenAPI specs.
APIs and scripts, on the other hand, speak JSON. Convert JSON to YAML when an API response should end up in a manifest, and YAML to JSON when code or a JSON-only system needs your config. The page opens in JSON → YAML mode; YAML → JSON is in the same dropdown.
How the Converter Writes YAML
- Indentation: always two spaces per level, with list items indented under their key. The Indentation setting only affects JSON output (YAML → JSON).
- Quoting: a string gets quotes only where a YAML parser would read it differently: number-like values (
"8080","3.8"), words like"yes","no","on","off","true"or"null", empty strings and anything containing:,#or quotes. Keys follow the same rule. - Line breaks stay escaped as
inside double quotes; the converter does not write|or>blocks. - Empty objects and lists become
{}and[].
Example: a docker-compose Service
This JSON
{"services":{"web":{"image":"nginx:1.27","ports":["8080:80"],"environment":{"DEBUG":"false"},"restart":"always"}}}becomes this YAML:
services:
web:
image: "nginx:1.27"
ports:
- "8080:80"
environment:
DEBUG: "false"
restart: alwaysThe image tag and the port mapping are quoted because of the colon, and "false" stays a string instead of turning into a boolean. Switch to YAML → JSON, paste the result back, and you get the same data as JSON again.
YAML to JSON: What the Parser Understands
The YAML reader covers what typical config files use: nested mappings, lists (also at the same indentation as their key), lists of objects like - name: web, comments, single- and double-quoted strings, unquoted values with colons such as nginx:1.27, true/false, null/~, integers, decimals and simple inline lists like [main, dev]. It is a subset, not a full YAML parser:
- Anchors, aliases and merge keys (
&base,*base,<<:) are not resolved: they stay as text or cause an error. - Block scalars (
|and>), common inrun:steps, stop with an indentation error. - Inline objects like
{a: 1}stay a string, and a comma inside a quoted list item splits it. - Several documents:
---separators are skipped, so the documents are merged into one object. - Types: only lowercase
trueandfalsebecome booleans;yes,on,True,1e5,0x1Fand dates stay strings.
For files that rely on these features, use a full YAML library.
Useful Resources