YAML 1.2 subset · K8s / Compose ready

Convert YAML to strict JSON

Parse YAML and emit valid JSON. Handles maps, sequences, scalars, flow collections, and anchors aren't supported.

YAML → JSON Workspace
Input size
87 B
8 lines
Output size
140 B
12 lines
Indent
2 sp
JSON pretty
Status
Valid
YAML 1.2 subset
Indent
input · yaml
output · json
{
  "name": "Ada",
  "active": true,
  "tags": [
    "admin",
    "founder"
  ],
  "meta": {
    "role": "engineer",
    "since": 2024
  }
}
Quick Start

How to convert YAML to JSON

The reverse of JSON to YAML. Drop in a Kubernetes manifest, GitHub Action, or Helm values file and get clean, indented JSON ready for tooling that doesn't speak YAML.

  1. 01

    Paste YAML

    Drop block-style YAML into the input. Flow collections ([...], {...}) work for JSON-compatible literals.

    Inputs parse through the native JSON.parse reviver chain — strict RFC 8259. Any syntax error returns line and column for the exact offending byte.

    k8sactionsRFC 8259JSON.parsestrict
    input · raw.yaml · RFC 8259
    name: ada
    active: true
    loaded · parsed RFC 8259RFC 8259 · ready
  2. 02

    Pick indent

    2 or 4 spaces for the output JSON.

    Indent options run through JSON.stringify(value, null, n); the second argument lets you sort, transform, or omit keys via a replacer if you ever wire one in.

    2sp4spindentJSON.stringifylive
    indent · optionsJSON · live
    {
      "name": "ada"
    }
    options applied · livelive
  3. 03

    Inspect parsed types

    Numbers, booleans, null (or ~), and quoted strings are auto-detected per YAML 1.2 scalar rules.

    Large documents stream through a useMemo with stable hashing so options re-apply instantly — no full re-parse if only formatting changes.

    scalarsmemoisedinstantdiff-friendlydeterministic
    types · renderedinferred · ready
    active: true → bool
    since: 2024 → int
    rendered · livediff-friendly
  4. 04

    Copy or download .json

    Pair with JSON Formatter for further pretty-printing.

    Download is a Blob with application/json; copy uses the Async Clipboard API. Both round-trip identically to what the page rendered.

    copydownloadclipboardblob.json
    export · copiedready · done
    ✓ Copied
    ✓ Saved
    shipped · ready to shipsuccess
Pro tips

Production-grade JSON, the right way

Stick to RFC 8259

Strict JSON has no NaN, Infinity, comments, or trailing commas. If you need those, look at JSON5 or JSON Repair.

Preserve key order for diffs

JavaScript preserves insertion order, but two parsers shouldn’t be assumed equal. Use Sort JSON Keys before diffing or hashing.

Big integers lose precision

JS numbers lose precision past 2^53−1. Transport large IDs as strings or use BigInt.

Escape inside HTML

When inlining JSON inside <script>, escape </ to <\/ so HTML parsing doesn’t close your tag early.

Validate at boundaries

Trust the wire as little as possible. Run incoming JSON through a schema (Zod / Pydantic) before it touches business logic.

Minify in production

Minify removes whitespace; gzip removes redundancy. Together they typically shrink JSON payloads 70–85% over the wire.

Use Cases

When to convert YAML to JSON

Anywhere downstream tooling needs JSON but your source is in YAML.

API integration

When you have a YAML config but need to POST it as JSON. Output round-trips losslessly through JSON.parse + JSON.stringify, so the file you save is byte-identical to what you see. Streaming parsers, jq pipelines, and Postgres jsonb columns all accept the result without complaint.

10× faster to scan

k8s → JSON tools

Some tools (kubectl plugins, audit tools) want JSON of the same resources. Pairs perfectly with sort-keys + diff for review-friendly fixtures in CI. Whitespace-only churn disappears and reviewers see real changes, which keeps PR comments focused on logic rather than indentation.

cleaner PR diffs

Pipeline conversion

Convert GitHub Action YAML into JSON for analysis or transformation. Handles emoji and non-ASCII via UTF-8 throughout — your data survives copy-paste between editors, terminals, and IDEs. Combining marks and ZWJ sequences come out the other side intact.

RFC 8259 valid

Schema validation

Validate YAML against a JSON Schema by converting first. Re-parses on every keystroke so syntax errors are caught at the exact character. Strict RFC 8259 — no trailing commas, no comments, no unquoted keys — keeps downstream parsers happy.

round-trip safe

Diff & compare

JSON diff tools beat YAML diff tools — convert, then compare. Streams large documents without a server round-trip — privacy stays in the tab. Heavy parsing runs through useMemo so even 5 MB payloads keep the editor responsive.

schema-friendly

Quick exports

Email or ticket-attach a JSON version when YAML rendering breaks formatting. Output is byte-stable: same input plus same options always produces identical bytes, ideal for content-addressed caches and snapshot tests. Downloads ship with the application/json MIME so editors apply syntax highlighting.

production-ready
FAQ

Frequently asked questions

A practical subset: block mappings/sequences, flow JSON-compatible collections, basic scalars, and quoting. Anchors (&) and aliases (*) are not supported.
Quoted strings work; folded (>) and literal (|) block strings are not yet supported.
Stripped during parsing — JSON has no comment syntax.
No. All parsing runs locally.
Yes.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!