YAML to JSON Converter

Instantly convert YAML to JSON or JSON to YAML. Pinpoints indentation and syntax errors with precise line and column numbers.

๐Ÿ“ Drag & drop .yaml / .yml / .json files or click to select
Files are read in the browser only ยท Max 8MB
Result

Support Coverage (frankly stated)
This parser is not a full YAML 1.2 spec implementation, but rather a direct implementation of the scope commonly used in real-world configuration files.
Supported โ€” Nested mappings/sequences, string/number/boolean/null scalars, single/double quoted strings (with escapes), block scalars |(literal)ยท>(folded) and chomping directives -ยท+ยทindentation directives, inline flow {}ยท[], # comments, multi-line plain scalars, - key: value compact mappings of the form, document start --- one.
Not supported โ€” Anchors &ยทAliases *, Merge Keys <<, Tags !!str, ? explicit keys, multiple documents, automatic date type conversion. If these syntaxes are encountered, instead of silently producing incorrect results, an error message will indicate the line number.
Booleans only accept true/falseaccording to the YAML 1.2 standard. yesยทnoยทonยทoffare strings; if found, a warning message will be displayed.

What is the YAML to JSON Converter?

YAML is the standard for modern configuration files, but its strict indentation rules can be unforgiving. This tool converts YAML to JSON, letting you see exactly how your file is being parsed and instantly revealing structural problems. It provides precise line-and-column error messages for invalid syntax, including tabs used for indentation. When converting JSON to YAML, it creates clean, readable output by quoting only when necessary and formatting multiline strings as easy-to-read block scalars. Since the entire conversion runs in your browser, your configuration files and any secrets they contain are never sent to a server.

How to use

  1. Choose a conversion direction like "YAML โ†’ JSON" or leave it on "๐Ÿ”€ Auto Detect".
  2. Paste your content into the "Input (YAML or JSON)" box, or drag and drop a .yaml, .yml, or .json file.
  3. The result appears instantly on the right. Any syntax errors are flagged with the exact line and column number.
  4. Customize the output using the "Indent", "Sort Keys (Aโ†’Z)", and "Short arrays on one line (YAML output)" options.
  5. Click "Copy" to get the result, or "Save" to download it as a file.

YAML to JSON Converter guide

How this tool is used in real work, and what to watch out for.

Why YAML Took Over Config Files, and the Price It Paid

JSON is dense with quotes and braces, and you can't add comments. Configuration files are meant to be opened and modified by humans every day, who need to leave notes like "why did I set this value this way?" JSON fails at both. That's why Docker Compose, Kubernetes, GitHub Actions, and Ansible all went with YAML.

But this comes at a price: structure is defined by indentation. One misplaced space can change the meaning of the entire file, and it's invisible in an editor. This tool's value lies in showing you how a "pretty-looking YAML" file is actually interpreted by converting it to JSON. When in doubt, convert it to JSON to check if the nesting matches what you intended.

Just looking at "Max Depth" and "Number of Keys" in the stats below the result can help you catch bugs. If a config that should be 2 levels deep comes out as 3, it means you've added an extra level of indentation somewhere.

The Norway Problem: When 'NO' Accidentally Becomes `false`

In YAML 1.1, `yes`/`no`/`on`/`off`/`y`/`n` were also booleans. This led to the famous "Norway problem," where listing the country code for Norway (`NO`) would be parsed not as the string "NO" but as the boolean value `false`. For example, `countries: [KR, JP, NO]` would become `[KR, JP, false]`.

YAML 1.2 removed these, recognizing only `true`/`false` as booleans. This tool follows the 1.2 standard, so `NO` is correctly parsed as the string "NO". But here's a more important fact: this tool's result might differ from how your actual server interprets the file.

Value WrittenThis Tool (YAML 1.2)YAML 1.1 ParserHow to Write Safely
NO"NO" (string)falseQuote it as "NO"
yes"yes" (string)trueWrite it as `true`
off"off" (string)falseWrite it as `false`
05300"05300" (string)May be read as octalQuote it as "05300"
1.201.2 (number)1.2 (number)If it's a version string, use "1.20"
Many parsers still in production, like the default loader in Python's PyYAML, still follow YAML 1.1 rules. Don't assume you're safe just because this tool produced a string. When in doubt, just quote the value. There's no downside to quoting. This tool will display a warning message if it encounters `yes`ยท`no`ยท`on`ยท`off` or numbers with leading zeros.

