JSON to YAML and YAML to JSON Converter
Convert JSON to YAML or parse the supported YAML subset into JSON. Review the output before using it in a configuration file.
JSON to YAML Converter workspace
name: Toolk
version: 1.0.0
tools: 90
free: true
features:
- browser-only
- fast
- private
config:
port: 3000
ssl: true
limits:
requestsPerMinute: 60
uploadMb: nullThis converter implements the most common subset of YAML 1.2 block style — mappings, sequences, scalars, comments, and nesting. Advanced features (anchors, aliases, multi-line block scalars, flow style mixed with block style) may not round-trip perfectly. For complex YAML, double-check your output before deploying.
Bidirectional
JSON → YAML with proper block-style indentation and string quoting. YAML → JSON with a focused YAML-subset parser tuned for real-world config files.
Inline Error Reporting
Malformed input shows a line-numbered error message — no silent failures. Spot the missing colon or unbalanced brace immediately.
One-Click Copy + Sample Loaders
Copy converted output to clipboard. Load sample JSON or YAML to see exactly what the converter produces from typical config patterns.
100% Client-Side
No uploads, no API calls. Configs may contain secrets — they stay in your browser. Works offline once loaded.
JSON to YAML Converter: Bidirectional, Spec-Aware, In-Browser
Convert JSON to YAML or parse the supported YAML subset into JSON. Review the output before using it in a configuration file. JSON and YAML do not represent every construct in the same way. This tool's custom YAML parser supports a subset rather than every YAML feature. Check scalars, dates, anchors, tags, and nested structures against the implemented limits before relying on a round trip.
How to use this JSON & YAML converter
- Set the direction: JSON → YAML or YAML → JSON, using the toggle.
- Paste your source into the input panel, or click Load sample to see a typical config converted.
- Read the output the instant it converts — valid input produces output, bad input shows a line-numbered error.
- Use Swap to feed the output back as input and round-trip-test the conversion.
- Press Copy to send the result to your clipboard for your manifest, workflow, or API call.
What is YAML, and how does conversion work?
YAML ("YAML Ain't Markup Language") is a human-friendly data format that uses indentation instead of braces. Since the YAML 1.2 specification, YAML is an official superset of JSON — every valid JSON document is also valid YAML. JSON itself is defined by RFC 8259 and ECMA-404.
JSON → YAML parses your text with the browser's native JSON.parse(), then walks the tree and emits block-style YAML at 2-space indentation. A string is left unquoted unless it would be ambiguous — the serializer quotes anything that looks like a number, matches a reserved word (true, false, null, yes, no, ~), or contains structural characters. YAML → JSON strips # comments (respecting quoted text), reads indentation to rebuild the tree, and serializes with JSON.stringify().
"YAML prohibits tab characters for indentation to eliminate the tab-versus-space ambiguity."— YAML 1.2.2 spec. Use spaces only; the recommended and most-used indent is 2 spaces per level.
Worked examples: input → output
JSON → YAML · nested object
{"port": 3000, "ssl": true} → port: 3000 ssl: true
JSON → YAML · array of scalars
{"features": ["browser-only", "fast"]} → features: - browser-only - fast
Edge case · the Norway problem
In YAML, unquoted country: NO parses here as the string "NO", not the boolean false. This tool follows YAML 1.2, where only true/false (and their capitalized forms) are booleans. Older YAML 1.1 parsers turned Norway's code NO into false — the famous bug. Quote it as country: "NO" to be safe across every parser.
Edge case · big-integer precision loss
An unquoted id: 9007199254740993 (above 253) is parsed with JavaScript's parseInt, which silently rounds it to 9007199254740992. Quote large IDs and nanosecond timestamps as strings — id: "9007199254740993" — to keep every digit.
JSON vs YAML: eight differences that matter
| Aspect | JSON | YAML |
|---|---|---|
| Quoting | All strings quoted with double quotes | Strings usually unquoted; quote only when ambiguous |
| Comments | No comments allowed (use JSONC or JSON5 extensions) | Hash-prefixed (# comment) |
| Multi-line strings | Single-line only with \n escapes | Block scalars (| literal, > folded), single-line as default |
| Structure delimiters | Braces { } and brackets [ ] (explicit) | Indentation (whitespace-significant) |
| Trailing commas | Forbidden (strict JSON); allowed in JSON5 | Not applicable — no commas in block style |
| Booleans / null | true, false, null (lowercase only) | true/True/TRUE, false/False/FALSE, null/~/empty |
| Best for | APIs, machine-to-machine, configuration with strict schema | Human-edited configs (Kubernetes, GitHub Actions, Docker Compose) |
| File extensions | .json, .jsonc, .json5 | .yml, .yaml |
Where each format is the standard
YAML dominates human-edited infrastructure config; JSON dominates machine-to-machine payloads. This table maps the common contexts so you know which way to convert.
| Context | Format | Notes |
|---|---|---|
| Kubernetes manifests | YAML required | apiVersion, kind, metadata, spec — all standard k8s files. |
| GitHub Actions workflows | YAML required | .github/workflows/*.yml — name, on, jobs, steps. |
| Docker Compose | YAML required | compose.yaml or docker-compose.yml — services, volumes, networks. |
| CI configs (CircleCI, Travis) | YAML required | Build pipelines historically standardized on YAML for human edit. |
| Ansible playbooks | YAML required | *.yml — tasks, hosts, vars, handlers. |
| REST API responses | JSON required | All major HTTP frameworks emit JSON by default. |
| package.json / tsconfig.json | JSON required | Node.js ecosystem manifests. |
| OpenAPI specs | Either | OpenAPI accepts both — YAML for human edit, JSON for tooling. |
The multi-document limit competitors gloss over
Kubernetes files often pack several resources into one file separated by --- document markers. Review these limits before using the result. The parser skips every --- line rather than splitting on it, so a multi-document file is merged into a single structure instead of an array of documents. The fix is mechanical: split your file at each ---, convert each document on its own, then combine the JSON outputs into an array yourself.
Two more deliberate behaviors worth knowing: special floats serialize the YAML way — Infinity becomes .inf, -Infinity becomes -.inf, and NaN becomes .nan. And empty collections stay in flow style: an empty object emits {} and an empty array emits [], not a blank block.
Gotchas when round-tripping JSON to YAML and back
1. Comments are lost
JSON has no comment syntax. A YAML → JSON → YAML round-trip drops every # comment. Keep the YAML source if comments carry context.
2. The Norway problem
YAML 1.1 treated NO, YES, ON, OFF as booleans, so NO became false. This parser follows 1.2, so they stay strings. Quote ambiguous values anyway.
3. Numeric precision
JavaScript numbers max out at 253. Large IDs and nanosecond timestamps round to the nearest float. Quote them as strings to preserve precision.
4. Indentation is normalized
JSON → YAML always emits 2-space indentation. Tabs are illegal in YAML — convert tabs to spaces before parsing, or you will hit a line-numbered error.
Related developer & config utilities
Beautify and validate JSON
YAML ValidatorSyntax check with line-precise errors
JSON DiffSemantic compare of two payloads
JSON Schema GeneratorInfer a schema from sample JSON
JSON to TypeScriptGenerate interfaces from JSON
CSV to JSON ConverterReshape tabular data to JSON
XML FormatterPretty-print SOAP, RSS, sitemaps
SQL FormatterFormat queries that feed your JSON
Base64 EncoderEncode config secrets for transport
All ToolsBrowse the full Toolk hub
Guide: JSON vs YAML vs XMLWhen to pick each data format
Guide: JSON ValidationFormat and validate JSON correctly
Last updated: September 15, 2026 · Runs 100% in your browser — no uploads, tool input is not sent to Toolk.
Frequently asked questions
Which parts of YAML does the converter understand?
The YAML 1.2 block subset that real configuration uses: mappings, sequences, scalars, # comments, and deep nesting. Anchors and aliases, custom tags, block scalars (| and >), and flow-style collections are outside that subset and will be rejected rather than silently misread.
Why did my large integer change value after converting?
JavaScript stores every number as an IEEE 754 double, so integers above 2^53 − 1 (9,007,199,254,740,991) lose their final digits during parsing. Quote big database IDs and nanosecond timestamps as strings in the source document and every digit survives both directions.
What happens to comments when converting YAML to JSON?
They are dropped — JSON has no comment syntax to carry them into. If you round-trip back to YAML afterwards, expect a clean document without the original annotations, so keep a copy of commented source files before converting.
Do secrets in Docker Compose or CI files leave my device?
No. Parsing and serialization run locally in your tab, and Toolk’s page analytics do not receive either document — which matters because config files routinely embed tokens and passwords. Conversion keeps working offline once the page has loaded.
How do I check a converted file is still valid config?
Convert first, then paste the result into Toolk’s YAML Validator (/tools/yaml-validator) before committing it. It parses the document independently and points at the exact line of any syntax problem, catching indentation slips that hand-editing introduces.