Skip to content

Paste YAML, get JSON. Handles anchors, block scalars, and multi-line strings. 100% in your browser.

Input - YAML
Output - JSON
Ctrl+Shift+CCopy

Share this tool

Found it useful? Help a fellow developer discover it.

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

Convert in the other direction

Going the other way, turning a JSON payload into a Kubernetes manifest or Compose file?

Convert JSON to YAML

Open JSON to YAML Converter

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 you need YAML as JSON

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. That gap shows up constantly: posting a Kubernetes resource to the API server as a JSON body, feeding a Compose file into a script that only reads JSON, piping a CI workflow through jq, or checking what an anchor or block scalar actually resolves to. Converting the YAML to JSON shows you exactly what a parser sees, with every implicit type and merged anchor spelled out.

How to convert YAML to JSON online

  1. 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.
  2. Copy the output. The JSON appears instantly in the right panel, formatted with 2-space indentation. Click Copy to copy it to your clipboard.
  3. Adjust indent size if needed. Use the indent selector to switch between 2 spaces, 4 spaces, or compact (minified) output.
  4. Download as a file. Click Download to save the output as a .json file.

Frequently Asked Questions

How do I convert YAML to JSON online?

Paste your YAML into the input panel and the JSON output appears instantly, formatted with 2-space indentation. Click Copy to copy the result to your clipboard or Download to save it as a .json file.

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 2026-03-16) 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 have no JSON equivalent: comments are dropped, anchors and aliases are expanded into full copies of the data they reference, and custom tags are discarded.

Related Tools