How to Quickly Catch Tab and Indentation Errors

YAML does not allow tabs for indentation. This tool will find any line containing a tab and point out its line and column number. The real problem is when you don't remember adding a tab. This usually happens when you copy-paste from another document or your editor is configured to insert tab characters for the Tab key.

  • In VS Code, click the "Spaces: 2" indicator in the bottom-right corner and change it to "Indent Using Spaces". Adding `[*.yml]` and `indent_style = space` to your `.editorconfig` file will keep your whole team safe.
  • If you can't see the error's cause on the line indicated, check the line directly above it. It's common for an error on one line (like an unclosed bracket or a missing space after a colon) to be caught on the next line.
  • A key-value pair must have a space after the colon (e.g., `key: value`). Without the space, `key:value` is not a valid mapping.
  • If a value needs to contain a colon followed by a space (e.g., timestamps, URL descriptions), you must wrap it in quotes. The "Insert Example" data includes an example of this.

Anchors (&) and Aliases (*) Are Not Supported

YAML has anchor/alias syntax and merge keys (`<<`) for defining a value once and reusing it. You'll often see this in the `x-common` pattern in `docker-compose.yml` or GitLab CI configurations. This parser does not implement this syntax. Instead of silently producing an incorrect result, it will halt with an error pointing to the line number.

We decided that failing silently is more dangerous. Ignoring an anchor results in a JSON where the referenced block is completely missing. It might look correct at a glance, leading to an error that's only discovered after deployment.

yaml
# This kind of file will cause an error
x-base: &base
  restart: always
  logging:
    driver: json-file

services:
  api:
    <<: *base        # Merge key and alias
    image: myapi:1.0

# It will be converted if you expand it like this
services:
  api:
    restart: always
    logging:
      driver: json-file
    image: myapi:1.0
If you absolutely must convert a file with many anchors, first expand them on your server with `yq eval "explode(.)" file.yml`, then paste the result here. Tags (`!!str`), explicit keys (`?`), multiple documents, and automatic date type conversion are also unsupported for the same reason.

Converting from JSON to YAML

The reverse direction is also common in practice. You might need to turn a JSON config from an API response into a draft YAML manifest, or you might need to dump a config object created in code into a file.

This tool adds quotes only when a string could be misinterpreted as another type. This includes values that look like numbers ("123"), booleans ("true"), or null; values containing a colon or `#`; values with leading or trailing whitespace; and the empty string. Long strings with newlines are converted to block scalars (`|`) for better readability.

Checking the "Short arrays on one line" option will render short arrays in flow style, like `[8080, 8443]`. This can dramatically reduce the line count in files with many short arrays, such as port lists or tags. On the other hand, if you plan to add a comment to each item, it's better to leave this option off.

The "โ†” Result to Input" button is useful for round-trip validation. By converting YAML โ†’ JSON โ†’ back to YAML and comparing it with the original, you can visually confirm that the parser's interpretation of the structure matches your own.

Indentation in the YAML output is always spaces. If you select "Tab" for indentation, it will only apply to the JSON output; the YAML output will use 2 spaces. This is because the YAML standard forbids tabs for indentation.

Frequently asked questions

Are my configuration files sent to your server?

No. All conversion happens directly in your browser. Nothing you paste or upload is ever transmitted, so your data and secrets remain completely private.

Why does it say `yes` / `no` is a string, not a boolean?

This tool follows the YAML 1.2 standard, where only `true` and `false` are booleans. While older versions treated `yes`/`no` as booleans, they are now just strings.

What's the quoting rule for JSON to YAML conversion?

Quotes are added only when necessary, like for values that look like numbers ("123") or booleans ("true"), or contain special characters, keeping the YAML clean.

Which YAML features are not supported?

It handles most practical configs but does not support anchors (&), aliases (*), merge keys (<<), tags (!), or multiple documents (---). It will show a clear error if it finds them.