YAML JSON Converter - Free Online Tool

YAML / JSON Converter

Convert YAML to JSON or JSON back to YAML, useful for editing CI configs, Docker Compose, and Kubernetes manifests.

Uses YAML 1.2. Input stays in your browser. Non-finite numbers, unsafe integers, non-string map keys and cyclic aliases cannot be represented safely in JSON and are rejected.

This YAML JSON converter turns YAML into JSON, or JSON back into YAML, with one click. Paste your text, pick a direction, and copy the result. It is built for developers who edit Kubernetes manifests, Docker Compose files, CI pipelines and OpenAPI specs and need a fast, readable conversion.

What Are YAML and JSON, and How Do They Relate?

YAML and JSON are two text formats for storing structured data such as objects, lists, strings, numbers, booleans and null. JSON uses braces, brackets and quotes. YAML uses indentation and dashes, which makes it easier to read and to comment by hand.

The two formats are closely related. YAML 1.2, the version this tool uses, was designed so that almost any valid JSON document is also valid YAML. The reverse is not true: YAML has features JSON lacks, such as comments, anchors and aliases, and keys that are not strings.

That gap matters when you convert. Anything JSON cannot hold has to be dropped, expanded or rejected, and knowing which of the three happens saves you debugging time.

What the converter keeps and what it changes

  • Comments disappear, because JSON has no comment syntax.
  • Anchors and aliases are expanded, so a reused block appears in full wherever it was referenced.
  • Quoted values stay strings. Unquoted true, null and numbers like 42 become real booleans, nulls and numbers.
  • JSON output is indented with 2 spaces. YAML output uses 2-space block style.

How to Use the YAML JSON Converter

You convert by pasting text into the Input box and clicking the button for the direction you want. The steps below match the controls on this page.

  1. Paste your YAML or JSON into the Input box. The placeholder shows a small example with a name, a version and a list of ports.
  2. Click YAML → JSON to produce JSON, or JSON → YAML to produce YAML.
  3. Check the status line under the buttons. It says "Converted successfully." or "Conversion failed:" followed by the reason.
  4. Read the result in the output panel, which is labeled "JSON Output" or "YAML Output" depending on the direction.
  5. Click Copy to copy the result. If copying fails, select the output and copy it manually.
  6. Click Swap to move the output into the Input box so you can convert it back, or Clear to start over.

The tool needs something in the Input box. If it is empty, you see "Paste input first." Input must also be 1 MB or smaller.

Worked Example: Converting a Config With Reused Settings

A realistic test is a short service config with a shared defaults block. Paste this YAML into the Input box:

name: my-app
version: 1.0.0
ports:
- 80
- 443
defaults: &defaults
retries: 3
timeout: 30
service:
<<: *defaults
timeout: 60

Click YAML → JSON. The JSON Output contains "name": "my-app", a "version" of "1.0.0" and "ports": [80, 443]. The service object comes out with "retries": 3 and "timeout": 60.

Three things are worth noticing. Version 1.0.0 is a string because it is not a valid number. The ports are real numbers, so they have no quotes. The alias was expanded, and the local timeout: 60 overrode the default of 30, so the JSON carries no trace of the anchor.

Now click Swap and then JSON → YAML. You get clean block-style YAML again, without the anchor. Repeated blocks are written out in full, so the file is longer but has no references to maintain.

How to Read the Results and Fix Common Errors

A successful conversion shows "Converted successfully." and an output panel. A failed one shows "Conversion failed:" with a reason. Most reasons fall into a few groups, and each has a quick fix.

MessageCauseFix
JSON objects require string map keys.A YAML key is a number, boolean or nullQuote the key, such as "200"
A number cannot be represented safely in JSON.An integer is too large, or a value is infinite or not a numberWrap large IDs in quotes
Cyclic aliases cannot be represented in JSON.An alias refers back to its own parentRemove the circular reference
Expanded document exceeds 50000 values.Aliases expand into a very large treeReduce alias reuse or split the file
Input must be 1 MB or smaller.The pasted text is too bigConvert it in smaller parts

Syntax errors from the parser, such as a bad indent or an unclosed quote, also appear in the status line. For JSON input that will not parse, the usual culprits are trailing commas, single quotes and unquoted keys. Fix those first, or run the text through a JSON formatter and validator to find the exact line.

Spotting type surprises

If a value converts to the wrong type, look at the quotes. A bare 08 or 1e3 may be read as a number, while "08" stays text. If you need a string, quote it in the source. Words like yes and no stay strings under YAML 1.2, while true and false become booleans.

YAML vs JSON: Which Should You Use?

Use YAML when people edit the file by hand, and JSON when programs exchange the data. YAML is easier to read and allows comments, which is why Kubernetes, Docker Compose and many CI systems use it. JSON is stricter and has fewer surprises, which is why it dominates web APIs and browser code.

