Skip to content
cliplimeClipLime

Convert YAML to JSON

Paste YAML or drop a file and get JSON, with anchors resolved and types read the YAML 1.2 way.

Runs on your device, nothing is uploaded

Convert from

to

Paste, type, drop a file here or load one.

0 characters, 0 lines

Options

Indentation

At a glance

Input
YAML text or a .yaml or .yml file, such as a Kubernetes manifest, a Docker Compose or GitHub Actions file, or an OpenAPI description.
Types
Reads YAML 1.2: true and false are booleans, but yes, no, on and off stay text, and a date such as 2001-12-14 stays a text value.
References
Anchors (&name), aliases (*name) and merge keys (<<) are resolved, so the JSON has plain copies and no references.
Several documents
A file with several documents separated by --- becomes a JSON list with one item per document.
Dropped
Comments are dropped, because JSON has nowhere to keep them. The order of the keys is kept.
Errors
Tabs, bad indentation, duplicate keys and unclosed brackets are shown with line and column and a plain explanation.
Privacy
Config files often hold passwords and tokens. This one is converted in your browser tab and is never uploaded.

How to do it

  1. 1

    Add your YAML

    Paste it, drop a .yaml or .yml file on the input box, or press Load a file. Example fills in a small file with an anchor and a merge key.

  2. 2

    Choose the indentation

    Under Options, pick 2 or 4 spaces, a tab, or Minified for JSON on a single line.

  3. 3

    Check the result

    The JSON appears as you type. A problem in the YAML is shown with its line and column. The notes under the result mention extra documents and values that had to change.

  4. 4

    Copy or download

    Press Copy, or Download to save a .json file.

How YAML values are typed

YAML writes everything as plain text and decides the type from how the text looks. This converter follows the YAML 1.2 core rules:

  • true, True and TRUE are booleans. yes, no, on and off are ordinary text, so country: no gives "country": "no".
  • null, ~ and an empty value are null.
  • 42, -3.5, 1e3 and 0x1F are numbers (42, -3.5, 1000 and 31), and 0o14 is the octal number 12.
  • 1.10 is the number 1.1, not the text 1.10. If it is a version, write "1.10" in quotes in the YAML.
  • 2001-12-14 and 12:30:45 stay text, and so does anything in quotes.
  • .inf and .nan become the text Infinity and NaN, with a warning, because JSON has no such numbers.

Whole numbers with more than 15 digits can lose their last digits when read, and a warning appears when the file has some. Put such IDs in quotes.

YAML 1.1 and 1.2: when the same file reads differently

YAML 1.2, published in 2009, removed several guesses that YAML 1.1 made. Many tools, including PyYAML and Ruby's YAML library, still follow the 1.1 rules, where no is false, on is true, 014 is an octal number and 12:30:45 is a base 60 number. The same file can give different data depending on the reader.

This page shows what a 1.2 reader sees. If your tool is a 1.1 reader, check every value that is yes, no, on, off, a time or has a leading zero, and put it in quotes in the YAML. A quoted value is text in every version of YAML.

Anchors, merge keys and several documents

Anchors let YAML define a block once and reuse it. defaults: &defaults marks a block, *defaults repeats it, and <<: *defaults merges it into another mapping, where keys written next to it win. JSON has no references, so each use becomes a full copy. In the example on this page both people get team and active from the defaults, and Ben's own team: Engineering replaces the default.

Copies can make the JSON much larger than the YAML. An anchor can be reused as often as you like, so a Docker Compose file that merges the same block into thousands of services converts. A file whose aliases would add more than about two million items (keys, values and lists) to what the file shows is refused with a message. Nested aliases can do that from a few lines, and the refusal protects your browser tab. An anchor that contains its own alias cannot be converted, and a merge key has to point to a mapping or a list of mappings.

A YAML file can hold several documents separated by ---, as Kubernetes files often do. They become a JSON list with one item per document, and a note says how many.

What does not carry over to JSON

  • Comments are dropped.
  • Keys that are not text, such as 1: one or true: yes, become text keys: "1" and "true".
  • Tags are not kept. A !!set becomes a list, a custom tag such as !custom value leaves just its value, and binary data written with !!binary becomes a list of byte numbers.
  • Multi line text written with | or > becomes one string with line breaks, as YAML defines them. The final line break is kept unless you write |- or >-.

Questions people ask

Why did no (or yes, on, off) stay a string?

YAML 1.2, which this converter follows, reads only true and false as booleans. In YAML 1.1, still used by many tools, no is false and yes is true. If your tool is one of them, quote the value in the YAML, or expect false.

Why did version 1.10 become 1.1?

In YAML an unquoted 1.10 is a number, and the number is written in its shortest form, 1.1. Write the value in quotes in the YAML, "1.10", and it stays text in both YAML and JSON.

What happens to comments?

They are dropped. JSON has no comments, so there is nowhere to put them. If you need them, keep the YAML file as the source and convert from it when you need JSON.

Can I convert a file with several documents?

Yes. Documents separated by --- become a JSON list with one item per document, and a note under the result says how many there were. Kubernetes manifests with several objects are an example.

Why do I get an error about tabs or indentation?

YAML only allows spaces for indentation, never tabs, and all lines at one level must start in the same column. The error shows the line and column, and a plain explanation of what does not fit.

Is my YAML uploaded?

No. The text or file is read and converted in your browser tab. That matters for config files, which often hold passwords, tokens and internal addresses.