YAML ↔ JSON Converter

Your data never leaves your browser

Convert YAML to JSON or JSON to YAML with a single toggle. Bidirectional, instant, and 100% in your browser.

Input - YAML
Output - JSON
Ctrl+Shift+CCopyCtrl+KClear

Share this tool

Found it useful? Help a fellow developer discover it.

https://developertoolkit.dev/tools/yaml-to-json

YAML vs JSON at a glance

YAML

  • ·Human-readable, indentation-based syntax
  • ·Supports comments with #
  • ·No quotes required for most strings
  • ·Multi-line strings with | or > block scalars
  • ·Anchors and aliases for reuse
  • ·Standard for Kubernetes, Docker Compose, GitHub Actions

JSON

  • ·Strict subset of JavaScript object literal syntax
  • ·No comments allowed
  • ·All strings must be double-quoted
  • ·More verbose for deeply nested structures
  • ·Universal REST API wire format
  • ·Natively parsed by every browser and runtime

When to convert between formats

YAML is the default format for many DevOps tools, Kubernetes manifests, Docker Compose files, GitHub Actions workflows, and Ansible playbooks are all YAML. JSON is the wire format for REST APIs, browser storage, and most configuration SDKs. You will often need to convert in both directions: copying a Kubernetes resource to pass to a JSON API, or taking a JSON API response and writing it into a YAML config file. This tool handles both directions on a single page so you don't need two separate converters.

How to convert YAML to JSON online

  1. Select the direction. Use the toggle at the top of the tool to choose YAML to JSON or JSON to YAML.
  2. Paste your YAML. Paste it into the input panel. The converter validates the syntax as you type and shows an error if the YAML is malformed.
  3. Copy the output. The JSON appears instantly in the right panel, formatted with 2-space indentation. Click Copy to copy it to your clipboard.
  4. Adjust indent size if needed. Use the indent selector to switch between 2 spaces, 4 spaces, or compact (minified) output.
  5. Download as a file. Click Download to save the output as a .json or .yaml file.

Frequently Asked Questions

How do I convert YAML to JSON online?

Select the YAML to JSON direction using the toggle, paste your YAML into the input panel, and the JSON output appears instantly. Click Copy to copy the result to your clipboard or Download to save it as a .json file. To go the other direction, toggle to JSON to YAML and paste your JSON instead.

What tools and platforms use YAML?

YAML is the configuration format for Kubernetes (manifests, Helm charts), Docker Compose, GitHub Actions, GitLab CI, CircleCI, Ansible playbooks, Azure DevOps pipelines, and many cloud infrastructure tools. When any of these tools produce output you need to pass to a JSON API, this converter bridges the gap.

Why is my YAML converting to an empty object or wrong output?

The most common causes are: inconsistent indentation (YAML uses spaces, never tabs), a missing colon after a key, a scalar value that YAML is interpreting as a different type (wrap it in quotes to force a string), or a YAML anchor that resolves unexpectedly. The error indicator in the input panel shows where the parser failed.

Can YAML comments be preserved when converting to JSON?

No. JSON has no comment syntax, so comments are lost during YAML to JSON conversion. This is a fundamental limitation of the JSON specification, not a bug in the converter.

Does YAML support everything JSON does?

Yes. YAML is a superset of JSON. Every valid JSON document is also valid YAML. However, YAML supports additional types and features such as anchors, tags, and multi-document streams that have no JSON equivalent and are dropped during conversion.

Why does my YAML timestamp become a Date string in JSON?

js-yaml parses unquoted timestamps (for example 2024-01-15) as JavaScript Date objects by default, which JSON serializes to ISO string format. Wrap the value in quotes in your YAML to keep it as a plain string.

Can I convert multi-document YAML (multiple --- blocks)?

The converter loads the first document in a multi-document YAML stream. Subsequent documents separated by --- are ignored. Split multi-document files manually before converting if you need all documents.

Is the conversion lossless?

YAML to JSON is lossless for the JSON data model (strings, numbers, booleans, null, arrays, objects). YAML-specific features like comments, anchors, and custom tags are dropped. JSON to YAML is fully lossless. All JSON types map cleanly to YAML equivalents.

Related Tools