ToolBook
Support us on Ko-fi
Help us keep this free, forever

YAML ↔ JSON Converter

How to convert YAML to JSON online

Convert YAML or YML config files to JSON, or convert JSON to clean YAML format.

  1. Choose conversion direction

    Select YAML to JSON to parse a YAML or YML config file, or JSON to YAML to serialise JSON into YAML format.

  2. Paste your input or upload a file

    Paste the YAML or JSON text directly, or click Upload to load a .yaml, .yml, or .json file from your computer.

  3. Set the JSON indent level

    When converting YAML to JSON, choose 2 spaces, 4 spaces, or compact output using the indent selector.

  4. Read the converted output

    The converted result appears on the right instantly. Any parse errors are shown with a description.

  5. Copy or download the result

    Copy the output to clipboard or download it as a .json or .yaml file.

Frequently asked questions

What YAML features does the converter support?

The converter handles the patterns that appear in real-world config files: mappings (key: value), sequences (- item), nested structures, block scalars (| and >), quoted strings, and type inference for booleans, integers, floats, and null. Complex features like anchors (&), aliases (*), and multi-document streams are not supported.

Why would I convert YAML to JSON?

YAML is comfortable for humans to write and read but JSON is what most APIs, JavaScript runtimes, and data pipelines consume natively. Converting to JSON lets you paste a config value directly into a REST client, debug a GitHub Actions input, or verify a Kubernetes spec before applying it.

Why would I convert JSON to YAML?

JSON is verbose: every key needs quotes, every structure needs braces. YAML is cleaner for large configuration documents. Converting a JSON API response to YAML can make it much easier to read and annotate with comments before feeding it to a config management system.

Are comments preserved when converting YAML to JSON?

No. YAML comments (# lines) are stripped during parsing. They are not part of the data model and have no JSON equivalent.

What does "yes"/"no"/"on"/"off" convert to?

In YAML 1.1 (the version used by most tools), "yes", "no", "on", "off" are boolean values. They convert to true/false in JSON. If you need literal strings, quote them in YAML: "yes".

Can I convert a .yml or .yaml file directly?

Yes. Click the Upload button on the input panel to load a .yaml, .yml, or .json file from your computer. The file contents are read locally in your browser and never sent to any server. Files up to 1 MB are supported.

Does this work for Kubernetes manifests and Docker Compose files?

It works for most single-document Kubernetes and Docker Compose YAML files that use standard mappings and sequences. If your manifest uses YAML anchors (&) or aliases (*), or contains multiple documents separated by ---, those features are not supported and you should use a full YAML library for those cases.

Can I use this for GitHub Actions and CI/CD pipeline YAML?

Yes. GitHub Actions workflows use standard YAML mappings and sequences, which this converter handles correctly. Paste the workflow YAML into the input panel to convert it to JSON for debugging or inspection.

Is my data sent to any server?

No. All conversion happens entirely in your browser using JavaScript. Your YAML or JSON text is never transmitted to any server, stored, or logged.

YAML vs JSON: differences, use cases, and converting between them

Why configs use YAML and APIs use JSON, and when to switch between them.

YAML and JSON: two formats, one data model

YAML and JSON are both human-readable, text-based data serialization formats. They share the same underlying data model: strings, numbers, booleans, null, arrays, and objects. But they use very different syntax. Most valid JSON is also valid YAML 1.2, though the reverse is not true.

The formats evolved for different contexts:

  • JSON was designed for network transmission. It's compact, unambiguous, and parseable by a 50-line parser. Every language has a JSON library. REST APIs, browser localStorage, and configuration files all use JSON.
  • YAML was designed for human authoring. It supports comments, multi-line strings, anchors and aliases, and indentation-based nesting. These features make config files far more readable than equivalent JSON.

When to use each format

Use YAML for human-edited configuration files: CI/CD pipelines (GitHub Actions, GitLab CI), Kubernetes manifests, Docker Compose files, Ansible playbooks, and application config files (like Rails' database.yml or Webpack's config.js equivalent). Comments alone make YAML the right choice for configs that need documentation inline.

Use JSON for machine-to-machine data exchange: API responses, localStorage, IndexedDB, and inter-service communication. JSON is faster to parse, less ambiguous (no implicit type coercion, no yes/no for booleans), and has universal tooling support.

YAML's implicit type coercion traps

YAML 1.1 (the version most parsers implement) has some surprising behavior:

  • yes, no, on, off, true, false all evaluate as booleans.
  • 1.0 is a float, not a string.
  • Strings that look like hex (e.g., 0xFF) are parsed as integers.
  • The string "null" becomes null, not the string "null".

This means YAML config values often need explicit quoting: status: "off" rather than status: off. The converter handles this automatically when producing YAML output: values that would be misinterpreted are always quoted.

How YAML anchors and aliases are handled

YAML supports anchors (&name) and aliases (*name) to avoid repetition. The converter does not support round-tripping these. When YAML with anchors is converted to JSON and back to YAML, the repeated values will be inlined rather than aliased. This is expected behavior: JSON has no equivalent concept, so the structure is preserved but the optimization is lost.

Multi-line strings in YAML

YAML supports two block scalar styles:

  • Literal block (|): Preserves newlines as-is. Good for embedded scripts or long prose.
  • Folded block (>): Folds newlines to spaces, like paragraph text. Good for long single-line strings that you want to wrap for readability in the source file.

Both are converted to regular JSON strings. The | style produces a string with embedded \n characters; the > style produces a single space-separated string.

Practical tips

When generating YAML from JSON for a Kubernetes or Docker Compose config, review the output before committing it. Pay particular attention to boolean and numeric values that came in as JSON strings. The converter quotes strings that would otherwise be misinterpreted, but context-specific validators (like kubectl apply --dry-run) will catch any remaining type mismatches.

For large JSON API responses that you want to inspect in a more readable format, YAML output with proper indentation is often easier to read than indented JSON, because YAML omits all the double quotes and curly braces.