Convert JSON to YAML or YAML to JSON instantly — paste either format, auto-detected. Supports nested objects, arrays, multi-line strings, flow style and all scalar types.
Both JSON and YAML are data serialization formats used to represent structured data. YAML is a superset of JSON — every valid JSON document is also valid YAML 1.2. The two formats are interchangeable in most contexts, but have different strengths:
| Feature | JSON | YAML |
|---|---|---|
| Comments | Not supported | Supported (#) |
| Verbosity | More punctuation ({}, [], "") | Minimal — relies on indentation |
| Multi-line strings | Must escape newlines as \n | Literal (|) and folded (>) block scalars |
| Data types | String, Number, Boolean, Null, Array, Object | All of JSON + timestamps, binary, custom tags |
| Anchors & aliases | No — content must be repeated | Yes — define once, reference with *alias |
| Human readability | Good for small payloads | Excellent for large configs |
| Machine parsing | Simpler, faster | More complex, multiple spec versions |
| Common use cases | REST APIs, web apps, databases | Config files (K8s, Docker Compose, CI/CD, Ansible) |
The converter runs entirely in your browser — no data is sent to a server. It handles both directions:
JSON.parse(), then serialized to YAML using indentation-based block syntax. Strings that require quoting (containing :, #, YAML keywords like true, null) are automatically wrapped in double quotes. Multi-line strings become literal block scalars (|).{} and []), quoted strings, block scalars (| and >), and all scalar types (string, integer, float, boolean, null, infinity, NaN). Anchors and custom tags are not supported — use a full YAML library for those features.YAML infers types from the value syntax. Understanding this avoids surprises when converting:
| YAML value | JSON type | Notes |
|---|---|---|
| 42 | number (integer) | |
| 3.14 | number (float) | |
| true / True / TRUE | boolean true | All three are valid |
| false / False / FALSE | boolean false | |
| null / Null / NULL / ~ | null | |
| "42" | string "42" | Quotes force string type |
| 0x1F | number 31 | Hexadecimal literal |
| .inf / .Inf | Infinity (not valid JSON) | JSON has no Infinity literal |
| .nan / .NaN | NaN (not valid JSON) | JSON has no NaN literal |
| 2001-01-23 | string (timestamp) | YAML 1.1 parsed as date; YAML 1.2 treats as string |
YAML provides two block scalar indicators for multi-line strings — critical when converting from JSON strings that contain newlines:
|): Newlines are preserved exactly. A trailing newline is added. Use |- to strip the trailing newline.>): Single newlines become spaces; blank lines become actual newlines (paragraph separator). Useful for long prose.This converter always uses the literal block style (|) for JSON strings containing \n characters.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
labels:
app: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
This typical Kubernetes manifest converts cleanly to JSON, with all nested keys preserved.
{
"openapi": "3.0.0",
"info": {
"title": "Pet Store API",
"version": "1.0.0",
"description": "A sample API"
},
"servers": [
{ "url": "https://api.example.com/v1" }
]
}
JSON APIs often need to be converted to YAML for OpenAPI spec files used by tools like Swagger UI, Redoc, or Stoplight.
# YAML input
debug: true
database: null
retries: 3
ratio: 0.75
name: "true" # quoted → stays a string
YAML's unquoted true, false, and null become JSON's native true, false, and null. Quoting them forces the string type.
Yes, in YAML 1.2. JSON is a subset of YAML 1.2, so a conforming YAML 1.2 parser can parse any valid JSON. YAML 1.1 (used by older parsers like PyYAML by default) has some incompatibilities — for example, it treats on, off, yes, no as booleans, while JSON and YAML 1.2 treat them as strings.
YAML was designed to be maximally human-readable. Indentation eliminates the visual noise of braces, brackets, and quotes, making config files easier to read and write by hand. The trade-off is that indentation errors are harder to spot than mismatched braces, and YAML parsers are significantly more complex to implement than JSON parsers.
The following YAML features are not handled: anchors and aliases (&anchor / *alias), custom tags (!!python/object), merge keys (<<: *defaults), multi-document streams (only the first document is parsed), and complex keys (non-string mapping keys). For these features, use a full YAML library such as js-yaml (JavaScript), PyYAML or ruamel.yaml (Python), or gopkg.in/yaml.v3 (Go).
Wrap the value in quotes. For example, version: "1.10" stays a string, while version: 1.10 becomes the number 1.1 (trailing zero dropped by float parsing). This is especially important for version strings, phone numbers, zip codes, and IDs that happen to look like numbers.
| (literal block scalar) preserves newlines exactly as written. > (folded block scalar) collapses single newlines into spaces — only blank lines create actual newlines. Use | for code, shell scripts, or any content where newlines matter. Use > for long prose descriptions where you want word wrapping in the YAML file but a single paragraph in the output.
Yes. YAML supports .inf (infinity), -.inf (negative infinity), and .nan (not-a-number), which have no JSON equivalents. When converting YAML containing these values to JSON, this converter renders them as the strings "Infinity", "-Infinity", and "NaN" to avoid producing invalid JSON. YAML also supports binary data, timestamps, and arbitrary custom types via tags.
The indent setting (2 or 4 spaces) only affects the output of this converter. When converting YAML → JSON and back to YAML, the output indent is determined by the "Indent" toggle at the top, regardless of the original YAML's indent. YAML allows any consistent indentation — 2 and 4 spaces are both valid and commonly used.
All conversion runs locally in your browser using JavaScript. No data is transmitted to any server. The page has no analytics, no data collection, and no server-side processing. You can safely paste secrets, API keys, and internal configuration files — nothing leaves your machine.