Skip to main content

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

JSON input
YAML output
name: Toolk
version: 1.0.0
tools: 90
free: true
features:
  - browser-only
  - fast
  - private
config:
  port: 3000
  ssl: true
  limits:
    requestsPerMinute: 60
    uploadMb: null

This 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

  1. Set the direction: JSON → YAML or YAML → JSON, using the toggle.
  2. Paste your source into the input panel, or click Load sample to see a typical config converted.
  3. Read the output the instant it converts — valid input produces output, bad input shows a line-numbered error.
  4. Use Swap to feed the output back as input and round-trip-test the conversion.
  5. 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

AspectJSONYAML
QuotingAll strings quoted with double quotesStrings usually unquoted; quote only when ambiguous
CommentsNo comments allowed (use JSONC or JSON5 extensions)Hash-prefixed (# comment)
Multi-line stringsSingle-line only with \n escapesBlock scalars (| literal, > folded), single-line as default
Structure delimitersBraces { } and brackets [ ] (explicit)Indentation (whitespace-significant)
Trailing commasForbidden (strict JSON); allowed in JSON5Not applicable — no commas in block style
Booleans / nulltrue, false, null (lowercase only)true/True/TRUE, false/False/FALSE, null/~/empty
Best forAPIs, machine-to-machine, configuration with strict schemaHuman-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.

ContextFormatNotes
Kubernetes manifestsYAML requiredapiVersion, kind, metadata, spec — all standard k8s files.
GitHub Actions workflowsYAML required.github/workflows/*.yml — name, on, jobs, steps.
Docker ComposeYAML requiredcompose.yaml or docker-compose.yml — services, volumes, networks.
CI configs (CircleCI, Travis)YAML requiredBuild pipelines historically standardized on YAML for human edit.
Ansible playbooksYAML required*.yml — tasks, hosts, vars, handlers.
REST API responsesJSON requiredAll major HTTP frameworks emit JSON by default.
package.json / tsconfig.jsonJSON requiredNode.js ecosystem manifests.
OpenAPI specsEitherOpenAPI 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.

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.

Need a different tool?

Browse all 103 browser-based tools (103 currently marked free), or tell us what useful utility we should build next.

Browse all tools