Indentation errors are the main risk in YAML, because a single misplaced space can change the meaning of a document. JSON's brackets and quotes make structure explicit, but the format has no comments and no trailing commas. Converting between the two lets you write in the format that suits you and ship in the format the target system needs.

When This Converter Is the Right Tool

The converter fits any job where the same data must live in both formats. These are the situations where it earns its place:

  • OpenAPI and Swagger specs. Some gateways and documentation tools accept only JSON. Paste your YAML spec, click YAML → JSON, and copy the output.
  • Kubernetes and Helm work. Convert a manifest to JSON to inspect its structure, or turn a JSON snippet into YAML for a manifest.
  • Docker Compose and CI files. Check how a value is typed, such as a port or a flag, before it reaches a pipeline.
  • API payload to config. Convert a JSON response into YAML to use as a fixture or a readable config file.
  • Learning and teaching. Seeing the same data in both syntaxes side by side is the quickest way to understand how they map.

If your source data is XML or a spreadsheet instead, the XML to JSON converter and the CSV to JSON converter cover those first steps. You can then bring the JSON back here to produce YAML.

Best Practices and Troubleshooting Tips

A few habits make conversions predictable and keep surprises out of your configs.

  • Convert one document at a time. Paste a single YAML document rather than several documents joined by separator lines.
  • Quote anything that must stay text. Version numbers, zip codes, phone numbers and long IDs are safer in quotes.
  • Use spaces, not tabs. YAML indentation must use spaces. A tab is a common cause of a parse failure.
  • Compare before you commit. After a round trip, paste the original and the result into the code diff tool to confirm that only comments and formatting changed.
  • Keep your comments elsewhere. Conversion drops them, so keep the original YAML as the source of truth and treat the JSON as generated output.
  • Test the round trip. Use Swap to push the output back into the Input box and convert again. If the data matches the original, your file uses only features both formats support.

If the output looks wrong but no error appears, check the types first. Most mismatches come from an unquoted value that was read as a number or boolean.

Limitations to Keep in Mind

This converter handles one YAML or JSON document per conversion, up to 1 MB of input. It deals with data only. It does not validate your file against a schema, such as a Kubernetes resource definition or an OpenAPI rule set, so a file can convert cleanly and still be invalid for its target system.

Some YAML content cannot become JSON at all. That includes non-string keys, circular aliases, infinite numbers and integers beyond the safe range. In those cases the tool stops with an error instead of producing output that might be silently wrong. For more utilities like this, browse the web developer tools collection, and use the code beautifier when you only need to tidy markup or scripts.

Paste your config into the Input box above, choose YAML → JSON or JSON → YAML, and copy a clean result in seconds. If something fails, the status message tells you what to fix.

Frequently Asked Questions

How do I convert YAML to JSON?
Paste your YAML into the Input box and click YAML → JSON. The JSON appears in the output panel with 2-space indentation. Click Copy to take it with you. If the YAML has a syntax problem, the status line explains what failed.
How do I convert OpenAPI or Swagger YAML to JSON?
Paste the full spec into the Input box and click YAML → JSON. Any anchors or aliases in the spec are expanded in the result. Comments are removed because JSON cannot store them. The tool does not check the spec against the OpenAPI schema.
What is the difference between YAML and JSON?
YAML is an indentation-based format that supports comments and is easy to edit by hand, while JSON uses braces, brackets and quotes and is strict. Most JSON is valid YAML 1.2. YAML adds features like comments and aliases that JSON lacks.
Why does my YAML to JSON conversion fail with a map key error?
The message JSON objects require string map keys means a YAML key is a number, boolean or null. JSON keys must be text. Put the key in quotes, for example "404": Not Found, then convert again.
Does the converter keep my YAML comments and anchors?
No. Comments are dropped because JSON has no comment syntax. Anchors and aliases are expanded into full copies of the data, so the JSON has no references. Cyclic aliases, where a block points back to itself, are rejected with an error.
Is the YAML JSON converter free, and is there a size limit?
Yes, the converter is free and needs no sign-in. Input must be 1 MB or smaller, and a document that expands to more than 50000 values is rejected. For larger files, split the content and convert it in parts.
Recommended

Explore VPN options

A VPN changes your network exit. It does not guarantee anonymity.

Hide Your IP Encryption Network coverage
Protect My IP Now

YAML conversion

Uses YAML 1.2 core scalar rules, merge aliases and string-key maps. Literal and folded blocks preserve their parsed meaning. Cyclic aliases, unsafe JSON numbers and non-string keys are rejected. Limits: 1 MB input and 50,000 expanded values.

Implementation reviewed: 4 October 2026. Source documentation