YAML to JSON converter

Convert YAML into JSON instantly

Paste YAML on the left and get formatted JSON on the right — all in your browser

Last updated: January 26, 2026
Frank Zhao - Creator
CreatorFrank Zhao
The converted JSON will appear here

Introduction / overview

This YAML to JSON converter parses your YAML input locally in the browser and produces formatted JSON you can copy. It supports YAML merge keys (often used with anchors) and outputs readable JSON with consistent indentation.

Use it when you need to paste a YAML config into tools that only accept JSON (APIs, validators, SDK examples, or deployment dashboards).

Why it’s safe and reliable

  • Runs locally in your browser — your input is not sent to a server.
  • Validates YAML and shows an error when the syntax is invalid.
  • Outputs formatted JSON, so diffs are easier to review.

If you’re working with encodings or formats, you may also like our Base64 String Encoder/Decoder or Case Converter.

How to use / quick start

1

Paste your YAML on the left

Include mappings, lists, anchors, and merge keys if you need them.

2

Check for validation errors

If the YAML is invalid, fix indentation, missing colons, or quote issues.

3

Copy the JSON output

Use the copy button in the top-right corner of the output box.

4

Share or reset when needed

Share a link (optionally including input) or reset the tool to start fresh.

How to read the output

JSON has only a few building blocks: objects { }\{\ \}, arrays [ ][\ ], strings, numbers, booleans, and null\text{null}. After converting, scan the output for the keys you care about and confirm the structure matches what your target tool expects.

Step-by-step examples

Example 1: Converting a list (and sanity-checking the size)

Suppose your YAML describes three environments. After converting, you should see an array with three objects.

n=3n = 3\Rightarrowenvironments=3|\text{environments}| = 3

If the output shows fewer items than expected, check for YAML indentation mistakes or overwritten keys.

Example 2: Understanding indentation in the formatted JSON

The output uses a 3-space indentation style. At nesting level kk, the left padding is approximately 3k3k spaces.

k=4k = 4\Rightarrow3k=123k = 12 spaces\text{ spaces}

This formatting doesn’t change meaning — it’s purely to make the JSON easier to read and copy.

Real-world examples / use cases

Turning a CI config into API JSON

Background: You have a YAML snippet from a CI/CD template, but a platform API expects JSON.

Input: YAML with a list of steps and environment variables.

Result: A JSON object you can paste into an API request body.

How to use it: Use the JSON output as the payload for your tooling or automation.

Converting Kubernetes-style YAML for debugging

Background: You want to quickly inspect nested fields without YAML anchors/aliases getting in the way.

Input: YAML with nested metadata/spec sections.

Result: A JSON structure that is easier to search in editors.

How to use it: Search for keys and compare against expected schema.

Normalizing config for JSON-only linters

Background: Your linter/validator accepts JSON, but the original config is in YAML.

Input: YAML settings with booleans and numbers.

Result: A JSON file you can validate and commit.

How to use it: Validate the JSON, then decide whether to keep YAML or switch formats.

After you get clean JSON, it’s common to re-encode it for transport. For that workflow, try our Base64 String Encoder/Decoder.

Common scenarios / when to use

API payload preparation

Convert YAML examples into JSON bodies for REST/GraphQL calls.

Schema debugging

Flatten the mental model: inspect nested objects and arrays in JSON.

Anchor/merge expansion

YAML merge keys can be hard to “see” — JSON makes the final structure explicit.

Copy-paste to dashboards

Many UIs accept JSON but not YAML. Convert and paste in one step.

Documentation cleanup

Produce consistent JSON samples for docs, README files, or guides.

Quick sanity checks

Make sure booleans, nulls, and numbers are interpreted as expected.

Not a great fit: If you need to preserve comments or exact formatting, JSON can’t represent those. Also, different YAML parsers can interpret edge cases slightly differently.

Tips & best practices

Practical tips

  • Prefer spaces over tabs in YAML indentation.
  • Quote values that look like dates or special tokens when you want them treated as strings.
  • After converting, search the JSON for a key you expect — it’s a quick correctness check.
  • If your YAML contains secrets, still treat the output carefully — copying puts it in your clipboard history.

When sharing links

If you enable “share with results”, the YAML input is included in the URL. For privacy, avoid sharing sensitive configs. For long configs, you may hit URL length limits.

Calculation method / mapping

This tool emphasizes correctness and readability. Conceptually, it does two steps: parse YAML into a JavaScript object, then stringify that object to JSON with a 3-space indentation.

JSON\text{JSON}==stringify(parseYAML(YAML), 3)\mathrm{stringify}(\mathrm{parseYAML}(\text{YAML}),\ 3)

Variables & terms

  • YAML\text{YAML}: your original input text.
  • parseYAML()\mathrm{parseYAML}(\cdot): converts YAML syntax into a structured object.
  • stringify(, 3)\mathrm{stringify}(\cdot,\ 3): outputs formatted JSON with 3 spaces per level.
indent(k)=3k\mathrm{indent}(k) = 3k

(indentation spaces at nesting level k)

Related concepts / background info

Anchors, aliases, and merge keys

YAML allows you to reuse blocks with anchors and aliases. Merge keys combine mappings. After conversion, the JSON shows the “final” merged result, which is often easier to reason about.

What JSON cannot represent

JSON doesn’t preserve YAML comments, custom tags, or formatting choices. It represents data, not the authoring style.

Frequently asked questions (FAQs)

Why does the converter say “Provided YAML is not valid”?

Most often it’s indentation (spaces), a missing colon after a key, or an unquoted value containing special characters. Try re-indenting with spaces and validating one block at a time.

Will anchors and merge keys be preserved?

JSON doesn’t support anchors/aliases. The output reflects the merged result (expanded data), which is usually what downstream tools need.

Are numbers and booleans converted correctly?

In general yes — YAML scalars are parsed into numbers, booleans, strings, or null\text{null}. If a value looks ambiguous (like a date), quoting it in YAML forces it to be a string.

Why is the output formatted (pretty-printed)?

Formatting makes it readable and reviewable. It doesn’t change meaning. If you need minified JSON, you can paste the output into a JSON minifier.

Can I share a link with my YAML included?

Yes. Use the Share button and enable “share with results”. Keep in mind URLs have length limits and can expose sensitive data.

Limitations / disclaimers

  • Comments and formatting from YAML are not preserved in JSON.
  • Duplicate keys may be overwritten during parsing depending on the YAML structure.
  • Very large inputs may be slow to parse and may exceed share-link URL limits.

External references / sources

YAML to JSON converter | CalculatorVast