JSON ⇄ YAML Converter

Convert JSON to YAML or YAML to JSON in one step. Indentation is configurable, errors are reported in plain language, and everything runs locally.

Direction
YAML indentation
Input
Output

About this tool

JSON and YAML describe the same shapes — objects, arrays, strings, numbers, booleans and null — but they are built for different readers. JSON is strict and machine-oriented: braces, brackets, double quotes and no comments, which makes it the natural format for APIs. YAML is indentation-based, allows comments and is easier to edit by hand, which is why Kubernetes manifests, CI pipelines and application configuration files use it.

Converting between them is mostly mechanical, and the interesting parts are the differences. Comments exist only in YAML and disappear when you convert to JSON, because JSON has no syntax for them. A YAML document may contain several objects separated by ---, while JSON holds a single value. Anchors and aliases are expanded, so shared settings appear as repeated values in JSON.

Typing is the other trap. Unquoted true, false and null become real JSON values, but words such as on, off, yes and no stay strings here. Some YAML 1.1 parsers read them as booleans, so quote such values if the consumer is strict — this converter follows the YAML 1.2 core schema and does not guess.

YAML indentation is structural, so whitespace mistakes are syntax errors rather than cosmetic ones. Tabs are forbidden for indentation, and mixing spaces with a tab copied from a chat window is the single most common reason a working config stops parsing. Lists may sit at the same indent as their parent key or one level deeper, and both styles are valid, which is why files pasted from different projects look inconsistent. Multi-line text is the other place where meaning hides in punctuation: a block starting with | keeps line breaks, > folds them into spaces, and a trailing minus or plus controls whether the final newline is stripped or kept. A value that begins with *, &, !, %, @ or another reserved indicator must be quoted, and a plain string containing a colon followed by a space will be read as a mapping instead of text.

Typing differences cause silent data changes that look like converter bugs. YAML accepts numbers in octal, hexadecimal and even sexagesimal form, plus .inf and .nan, none of which JSON can represent, so a value such as 0123 or 1:30 may arrive as a decimal number or be rejected instead of staying a string. Version strings are the classic casualty: 1.10 becomes 1.1 as a number, and an unquoted 2026-01-01 may be turned into a timestamp by parsers that implement YAML 1.1. On the JSON side, numbers are IEEE 754 doubles, so integers above roughly 9 quadrillion lose precision before YAML ever sees them. Duplicate keys are another quiet failure: JSON leaves the behaviour undefined and most parsers keep the last value, while YAML forbids the duplicate outright, so a file that loads in one tool may be rejected in the next.

YAML features that have no JSON equivalent need a deliberate decision rather than a mechanical translation. Anchors and aliases are expanded, which is correct but can turn a ten-line file into a thousand-line JSON object, especially when an alias points at a structure that itself contains aliases; untrusted YAML can exploit this as a memory bomb, so never parse arbitrary YAML from the internet with anchors enabled. Merge keys written as << copy defaults into a mapping, and the result depends on key order. Multiple documents separated by --- must be split before converting to JSON, since JSON holds exactly one top-level value. On the way back, JSON has no comments, no anchors and no multi-document syntax, so anything you add in YAML for human readers has to live outside the JSON representation or in a companion file.

How to use

  1. Choose a direction: JSON → YAML for a config file, YAML → JSON for tooling that only accepts JSON.
  2. Paste the source, or load a .json, .yaml or .yml file from your computer.
  3. For JSON → YAML, choose the indentation your project uses — two spaces is the common convention.
  4. Press Convert. If the input is invalid, the status line names the line and the reason instead of failing silently.
  5. Copy the result or download it; the downloaded file uses .yaml or .json according to the direction.
  6. Round-trip the result before shipping it: convert JSON to YAML and back, then compare the two JSON trees, including key order and value types, because a value that changed from string to number will look identical in YAML.
  7. Quote anything that could be reinterpreted: identifiers with leading zeros, version numbers, dates, and the words true, false, null, yes, no, on and off. A single pair of quotes is cheaper than debugging a production config that silently changed type.

FAQ

Is every JSON document valid YAML?

Almost. YAML 1.2 was designed as a superset of JSON, so ordinary JSON — braces, brackets and double-quoted keys — parses as YAML. The exceptions are edge cases where characters such as tabs or certain control characters are allowed in JSON strings but not in YAML.

Why do my comments disappear?

Because comments are not data. YAML comments start with # and are discarded by any parser, and JSON has no comment syntax at all, so there is nowhere to keep them. If comments matter, keep the YAML source and convert a copy.

Why did "on" or "yes" become a string instead of a boolean?

YAML 1.1 treated on, off, yes and no as booleans, while later schemas do not, and implementations disagree. This converter follows the YAML 1.2 core schema, where only true and false are booleans, so other words stay strings. Quote or unquote accordingly if the target system expects the older behaviour.

What happens to anchors, aliases and multiple documents?

Anchors and aliases are resolved, so a value that was shared in YAML is written out in full in JSON. A YAML file containing several --- separated documents is rejected for JSON conversion, because JSON can only hold one value; split the documents first.

Why does my YAML fail with an indentation error?

YAML uses indentation to define structure, and tabs are not allowed for it, so a tab pasted from an editor or a chat message breaks the document even though it looks aligned. Replace tabs with spaces, keep siblings at exactly the same column, and remember that a list item may be indented at its parent key or one level below, but not inconsistently within one list.

Why did a version number or a date change after conversion?

Unquoted scalars are typed by the parser. A value such as 1.10 is a number and loses the trailing zero, and a date-like string may become a timestamp under YAML 1.1 rules. JSON has no date type, so the value may come back as an ISO string with a time or not at all. Quote version numbers and dates in the YAML source to keep them as strings.

Can comments survive a JSON conversion?

No. Comments are not data, YAML parsers discard them before the document tree exists, and JSON has no comment syntax. Keep the commented YAML as the source of truth and convert a copy for tools that demand JSON; a JSON file with comments is not valid JSON even though some editors tolerate it.