YAML Input

JSON Output

Success
Warning

What is a YAML to JSON Converter?

YAML is what humans write and JSON is what programs read. Kubernetes manifests, GitHub Actions workflows, Docker Compose files, Ansible playbooks, OpenAPI specs: all YAML, because indentation and comments are easier to live with than braces. But the moment you want to run jq over it, validate it against a JSON Schema, drop it into a request body, or diff it in a tool that only speaks JSON, you need the other form. That is what this page does: paste YAML on the left, get formatted JSON on the right as you type.

The parsing follows the YAML 1.2 specification, the same rules js-yaml applies in a Node project. The output is two-space indented and satisfies RFC 8259, but it is not a plain JSON.stringify of the parsed value, and that difference is deliberate. A JavaScript YAML parser normally resolves an integer scalar to a double, so iccid: 8944500102030405060 would come back as 8944500102030405000: a different SIM, reported as a success. Both halves of this page read the digits out of your source text instead, so that ICCID lands in the JSON as 8944500102030405060, unquoted and exact. All of it happens in your browser tab: your cluster secrets, connection strings and subscriber data never touch a server.

One thing to know before you convert anything: comments do not survive. JSON has no comment syntax, so every # line in your YAML is gone the moment it becomes JSON, and it cannot be recovered by converting back. If those comments are the only documentation for a production config, keep the YAML file as the source of truth and treat the JSON as a derived artifact.

How to Convert YAML to JSON

  1. Paste Your YAML – Drop a manifest, playbook, or .yml config into the left panel. A multi-document file (the ones split by ---, which is most Kubernetes manifests) comes out as a JSON array with one element per document, in source order.
  2. Watch the JSON Appear – JSON appears on the right without a Convert button. Typing pauses the conversion; 300 ms after your last keystroke the YAML is loaded again and the JSON beside it is rebuilt from scratch, two-space indented.
  3. Read the Error Line – If the YAML is broken, the output panel names the line and column, for example Invalid YAML (line 7, column 3): bad indentation of a mapping entry. Count to that line in the left editor and the problem is almost always right there or one line above.
  4. Check How Values Were Typed – YAML infers types from unquoted text. Scan the JSON for anything that came out as a number or boolean when you meant a string: version numbers and long identifiers are the usual casualties.
  5. Take the JSON Elsewhere – Copy it straight into a request body or a jq command, or use Download to get converted.json for a schema validator or a test fixture.

Pro Tip: If a value must stay a string, quote it in the YAML before converting. Unquoted, version: 1.20 arrives as "version": 1.20: the digits look right, but it is a number now, and the first JSON.parse downstream reads it as 1.2. version: "1.20" converts to the string "1.20" and stays that way. The same rule saves ICCIDs, IMSIs, phone numbers, ZIP codes, and anything else that is digits but not arithmetic.

Example

A short subscriber profile. Note what happens on the way across: the # provisioning defaults comment disappears (JSON has no comments), roaming: true becomes a real boolean, rsrp: -92 becomes a number, and the quoted iccid stays a string, which is exactly what you want for a 19-digit identifier.

YAML → JSON Convert
subscriber.yamlYAML
# provisioning defaults
subscriberId: SUB-1001
msisdn: "447700900142"
iccid: "8944500102030405060"
plan: Unlimited 5G
roaming: true
rsrp: -92
apns:
  - name: internet
    qci: 9
subscriber.jsonJSON
{
  "subscriberId": "SUB-1001",
  "msisdn": "447700900142",
  "iccid": "8944500102030405060",
  "plan": "Unlimited 5G",
  "roaming": true,
  "rsrp": -92,
  "apns": [
    {
      "name": "internet",
      "qci": 9
    }
  ]
}

Common Use Cases

Querying Kubernetes and CI Files with jq

kubectl can hand you JSON, but the manifest in your repo is YAML, and half the time the thing you want to inspect is the file on disk rather than the live object. Converting it here lets you run a jq expression against it, pipe it into a script, or paste it into a tool that only accepts JSON. The Kubernetes object documentation explains what the fields mean once you have them in front of you.

Validating a Config Against JSON Schema

Most schema tooling (JSON Schema validators, OpenAPI linters, IDE plugins) validates JSON. Convert the YAML first and you can check a deployment config or an API spec against its schema before it reaches a pipeline that fails at 2 a.m.

Turning a Hand-Written Fixture into Test Data

Writing test fixtures in YAML is far pleasanter than writing them in JSON: no trailing-comma errors, no quote soup, and you can comment each case. Author the fixture in YAML, convert it here, and commit the JSON your test harness actually loads.

