4Devs.tech

    YAML to JSON Converter (and JSON to YAML)

    Paste YAML or JSON and convert it both ways instantly. Errors show the exact line, and nothing leaves your browser.

    Features

    • YAML → JSON and JSON → YAML
    • Syntax validation with line numbers
    • Supports anchors, multi-line strings and comments
    • Private: runs locally in your browser
    • Ideal for Kubernetes, Docker Compose, GitHub Actions

    YAML vs JSON: When to Use Each and How to Convert Safely

    YAML and JSON describe the same data structures: objects, lists, strings, numbers and booleans. YAML is designed for people to write by hand, which is why Kubernetes, Docker Compose and CI pipelines use it. JSON is stricter and easier for programs to parse, which is why APIs use it. Converting between them is common when you need to feed a config file into a tool that expects the other format.

    Indentation is the most common YAML error

    YAML uses spaces for nesting and forbids tabs. A single misaligned space can move a key under the wrong parent without causing an error, so the converted JSON is a good way to check that the structure is what you intended.

    Strings that change type

    Unquoted values like 1.10, 0755 or 2026-01-01 can be read as numbers or dates. Version numbers are a classic trap: version: 1.10 becomes the number 1.1. Quote any value that must stay a string.

    version: "1.10"   # string
    version: 1.10     # number 1.1

    Multi-line strings

    Use | to keep line breaks exactly (good for scripts and certificates) and > to fold lines into one paragraph. In JSON these become a single string containing \n characters.

    Converting on the command line

    For scripts and CI, the yq tool converts in one step:

    yq -o=json config.yaml > config.json
    yq -P config.json > config.yaml

    Frequently asked questions