Skip to content

YAML to JSON

Convert YAML to JSON and back.

Runs in your browser · free · no sign-up

YAML
JSON

About the YAML to JSON

Switch config files between YAML (used by Docker, Kubernetes and GitHub Actions) and JSON. Errors show the line and column so you can find indentation mistakes quickly.

YAML is the configuration language of Docker Compose, Kubernetes, GitHub Actions, Ansible and many frameworks, valued because it is easy for people to read. JSON is stricter and is what most code and APIs consume. Developers frequently convert between them, and doing so reveals indentation mistakes that are otherwise hard to spot.

This tool converts YAML to JSON and JSON to YAML using js-yaml, the standard YAML library for JavaScript. Errors show the line and column so you can find a misaligned item quickly. Choose 2- or 4-space indentation for the output, and if a YAML file holds several documents separated by ---, they become one JSON array.

How to use the YAML to JSON

  1. 1Choose YAML → JSON or JSON → YAML.
  2. 2Paste your data.
  3. 3Copy the converted result.

Key features

  • YAML to JSON and back.
  • Line and column error messages.
  • 2 or 4 space indentation for the output.
  • Powered by js-yaml.
  • Copy the result.

Practical uses

  • Checking a Kubernetes manifest.
  • Converting a JSON config to a readable YAML file.
  • Debugging GitHub Actions workflows.
  • Feeding YAML config into a JSON-only tool.
  • Converting an OpenAPI specification between YAML and JSON.

Example

The YAML lines “name: web” and “ports:” with an item “- 80” convert to {"name":"web","ports":[80]}.

Tips and common mistakes

  • Use spaces, never tabs, for YAML indentation.
  • Quote values such as yes, no and on if you mean text; older YAML tools treat them as booleans.
  • Validate converted YAML in the target tool.
  • When converting JSON to YAML, check long strings, which may be written as folded or quoted text.

Limitations

  • Comments are lost when converting to JSON.
  • Custom YAML tags are not supported.

Privacy

Your configuration stays in your browser.

Frequently asked questions

Why do I get an indentation error?

YAML uses spaces (not tabs) for structure. Make sure items at the same level line up exactly.

Are comments kept?

JSON has no comments, so YAML comments are lost when converting to JSON.

Which library is used?

js-yaml, the standard YAML parser for JavaScript.

Can it handle multiple YAML documents separated by ---?

Yes. When the YAML contains several documents, the JSON output is an array with one item per document.

Why did true or 42 lose their quotes?

Unquoted true, false, null and numbers are typed values in YAML, so they become JSON booleans, null and numbers. Quote them in YAML if they must stay text.

Are anchors and aliases supported?

Yes. YAML anchors (&) and aliases (*) are expanded into full values in the JSON output.

Related tools

CSV to JSONConvert CSV rows to a JSON array.
JSON to CSVTurn a JSON array into a CSV file for Excel.
JSON MinifierCompress JSON to a single line.
XML to JSON ConverterNewConvert XML to JSON and JSON to XML.