Convert YAML to JSON

Converting YAML to JSON is the fastest way to find out what a YAML file actually means, because JSON has no shorthand to hide behind: anchors are expanded, quoted and unquoted values become visibly different types, and anything the parser resolved differently from your intention is right there in the output. It runs in your browser.

  • Where it runs In your browser. The file is never uploaded.
  • Lossless Nothing is discarded. The JSON holds exactly what the YAML held.
  • File size limit Up to 100 MB per file, free, without an account.

Up to 100 files at once. Mixed formats are fine.

Reading a YAML file as data rather than as text

YAML 1.2 is deliberately a superset of JSON, which means every JSON document is already valid YAML and this conversion is a matter of writing the same data with none of the shorthand. That is exactly why it is useful for debugging: the JSON shows you the values the parser produced, not the characters you typed.

Most of the surprises in a YAML file are resolution surprises — a version that became a number, a word that became a boolean, an alias that pulled in more than you expected. None of them are visible in the YAML and all of them are visible in the JSON. The rest of this page is the list of those resolutions, in the order they tend to cost people time.

A multi-document YAML stream stops the conversion dead

YAML files can hold several documents in one stream, separated by --- lines. Kubernetes manifests use that constantly: a Deployment, a Service and a ConfigMap in one file is the normal shape. JSON has no equivalent — a JSON file is one value — so the parser refuses rather than silently picking a document, and the conversion fails with a message naming the line where the second document begins.

The workaround is mechanical. Split the file at the --- markers and convert each document separately, or wrap the parts in a single top-level list yourself before converting. A leading --- on its own at the top of a file is fine and so is a closing ... marker; it is only a second document that stops it.

Anchors expand, and the merge key does not merge

An anchor and its aliases collapse into copies. A .gitlab-ci.yml that defines &defaults once and aliases it from six jobs produces JSON with six full copies of that block, because JSON has no way to refer to a value defined elsewhere. The output is larger than the input and says the same thing.

The merge key is the part that catches people. A line written << followed by an alias is a YAML 1.1 convention for merging a map into the current one, and it is not part of the YAML 1.2 core schema, so it comes through as an ordinary key named "<<" whose value is the referenced map. The keys you expected to be merged into the job are one level down under that key instead. Whatever consumes the JSON has to flatten it, and you should assume any tool downstream will not.

Custom tags like !Ref vanish without an error

CloudFormation short forms, Home Assistant includes and a dozen other dialects hang meaning off custom tags: !Ref myBucket, !GetAtt [resource, attribute], !include other.yaml. The parser does not know those tags, so it resolves each one to its bare value and moves on — !Ref myBucket becomes the plain string "myBucket", and !GetAtt with a list after it becomes just the list.

This is the most dangerous conversion on the page, because the JSON is valid, plausible and wrong. There is no marker left to say a tag was there. If your YAML belongs to a dialect with custom tags, this converter will produce a document that no longer describes what you meant, and the only defence is knowing in advance that your file uses them.

Which words in a YAML file are booleans

YAML 1.1 treated yes, no, on, off, y and n as booleans, which is the origin of the well-known problem where a country code written as no becomes false. The parser here implements YAML 1.2, whose core schema recognises only true and false, so those words survive as strings and the country code is safe.

That is a default, not a guarantee. A file whose first line is a %YAML 1.1 directive is read as 1.1, and then on genuinely does become true in the JSON. It is also only true of this converter — the tool that reads your YAML in production may well be PyYAML, which is a 1.1 implementation. The JSON here tells you what a 1.2 parser sees, which is useful precisely because it may differ from what your runtime sees.

Numbers a YAML parser resolves before JSON is involved

A value written 1.0 resolves to the number 1, so a pinned version becomes an integer and prints without its decimal. A value written 0755 resolves to 755. Quoting either one in the source keeps it a string, and the JSON output will show quotes around it, which makes this conversion a quick way to audit a file for values that need quoting.

Large integers lose precision silently. YAML has no size limit on an integer, JSON numbers are IEEE doubles, and a 64-bit identifier written 9223372036854775807 comes out as 9223372036854776000. Nothing reports it. Any YAML holding IDs of that magnitude wants them quoted as strings before conversion, not after.

Timestamps, binary data and other YAML types JSON cannot hold

JSON has six types and YAML has a tag system. Where the two disagree, something is flattened. A value carrying the explicit !!timestamp tag becomes a date and then an ISO 8601 string in the JSON, normalised to UTC — so a timestamp written with a minus five hour offset comes out shifted and marked with a Z, and the original offset is gone.

A !!binary value is decoded to bytes and then serialised as an object keyed by position — the two bytes of "hi" arrive as {"0":104,"1":105}. The data is all there and no consumer will recognise it; re-encoding the field to base64 text in the YAML before converting is the shorter road. Unquoted dates without a tag are simpler: under the 1.2 core schema they are ordinary strings, so a date written 2024-01-02 stays the string 2024-01-02, which is usually what you want.

The YAML that fails to parse before it can become JSON

Two errors stop the conversion outright and both are worth recognising. Duplicate keys in the same mapping are rejected — the message is that map keys must be unique, with the line number — which is stricter than some YAML tools and generally the correct behaviour, since a duplicate key means one of the two settings has been ignored ever since it was added.

The second is a tab used for indentation. YAML forbids tabs there, and the parser says so with a line and column. Both errors are the converter doing you a favour: a file with either problem is a file whose behaviour already depends on which parser reads it.

What the JSON is good for once you have it

The output is indented two spaces and ends with a newline, so jq, a JSON Schema validator and any HTTP client read it directly. Validation is the strongest reason to make this trip: JSON Schema is mature and widely implemented, and running a generated JSON copy of a config through a schema catches misspelled keys that a YAML linter, which only checks syntax, will pass.

It is not a replacement for the YAML. Comments are gone, anchors are expanded into duplication, and any custom tags have quietly evaporated, so converting back would give you a file that works and no longer reads like something a person wrote. Keep the YAML as the source and treat the JSON as the view.

How to convert YAML to JSON

  1. Drop your YAML file onto this page, or click to choose one.
  2. It is parsed and written as JSON in your browser.
  3. Download the JSON, or read it to find the value that resolved wrongly.

YAML against JSON: a superset written out as its subset

YAML compared with JSON
YAMLJSON
Full nameYAML Ain't Markup LanguageJavaScript Object Notation
File extension.yaml, .yml.json
Media typeapplication/yamlapplication/json
First published20012001
SpecificationYAML 1.2RFC 8259
LicensingOpen standardOpen standard
Standing todayCurrentCurrent
Opens in a browserNo browserEvery browser
Considered insteadTOMLXML, NDJSON

What is lost

Comments do not survive. YAML lets you annotate a file and JSON has no syntax for it, so every explanatory line is dropped — which matters most on exactly the files people comment: configuration somebody else has to maintain.

What survives

Nothing is discarded. YAML and JSON both store their content losslessly, so the conversion is a change of packaging rather than a change of quality, and it can be repeated without accumulating damage.

Opening the result

JSON opens in every current browser. YAML has narrower browser support than that. If the file is going onto a web page or into a form, that is usually the whole reason for the conversion.

Visual Studio Code reads both YAML and JSON, so there is a way to check the result against the original without a second tool.

What each format is for

YAML was published in 2001. The specification is YAML 1.2, and it is worth reading if the file has to outlive the tool that wrote it.

JSON dates from 2001, specified as RFC 8259. Visual Studio Code, jq and Postman all read it.

YAML to JSON: questions from people debugging a config

Are my YAML files uploaded anywhere?

No. This conversion runs entirely inside your browser, so the file never leaves your device. You can confirm it yourself: open the network tab of your browser's developer tools and convert something. You will see the page load, plus the analytics and advertising the site is paid for with — and nothing carrying your file.

Why does my Kubernetes manifest fail to convert?

Almost certainly because it contains more than one document separated by a --- line. A YAML stream can hold several documents and a JSON file holds one value, so the parser stops rather than guessing which document you meant. Split the file at the markers and convert each part.

What happens to anchors and aliases?

They are expanded. Every alias is replaced by a full copy of what the anchor pointed at, so the JSON repeats content the YAML stated once. That is the only faithful representation, since JSON has no references.

Is the merge key applied?

No. A line reading << with an alias after it comes out as a key literally named "<<" holding the referenced map, rather than being merged into the surrounding object. Anything reading the JSON has to flatten it, or you edit it by hand.

Are yes and on converted to booleans?

Not by default. This parser implements YAML 1.2, whose core schema treats only true and false as booleans, so yes, on, y and off stay strings. A file that opens with a %YAML 1.1 directive is read as 1.1 instead, and then those words do become booleans.

What happens to comments?

They are dropped. JSON has no comment syntax under RFC 8259, so there is nowhere to put them. Treat the JSON as a view of the YAML rather than a replacement for it.

Is the file uploaded?

No. Parsing and serialising both happen in this page in JavaScript, so a manifest holding cluster names, image registries or secrets stays on your machine.

More about these formats