Switch instantly between YAML → JSON and JSON → YAML to inspect CI workflows, Helm values, or OpenAPI specs, complete with multiline literal block (|) support and safe string quoting.
YAML dominates cloud-native infrastructure—Kubernetes deployments, GitHub Actions, Wrangler configs, and OpenAPI definitions—yet jq pipelines, JSON Schema validators, and REST APIs expect strict JSON.
This bidirectional converter strips YAML comments safely without mangling hash characters inside quoted strings, resolves anchors, honors literal (|) and folded (>) blocks, turns multi-document Kubernetes files into an array, and quotes ambiguous scalars when exporting back to YAML so round-trips preserve exact types.
Classic YAML Gotchas That Break Deployments
01. The Norway Problem (Unquoted Booleans)
Legacy YAML 1.1 parsers silently coerce bare values like NO, on, or off into booleans, turning Norway country code NO into false. YAML 1.2 restricts booleans strictly to true and false, and our serializer quotes ambiguous words automatically.
02. Tab Indentation Parse Failures
Unlike Makefiles or Go files, YAML forbids tab characters for block indentation. Pasting snippets from terminals or spreadsheets often sneaks in leading tabs; this parser catches the exact offending line immediately.
03. Unquoted Version Numbers Turning Into Floats
Writing version: 1.10 without quotes parses as the float 1.1, silently dropping the trailing zero in container tags or API versions. Wrap semantic version strings in quotes.
YAML 1.2 Construct Mapping
| YAML Construct | JSON Output | Notes |
|---|---|---|
| Block Mapping | Indented key: value pairs | host: db -> {"host":"db"} |
| Block Sequence | Dash-prefixed list items | - us-east -> ["us-east"] |
| Literal Block (|) | Preserves embedded line breaks verbatim | script: |\n echo hi |
| Folded Block (>) | Joins single newlines into spaces | desc: >\n line one |
| Flow Syntax | Inline brackets and braces inside YAML | ports: [80, 443] |
Worked Engineering Examples
Converting a Sequence of Service Objects
services:
- name: auth
port: 8081
- name: billing
port: 8082 {"services":[{"name":"auth","port":8081},{"name":"billing","port":8082}]} Inline sequence-of-mappings notation translates cleanly into an array of structured JSON objects.
Safe Quoting on JSON to YAML Export
{"country":"NO","portLabel":"0800","tag":"v1:latest"} country: "NO" portLabel: "0800" tag: v1:latest
Strings that look like numbers or YAML 1.1 booleans are wrapped in double quotes so every parser keeps them as strings.
Frequently Asked Questions
Does YAML to JSON preserve comments?
JSON has no comment syntax in RFC 8259, so comments are stripped during YAML-to-JSON conversion while # symbols inside quoted strings stay intact.
Why does the converter reject leading tabs?
The official YAML specification prohibits tabs as indentation whitespace because editors render tab stops inconsistently. Replace leading tabs with two spaces.
How are multiline strings exported when converting JSON back to YAML?
Strings containing newline characters automatically serialize using YAML literal block syntax (| or |-) so multi-line scripts and PEM snippets remain readable.
Can I swap output back into the input pane to test round-tripping?
Yes. Click Swap in the action toolbar to invert direction and feed the generated document back through the opposite parser.