Key Features

  • Live output – conversion waits until you pause for 300 ms, so typing into a long Helm manifest stays smooth.
  • Errors carry a position – A syntax error reads Invalid YAML (line 3, column 5): bad indentation of a mapping entry, taken from the parser's own mark rather than guessed.
  • Tabs named as the problem – A tab in the indentation is reported by line number as a tab, not as a vague "bad indentation" complaint further down.
  • Long integers stay intact – An unquoted 19-digit ICCID converts to a bare JSON number with every digit, not to the rounded double yaml.load alone would give you.
  • Document streams convert – ----separated manifests become a JSON array instead of an error.
  • YAML 1.2 Semantics – Parsed with the YAML 1.2 core schema, the same behaviour modern YAML tooling expects.
  • Stays in the tab – this converter has no share link, so no button on the page can post your YAML anywhere.

Frequently Asked Questions

Do comments survive the conversion?

No, and nothing can change that: JSON has no comment syntax. Every # ... line is dropped when the YAML becomes JSON, and converting the JSON back to YAML will not bring them back. Keep the YAML as the file you edit and the JSON as the file you generate. If a comment carries information a program needs, promote it to a real key such as _note: "leave qci at 9 until the core upgrade".

What is the "Norway problem"?

It is the old YAML 1.1 rule that NO, yes, on and off are booleans, which turns Norway's country code into false. Here the conversion uses the 1.2 core schema, so roaming_partners: [NO, SE, DK] comes out as ["NO", "SE", "DK"] and enabled: yes as the string "yes", not true. That second one surprises people the other way round: if your app expects a boolean, write true. Run the same file through PyYAML or Ruby's Psych and you get False for Norway, so quote "NO" in the source and every reader agrees.

Why is my version number not a string in the JSON?

Because YAML decided it was a number before JSON was involved. Unquoted, version: 1.20 resolves to a float. This page copies the digits across as written, so the JSON line reads "version": 1.20 and not the 1.2 a plain JSON.stringify would print, but a number has no use for a trailing zero: your app loads that line as 1.2. Put firmware: "1.20" beside it in quotes and that one converts to "firmware": "1.20", so the fix belongs in the source file. Two spellings JSON cannot carry are converted to their value instead: zip: 02134 becomes 2134 (JSON numbers cannot start with a zero) and 0x1F becomes 31. Long digit strings are the case that does not apply here: an unquoted iccid: 8944500102030405060 is past Number.MAX_SAFE_INTEGER, so a converter built on yaml.load plus JSON.stringify hands back 8944500102030405000 without complaint. This page reads that integer out of your source text rather than out of a double, so the output carries all nineteen digits as a bare JSON number. Quoting it is still the safer habit for whatever reads the file next, but you will not lose it here by forgetting.

My YAML looks aligned, so why is there a tab error?

Because one of those indents is a tab, and the YAML spec does not allow tabs in indentation at all. A tab and two spaces can look identical on screen, which is why the file seems fine to you and fails in every parser. This page detects a leading tab and tells you which line it is on. Set your editor to expand tabs to spaces for .yaml and .yml; two spaces per level is the community convention.

What happens to anchors and aliases?

They are expanded, not preserved. An anchor (&defaults) plus alias (*defaults) is YAML's way of writing a block once and reusing it; JSON has no equivalent, so each reference is replaced by a full copy of the block. A file with one shared block and five aliases becomes JSON with five duplicated objects. That is correct, but if you convert back to YAML afterwards, the sharing is gone and the file will be noticeably longer.

Is valid JSON also valid YAML?

Yes, the 1.2 spec was revised so that JSON text parses as YAML. Paste {"msisdn": "447700900142", "plan": "Unlimited 5G"} on the left and the right side is the same object, re-indented over four lines. That makes this page a quick pretty-printer for a one-line JSON payload, and it is why tools such as Helm accept a values file in either format.

Can it handle multi-document YAML?

Yes, and the result is a JSON array. JSON has no notion of a document stream, so a manifest holding a Service and a Deployment separated by --- comes out as [ { "kind": "Service", … }, { "kind": "Deployment", … } ], one element per document, in the order they appear. A single-document file is unaffected and still converts to a bare object. Worth knowing why this needs saying: a plain yaml.load call rejects a stream as a whole, and because that error is raised after both documents parse it carries no line or column, so many converters answer a two-document manifest with a message and no position at all.

Does converting send my YAML anywhere?

No. The YAML is parsed inside this tab and the JSON is built there too; this converter offers no share link, so there is no button that posts your text to a server. Download writes converted.json to your own disk. That matters for the files people bring here most: a values.yaml or a CI config usually has at least one token in it.

Related Tools

Useful Resources