How to Convert YAML to JSON (and Back) Without Installing Anything

Need to switch between YAML and JSON? Learn the key differences between the two formats and how to convert them instantly in your browser.

YAML and JSON: Two Faces of the Same Coin

YAML and JSON are both data serialization formats widely used in software development. If you have worked with Docker Compose, Kubernetes, GitHub Actions, or Ansible, you have written YAML. If you have built any web API or worked with JavaScript, you have written JSON. They overlap considerably – in fact, every valid JSON file is also valid YAML.

Yet they have distinct strengths, and projects regularly need to move data between the two.

Key Differences

YAML is optimized for humans. It uses indentation instead of brackets, supports comments, allows multiline strings naturally, and reads more like a config file than code. This makes it popular for configuration: Docker Compose files, CI pipelines, Ansible playbooks, Helm charts.

JSON is optimized for machines. It is strict, has no ambiguity, and every major programming language has a built-in or standard-library JSON parser. It is the lingua franca of web APIs and data interchange.

YAMLJSON
CommentsYes (`#`)No
Quoting stringsOptionalRequired
Multiline stringsNativeRequires `\n`
Trailing commasAllowedNot allowed
Syntax strictnessRelaxedStrict
Tooling supportGoodUniversal

Common Conversion Scenarios

YAML → JSON: You have a YAML config file and need to pass its values to a JSON API, validate the structure, or import it into a tool that only accepts JSON.

JSON → YAML: You received a JSON payload and want to store it as a more readable config file, or you are migrating from a JSON-based tool to a YAML-based one (for example, moving from a package.json configuration block to a standalone YAML config).

Gotchas to Watch For

Special YAML types

YAML has implicit type coercion. The string yes in YAML becomes the boolean true in JSON. The string 1.0 becomes a float. null, ~, and empty values all map to JSON null. Always check that your string values that look like booleans or numbers are quoted in YAML if you need them to remain strings after conversion.

Indentation errors

YAML is indentation-sensitive. A single extra space can change the structure of your document. If your conversion tool throws an error, the most likely culprit is inconsistent indentation (mixing tabs and spaces is not allowed).

Multiple documents

YAML supports multiple documents in one file separated by ---. Most JSON tools only handle one document at a time; check whether your converter handles this case.

How to Convert in Your Browser

You do not need to install a command-line tool or write a script to convert between these formats. The YAML to JSON Converter on this site handles the conversion entirely client-side – paste your YAML, get JSON back instantly (or vice versa). Your data never leaves your browser.

For command-line users: yq (a YAML processor) and jq (a JSON processor) are the standard tools. The command yq -o=json your-file.yaml converts YAML to JSON in one step.

Summary

Both formats have their place. YAML excels at human-written configuration; JSON excels at machine-to-machine data exchange. Converting between them is trivial once you understand the structural equivalence – and knowing the gotchas (implicit types, indentation, multiple documents) saves you from hard-to-debug surprises.