YAML to JSON

Converter

Convert YAML data to formatted JSON with full nested structure support. Paste config files for clean, 2-space-indented JSON you can drop into any project; anchors expand and multiple documents become an array.

Converted
YAML
6 lines
JSON
8 lines

About YAML to JSON

Converting YAML to JSON shows up in two situations. The first is sending a Kubernetes manifest or CI configuration to an API that only accepts JSON, which is common among cloud platform REST endpoints. The second is reading YAML configuration reliably inside code: YAML has so many implicit typing rules that different language implementations can disagree, and converting to JSON first removes that uncertainty. The mechanism parses YAML text into a tree and serializes it as JSON. The critical difference is YAML's implicit typing: unquoted numbers become numeric types, yes and no become booleans under the older specification, a value like 1.10 may be treated as a number and lose its trailing zero, and hexadecimal plus scientific notation follow their own rules. The converter reports exactly what the parser produced, so a value that "looks like text but became a number" has to be fixed at the source with quotes. Practical notes: After converting, verify three classes of value: version strings, identifiers ending in zero, and short strings such as no or on, since these are the ones implicit typing distorts most. Anything quoted in the original should remain a string; if it came out numeric, the source was missing quotes. Indentation errors are the most frequent parse failure, because YAML forbids tabs and requires identical indentation for siblings. The error message typically gives a line number without naming the real cause, so replace tabs with spaces in your editor before investigating further. Limits: YAML supports anchors and aliases (the & and * sigils) for reuse and permits multiple documents separated by three dashes. Converting to JSON expands anchors into duplicated content, which inflates the file, and multi-document files must be split or wrapped in an array or only one document is processed. Comments are necessarily lost in the conversion, a capability difference between the formats rather than a tool defect, so explanatory text belongs in a field value or a separate document. YAML also has 1.1 and 1.2 specifications that differ on yes/no and octal numbers, so confirm which version each side uses before exchanging files. Data and privacy: the configuration being converted usually contains database passwords, cloud provider keys and internal hostnames. This tool parses and converts in the browser, uploads nothing and needs no network access. Once converted, check the output for sensitive values that should have been replaced by anchors or environment variables. Sequencing matters when validation is involved: validate the converted JSON against a schema before handing it to business logic, which is steadier than validating YAML directly because JSON lacks implicit typing and anchors that mislead validators. Pipelines often use the converted form a second way, running a field-level diff on the JSON to avoid whole-block false positives caused by anchor expansion. Keeping one human read-through between conversion and commit remains the highest-value safeguard for the cost. One more point worth remembering: conversion changes form without validating meaning. A misspelled field, a missing required key, or an enum value out of range all pass silently, so a successful conversion is not proof of a correct configuration and deserves an independent validation step. Finally, keep converted output for common configurations under version control with a note explaining each change, so that who modified which field and when stays traceable afterwards, which matters more in team settings than any single tool feature.

How It Works Internally

Implicit typing is the crux of the reverse direction: an unquoted number becomes numeric, an identifier with leading zeros may lose them, and a date-like string may be promoted to a timestamp type. So a value that "looks like text but became a number" has to be fixed in the source with quotes rather than patched afterwards. Anchors and aliases expand into duplicated content.

Implicit typing at work
Inputid: 007 flag: no
Output{"id":7,"flag":false} (both values had their type rewritten by implicit rules)

Measured on This Page

Fixed: big integers lose precisionjs-yaml parses 9007199254740993 as an IEEE-754 double → 9007199254740992. Unquoted integers of 16+ digits at value positions are now quoted before parsing, so the output keeps the original as a string
Fixed: dates grow a timezoneAn unquoted date: 2026-01-01 is parsed as a Date, and after JSON.stringify it becomes "2026-01-01T00:00:00.000Z" — a time and UTC offset appear from nowhere. It now stays the string "2026-01-01"
yes/nojs-yaml 4 follows the YAML 1.2 core schema: yes/no are strings, not booleans — unlike 1.1, so note this when exchanging across systems
Nested listsitems converts to an array correctly

Implicit typing is the root of every trap on this page: the same characters mean different things with and without quotes. Two data-rewriting cases were measured and both are now guarded — big integers (snowflake/order IDs lose their last digit) and unquoted dates (parsed as Date, then JSON-stringified with a phantom 00:00:00.000Z). The fix quotes those values before parsing, so they come out as strings — honest, versus silently rewriting digits. A third case cannot be auto-fixed: version 1.10 becomes 1.1 as a number, so zero-suffixed codes must be quoted at the source. Also: only the first document of a multi-doc file is converted, anchors expand to duplicated content, and comments are always lost.

How this was measured: Values were pasted line by line and the JSON output inspected: an out-of-range integer, an unquoted calendar date, a two-item list and the shipped sample. The same inputs were also run through node-side js-yaml to attribute each behaviour to the library rather than the page, and re-run after the guards landed. · Measured 2026-10-31

How to Use

  1. Open "YAML to JSON"
  2. Paste the YAML document or config
  3. JSON refreshes as you type
  4. Check dates and big integers stay strings
  5. Click the copy icon to put the JSON on the clipboard

Use Cases

  • Store configs — Convert YAML to JSON before writing to a database or posting via API, avoiding an extra YAML parser on the backend.
  • Debug K8s manifests — Convert kubectl-exported YAML to JSON, then extract fields with jq or JSONPath.
  • Consume configs in frontend — Browsers natively support JSON.parse, so convert YAML to JSON for direct frontend use.
  • Expand anchors — Expand anchor-reused YAML into full JSON to see the actual effective values.
  • Validate format — A failed conversion means invalid YAML syntax — use it as a quick lint check.
  • Preprocess Ansible vars — Convert Ansible inventory YAML to JSON so external scripts can consume host variables without a YAML library.
  • Seed test fixtures — Write test data in concise YAML syntax, then convert to JSON for use in unit-test fixtures.

FAQ

Does it support multi-document YAML?

Yes. YAML documents separated by --- become a JSON array, with each document as one element.

What happens to YAML anchors and references?

They are fully expanded. &anchor definitions and *ref references are inlined into actual repeated content, since JSON has no reference mechanism.

Are dates and booleans auto-detected?

Yes. YAML true/false, null, numbers, and dates are typed accordingly; quote them in YAML to keep them as strings.

Why does it report an indentation error?

YAML is very indentation-sensitive: siblings must align and tabs are forbidden. The error gives a line number to check.

How are multi-line block scalars converted?

| and > blocks become a single string with real newlines; the folded (>) newlines are normalized to spaces in the JSON string.

Can I convert back to YAML?

Yes, use our JSON to YAML tool for the reverse direction.

It reports duplicate keys, but the YAML sections look different?

YAML tolerates duplicate keys (later wins in most implementations) while JSON requires uniqueness. The tool errors instead of silently overwriting so data is not lost — fix the duplicate in the source.

What happened to YAML anchors (*) and references (&)?

Anchors are resolved at parse time, so the JSON contains the expanded values with no & or * markers. That is correct — anchors are an authoring shortcut, not data.