YAML to JSON Converter

Convert YAML to JSON (or JSON back to YAML) in your browser, supports multi-document manifests, anchors, and clear line-numbered parse errors.

🌐 Español

🔒 Private by design: your text is processed locally in your browser and never uploaded to any server.

The conversion is really a question about YAML’s type rules

JSON is a subset of YAML, which makes one direction sound trivial and hides where the actual work is. Both formats describe the same six kinds of value, so nothing structural gets lost going from YAML to JSON. What differs is how each format decides what an unquoted scalar means, and YAML has far more opinions about that than JSON does.

null is the easy illustration. JSON spells it exactly one way. YAML accepts null, Null, NULL, ~, and an empty value after the colon, all five of which arrive in JSON as the same null. Numbers are looser too: YAML will read 0x1F as 31 and 1e3 as a float, while JSON has no hexadecimal literal at all. Timestamps are the one that surprises people, because a bare 2024-01-15 is a genuine YAML type, becomes a real date object during parsing, and then serialises into JSON as the full ISO string 2024-01-15T00:00:00.000Z, since JSON has nowhere to put a date.

That is why “convert my YAML” is not a text substitution. Seeing which of your values the parser considered a number, which a string, and which a boolean is often the entire reason to run a manifest through here in the first place.

The yes and no trap, and which side of it this tool sits on

There is a well-known bug pattern where a config file listing country codes turns NO into false, because YAML 1.1 treated yes, no, on and off as boolean spellings. It bit enough projects to earn a nickname, the Norway problem.

This converter runs js-yaml v4 on its default schema, which resolves booleans the YAML 1.2 way, so the only booleans are true and false. That default schema is the 1.2 core types plus a handful of extras js-yaml keeps, which is why the timestamps and merge keys further down this page work at all. Your no comes out as the string "no". We verified that against the library rather than trusting the reputation of YAML generally, because it changes the advice: if you are debugging a config that a Ruby, Perl or older Python toolchain misread, the result here will disagree with the tool that broke, and that disagreement is the finding.

Multi-document files and the loadAll decision

Kubernetes conventions push several resources into one file, separated by a --- line. Most naive converters read the first document and either stop or throw, because js-yaml’s plain load refuses a stream containing more than one document outright.

This tool calls loadAll instead, and then makes one judgement call about the shape of the output. A single-document file gives you the object or array itself, not a one-element array wrapping it, because that is what someone pasting an ordinary config expects. Two or more documents give you a JSON array with one element per document, in source order. So a file bundling a Deployment, a Service and a ConfigMap becomes an array of three objects you can index into. Genuinely empty input, including an empty document between two separators, converts to null, which is what the YAML specification says an empty document contains.

What cannot survive the trip

Comments are the big loss and no tool can prevent it. A # comment is not part of YAML’s data model, so the parser drops it while reading; there is no comment left by the time output is written, and JSON has no syntax to receive one anyway. Any config where the comments carry the institutional knowledge should be edited in place, not round-tripped.

Two smaller things also flatten out. Anchors and aliases resolve to their values, so a &defaults block referenced three times, or merged in with a merge key, appears three times in full in the JSON rather than staying a reference. And mapping keys that look like integers get reordered: JavaScript objects list integer-like keys in ascending numeric order regardless of the order they were written in, so a mapping with keys 10 and 2 will come out 2 first. Quote those keys in the source if their order matters.

Going the other way

Switch Direction to JSON → YAML and the same box takes JSON instead. The indent option (1 to 8 spaces, default 2) does useful work in both modes: it sets the JSON output’s indentation in one direction and js-yaml’s block indentation in the other. Values outside that range are clamped rather than rejected. Either way it is four steps:

  1. Paste your YAML (or JSON) into the text box above.
  2. Leave Direction on YAML → JSON, or switch it to JSON → YAML.
  3. Set Indent size (spaces) if the default of 2 is not your house style.
  4. Click the button, then press Copy to clipboard. A parse failure appears in the same output box, naming the line and column, rather than as a generic error banner.

This is the direction to use when a tool insists on YAML and what you have is an API response or an exported config. Do not expect the result to look hand-written, though. A serialiser makes consistent choices about quoting and flow style that a human author would not, so the YAML is correct but plain.

Reading a parse error

Both directions report failures as a single line naming the position and the parser’s own reason, rather than a generic “invalid input” banner. The YAML side converts js-yaml’s zero-based mark into the one-based line and column your editor displays; the JSON side reuses the error description already written and tested for the JSON Formatter rather than duplicating that logic.

One detail from building this is worth recording. The conversion function deliberately never throws. The shared text-tool shell catches any thrown error and replaces its message with a fixed “something went wrong” banner, which would have swallowed the one thing this tool exists to show you. So the error text is returned as the result instead, and lands in the output box where it is readable.

If your input turns out to be XML rather than YAML, XML to JSON covers that shape, and Diff Text is the usual next step once two configs are in the same format and you want to see what actually differs.

See it in action

Screenshot of the YAML to JSON Converter tool with the sample input “site: sysfenix uploads: 0 categories: - image - …”, Direction set to YAML → JSON, Indent size (spaces) set to 2
YAML to JSON Converter mid-process: the sample input “site: sysfenix uploads: 0 categories: - image - …”, Direction set to YAML → JSON, Indent size (spaces) set to 2.
Screenshot of the YAML to JSON Converter result screen showing the generated output “{ "site": "sysfenix", "uploads": 0, "categories"…”
The finished result: the generated output “{ "site": "sysfenix", "uploads": 0, "categories"…”. The download link is a local blob URL — the file never leaves your device.

Frequently asked questions

Why did my "no" value stay a string instead of becoming false?

Because js-yaml v4 resolves booleans the YAML 1.2 way, where the only spellings are true and false. YAML 1.1 also treated yes, no, on and off as booleans, which is the origin of the famous Norway bug: a country list containing NO turned into a false. Newer parsers dropped that rule, and this converter reports what js-yaml actually does rather than what older tooling used to do.

Does it handle a manifest with several documents in one file?

Yes, and that shaped the implementation: it calls loadAll rather than load, because load throws the moment it sees a second document separator. One document converts to a single JSON object, so an ordinary file behaves the way you expect. Two or more convert to a JSON array with one element per document, in source order, which is what a bundled Deployment plus Service plus ConfigMap gives you.

Where did my YAML comments go?

They are gone, and no converter can save them. Comments are not part of YAML's data model at all; the parser discards them while reading, so by the time there is a value to serialise there is nothing left to carry across. JSON has no comment syntax to receive them either, which is why round-tripping a heavily annotated config through JSON and back is a lossy operation.

What does the error message tell me when my YAML will not parse?

You get a single line naming the exact position and cause, such as an invalid YAML report at line 4, column 3 with js-yaml's own reason text attached. The numbers are converted from js-yaml's zero-based mark to the one-based line and column your editor shows, so you can jump straight to the character where the parser gave up.

Why did a date turn into a long timestamp string?

A bare date like 2024-01-15 is a real timestamp type in YAML, so js-yaml produces a JavaScript Date object for it. JSON has no date type, and serialising a Date yields its full ISO 8601 form, which is why you get 2024-01-15T00:00:00.000Z back. Quote the value in your YAML if you need the original spelling preserved as a plain string.

Can a malicious YAML file run code through this tool?

No. The dangerous behaviour belonged to js-yaml v3's unsafe loader, which could construct arbitrary objects and even functions from custom tags; v4 removed that schema entirely, and the loaders used here reject a tag such as a JavaScript function tag with an unknown-tag error instead of building anything. Parsing happens in your own tab with no evaluation step anywhere in the path.

Related tools