UseToolSuite UseToolSuite

JSON ↔ YAML Converter

Convert JSON to YAML and YAML to JSON in one tool. Bidirectional, with syntax validation — ideal for Kubernetes configs, Docker Compose, and API work.

Both directions in one tool Converts instantly as you type Configurable indentation Runs entirely in your browser
Converted output will appear here...

The implicit-typing minefield, mapped

Most YAML→JSON surprises trace to bare scalars that YAML types for you:

You wroteYAML 1.1 readsKeep it a string with
country: NOfalsecountry: "NO"
version: 1.101.1 (float)version: "1.10"
mode: 0755493 (octal)mode: "0755"
when: 2026-06-12date objectwhen: "2026-06-12"
id: 1e2100.0id: "1e2"

The defensive habit that prevents all of these: quote every string that isn’t obviously a word, especially anything resembling a number, date, or two-letter code. Converting to JSON here is itself a great audit — scan the output for values that changed type unexpectedly.

Indentation rules that trip up hand-written YAML

YAML forbids tabs for indentation — a single tab character fails the parse with a confusingly located error. Sequence items (- item) must align consistently, and a common Kubernetes-manifest bug is a list indented one space differently between siblings, silently creating a different structure rather than an error. When YAML “parses but behaves wrong,” convert it to JSON here: the brackets make the actual structure unambiguous in a way indentation never quite does.

Anchors, aliases, and what conversion does to them

YAML’s &anchor / *alias / <<: merge let one block reuse another — heavily used in CI configs (GitLab CI, docker-compose) to avoid repetition. JSON has no equivalent, so conversion expands every alias into a full copy. That’s correct and lossless for the data, but be aware the round trip won’t restore the anchors: a 40-line YAML with shared defaults can become a 200-line JSON, and converting back yields the expanded form. Treat anchored YAML as source code and its JSON form as compiled output.

Comments don’t survive — plan accordingly

JSON has no comment syntax, so every # explanation in your YAML is dropped on conversion, and there is nothing to restore on the way back. When migrating commented configuration permanently to JSON, move essential comments into the data itself (a "_comment" key or proper documentation). For one-way inspection — converting YAML to JSON just to query it with jq or validate structure — the loss is irrelevant.

Last updated Built and maintained by Necmeddin Cunedioglu How tools are tested

How to Use This Tool

  1. 1

    Pick the direction

    Choose YAML → JSON or JSON → YAML with the toggle buttons at the top.

  2. 2

    Paste your input

    Paste or type into the input pane. The output converts as you type, and syntax errors are reported with their location.

  3. 3

    Copy the result

    Adjust the indentation if your config style needs it, then copy the converted output or load a sample to experiment.

How helpful was this tool?

Click to rate

Key Concepts

Block Scalar (|- and >)

YAML's special notation for multi-line strings. The literal block scalar (|) preserves line breaks exactly as written — ideal for scripts and code. The folded block scalar (>) joins lines with spaces — good for long text paragraphs. Adding a - (e.g., |-) strips trailing newlines. These have no JSON equivalent and are lost during conversion.

Frequently Asked Questions

Does this tool preserve YAML comments during conversion?

No. YAML comments (lines starting with #) are lost during conversion to JSON because JSON does not support comments. If you convert back to YAML, the original comments will not be restored.

Can I convert multi-document YAML files?

The tool processes single YAML documents. If your file contains multiple documents separated by ---, you should convert each document individually. Multi-document YAML is commonly used in Kubernetes manifests.

Does the converter handle YAML anchors and aliases?

Basic YAML anchors (&) and aliases (*) are resolved during conversion to JSON. The referenced values are expanded inline in the JSON output, producing a fully self-contained JSON document.

What happens if my YAML has invalid syntax?

The tool validates the YAML syntax before conversion and displays a clear error message indicating the line and position of the syntax error. This helps you quickly identify and fix issues in your YAML content.

Why do unquoted values like no, on, or 1.0 change type after conversion?

YAML's implicit typing interprets bare scalars: under YAML 1.1 rules, no/yes/on/off become booleans (the infamous 'Norway problem' — country code NO turning into false), 1.0 becomes a float (dropping the trailing zero), and 0755 may parse as octal. Quote any value that must stay a string ('no', '1.0', 'NO') and the round-trip is exact.

How do I keep multi-line strings intact when converting?

YAML's block scalars control this: the literal style (|) preserves every newline exactly — right for certificates, scripts, and SQL — while the folded style (>) joins lines into spaces for readable paragraphs. Converted to JSON, both become a single string with \n escapes; converting back, the tool re-emits a block scalar when the string contains newlines.

Troubleshooting & Technical Tips

YAMLException: bad indentation of a mapping entry at line X

YAML is sensitive to indentation using space characters and does not accept tabs. This error typically occurs when there is a tab-space mix or inconsistent indentation levels. Set your editor to "spaces only" mode and verify that all indentation levels consistently use either 2 or 4 spaces. Use your editor's "show whitespace" feature or grep to find any existing tab characters.

YAMLException: duplicate key "apiVersion" at line X

The YAML specification does not allow duplicate keys at the same level. This is commonly encountered in Kubernetes manifest files due to copy-paste errors. Check your YAML file for multiple keys with the same name and either remove the duplicates or rename them.

Special characters in string values corrupted during JSON to YAML conversion

Characters like colon (:), hash (#), and exclamation (!) have special meaning in YAML. When string values containing these characters are written without quotes, they can cause parsing errors. After conversion, verify that such values are enclosed in double (") or single ('') quotes. URLs, file paths, and API keys are especially susceptible to this issue.

Multiline string conversion error: |- and > block scalars

YAML block scalar notations (|- literal block, > folded block) are converted to plain string values in JSON. The |- notation preserves line breaks, while > converts line breaks to spaces. When converting back from JSON to YAML, these special formats are not automatically restored; you may need to manually add the block scalar notation if needed.

Related Guides

Related Tools

Embed this tool on your site

Paste this snippet into any HTML page or blog post to embed a live, fully working copy of JSON ↔ YAML Converter. Free for any use.