Skip to content

YAML to JSON

Paste YAML to get JSON, and see exactly where YAML breaks.

0 characters · 0 lines

0 characters · 0 lines

Your files are open only in this tab. Nothing is uploaded.

Related tools: JSON formatter JSON to CSV

How to use YAML to JSON

  1. Paste YAML or open a file. Drop a .yaml or .yml file up to 20 MB into the YAML box, or click Try an example.
  2. Confirm Direction is set to YAML -> JSON. Use the Swap button anytime to flip between YAML and JSON.
  3. Fix any highlighted syntax errors. Click Go to line if a tab indentation or colon error appears.
  4. Copy or download the JSON output. Use Copy for the clipboard or Download to save data.json locally.

Everything runs in this browser tab. Nothing you paste or open is uploaded or logged, so it's safe for keys, tokens and private data.

YAML vs JSON: how the YAML 1.2 specification maps to RFC 8259

YAML 1.2 is designed as a strict superset of JSON, meaning every valid JSON document is valid YAML, but converting YAML back to JSON requires expanding references and stripping comments. This converter outputs clean 2-space indented JSON ready for APIs and jq pipelines.

Feature YAML 1.2 JSON (RFC 8259) Conversion behavior
Comments (# ...) Supported anywhere Not allowed Stripped from JSON output
Anchors (&) and aliases (*) Native node reuse Not supported Expanded into full JSON values
Merge keys (<<: *base) Supported via merge: true Not supported Merged with explicit overrides kept
Multi-line strings (| and >) Native block scalars Escaped \n strings Serialized as single-line JSON strings
Multi-document streams (---) Multiple docs per file Single root value Wrapped into a JSON array [...]

Why YAML 1.2 treats unquoted NO and off as strings

Under the YAML 1.2.2 Official Specification, boolean literals are limited to true and false, fixing the legacy YAML 1.1 quirk where unquoted NO, yes, on, and off coerced into booleans. That prevents country codes, feature flags, and port labels from silently mutating when converted for JSON APIs.

Once your YAML is converted, you can inspect or sort keys alphabetically using the strict RFC 8259 JSON formatter and validator if you need canonical key ordering.

Block scalars, multi-line strings, and stripped comments

Configuration files for Docker Compose, GitHub Actions, and Ansible rely heavily on literal (|) and folded (>) multi-line blocks. The parser translates literal blocks with intact \n escapes and folded blocks with spaces, preserving trailing newline chomping indicators (|- or |+) so multi-line shell scripts or certificates stay accurate.

Because JSON forbids comments, any # annotations in your YAML file are removed during conversion. Keep the original YAML source when you still need inline human notes.

How do YAML merge key expansion and multi-document YAML streams work?

Because IETF RFC 8259 JSON Data Interchange Standard permits only one root value and zero pointer syntax, the converter expands anchors, aliases, and << merge keys into standalone JSON structures. Multi-document streams separated by --- automatically become a JSON array.

Tip: Click Swap (⇄) after inspecting your JSON output to switch Direction to JSON → YAML and verify how the structure round-trips back to YAML.

Resolving anchors (&), aliases (*), and << merge keys

The parser runs with merge: true, so &defaults anchors referenced by *defaults or <<: *defaults expand directly into every target object. Explicit keys defined locally inside a service block override inherited anchor keys cleanly.

If you ever need to move in the opposite direction after editing a JSON payload, you can convert JSON payloads back into readable YAML from the same interface by toggling Direction.

Converting — multi-document Kubernetes manifests into arrays

Kubernetes manifests and Helm templates frequently bundle Deployments, Services, and ConfigMaps into one file separated by ---. Calling parseAllDocuments() reads every document in the stream, filters out trailing empty --- markers, and emits a JSON array [...] when more than one document is present.

Single-document YAML files emit the root object or array directly without an extra outer wrapper. That makes piping converted Kubernetes output into jq queries, REST API test suites, or JSON Schema validators completely predictable.

Preserving 64-bit integers and catching tab indentation errors

Standard JSON.parse() and JSON.stringify() in JavaScript cast every number to a 64-bit float, silently rounding integers larger than 53 bits. This converter avoids that data loss and catches indentation mistakes by line and column.

Keeping >53-bit IDs exact with intAsBigInt

Twitter/Discord Snowflake IDs, Stripe trace IDs, and 64-bit database keys exceed Number.MAX_SAFE_INTEGER (9,007,199,254,740,991). The parser enables intAsBigInt: true so large integers stay BigInt values as defined in the MDN JavaScript BigInt Reference, while safe integers normalize back to native numbers.

During JSON serialization, stringifyWithBigInts() writes exact unquoted digit tokens instead of throwing a TypeError or rounding trailing digits to zero. After converting structured arrays of records, you can flatten converted JSON records into spreadsheet rows for reporting.

Jumping to tab and syntax errors with Go to line

YAML forbids literal tab characters (\t) for indentation and fails on unquoted colons followed by spaces inside strings. Mixing two-space and four-space indentation levels inside the same mapping or sequence also triggers a structural parse failure.

When YAMLParseError occurs, the tool extracts the 1-based line and column and displays a Go to line button that scrolls and highlights the exact line. Fixing the highlighted indent or quoting the colon immediately updates the live JSON output.

Local browser privacy for CI configs, Helm values, and large files

DevOps manifests often contain database hosts, internal service URLs, and environment keys that should never touch third-party servers. Processing YAML inside your browser tab keeps all configuration data strictly on your machine, with zero telemetry or server-side caching.

  • Zero server uploads: Parsing, anchor expansion, and JSON serialization run locally in memory with no network calls, even for sensitive production templates.
  • Large-file Web Worker offload: Inputs over 65,536 characters (64 KB) automatically move to a dedicated Web Worker with a 120 ms debounce, supporting .yaml and .yml files up to 20 MB.
  • Clean local exports: Click Download to save data.json directly from browser memory, or keep the original filename stem when opening a local file.
  • Multi-format config pipelines: When your data workflow also ingests delimited spreadsheets alongside YAML manifests, you can convert CSV files into structured JSON in the same local suite.

Questions

Does standard JSON support multi-document streams separated by ---?

No. Standard JSON requires a single root value. When your YAML input contains multiple documents separated by --- markers, this converter wraps them into a top-level JSON array and omits any empty trailing marker.

How do YAML anchors and merge keys expand into JSON?

JSON has no reference syntax, so the parser resolves every &anchor, *alias, and << merge key into concrete values during conversion. Explicit keys in the target mapping override any conflicting keys inherited from the merged anchor.

What happens to YAML comments during JSON conversion?

All # comments are stripped because the RFC 8259 JSON specification has no comment syntax. If you need to keep documentation alongside configuration values, retain the original YAML source file.

Why does unquoted NO or off stay a string in YAML 1.2?

YAML 1.1 treated unquoted yes, no, on, and off as booleans, which famously turned the country code NO into false. YAML 1.2 restricts booleans strictly to true and false so unquoted NO and off remain strings.

How do literal and folded YAML block scalars convert to JSON?

Literal blocks (|) preserve every newline as escaped \n characters inside a single JSON string, while folded blocks (>) join single line breaks into spaces while keeping blank lines as newlines.

Are private Kubernetes manifests or CI secrets uploaded to a server?

No. Every parse and serialization step runs locally inside your browser tab or Web Worker, so Kubernetes manifests, Helm values, and CI environment files never leave your device.

Updated