LocalDevTools

YAML to JSON / JSON to YAML Converter

Paste a Kubernetes manifest, a GitHub Actions workflow, a Docker Compose file or any other YAML and get clean JSON, or turn JSON into readable YAML. Errors point to the exact line.

Runs entirely in your browser. Your input is never uploaded or stored on a server.

How to convert YAML to JSON

  1. Choose the direction: YAML → JSON or JSON → YAML.
  2. Paste your input on the left, or click Load sample to try it. The output updates as you type.
  3. If the input is invalid, the message below the tool shows what is wrong and the line and column where the parser stopped.
  4. Click Copy or Download. Swap moves the output back into the input so you can round-trip a file.

Examples

name: web            →  {"name": "web", "replicas": 3, "ports": [80, 443]}
replicas: 3
ports: [80, 443]

{"debug": false}     →  debug: false

YAML features that are handled

  • Anchors and aliases (&defaults and *defaults) are expanded, so the JSON contains the full values. Merge keys (<<: *defaults) are supported too.
  • Block scalars: | keeps line breaks and > folds lines into one, the same way Kubernetes and GitHub Actions read them.
  • Multiple documents separated by ---. By default the first document is converted; tick All documents to get a JSON array with one item per document.
  • Comments are allowed in YAML but JSON has no comments, so they are dropped in the JSON output.

Common YAML gotchas

YAML guesses types from how a value looks. port: 8080 becomes a number, enabled: true becomes a boolean and version: 1.10 becomes the number 1.1. If you need a string, quote it: version: "1.10". This converter follows the YAML 1.2 core schema, so yes, no, on and off stay as strings (YAML 1.1 parsers, including some older tools, treat them as booleans, which is the famous "Norway problem" where the country code NO turns into false).

Indentation must use spaces, never tabs. A tab at the start of a line is the most common reason a file that looks fine fails to parse.

Frequently asked questions

Is JSON valid YAML?

Almost always, yes. YAML 1.2 was designed as a superset of JSON, so most JSON documents can be read by a YAML parser without changes. That is why the JSON → YAML direction is mainly about making the file easier for people to read.

Why did my comments disappear?

JSON has no comment syntax, so comments cannot be carried over from YAML to JSON. Keep the YAML file as your source of truth if the comments matter.

Why did "1.10" turn into 1.1?

Unquoted values that look like numbers are parsed as numbers, and 1.10 and 1.1 are the same number. Put quotes around values such as version strings, ZIP codes with leading zeros or IDs to keep them as text.

How are multiple documents separated by --- converted?

By default only the first document is converted. Turn on "All documents (as array)" to get every document as an item in a JSON array, which is handy for multi-resource Kubernetes files.

Is my file uploaded anywhere?

No. Parsing and conversion run in your browser with the open-source js-yaml library. Config files often contain secrets, so nothing is sent to a server.

Related tools

Last updated: