YAML to JSON Converter

Paste YAML, including Kubernetes manifests, Compose files and CI pipelines, and get valid JSON. Anchors and merge keys are resolved, multiple documents become an array, and nothing is uploaded.

Input
Output

    Nothing leaves your browser. Shortcut: Ctrl/⌘ + Enter runs the main action.

    How YAML maps to JSON

    YAML mappings become JSON objects, sequences become arrays, and scalars become strings, numbers, booleans or null according to the YAML 1.2 core schema. A few YAML features have no JSON equivalent and are converted as follows:

    YAML featureIn JSON
    Comments (# …)Dropped
    Anchors and aliases (&base, *base)Resolved into copies of the value
    Merge keys (<<: *base)Keys merged into the mapping
    Several documents separated by ---One array with one item per document
    Block scalars (|, >)Strings with the newlines YAML defines
    Non-string keys (1: a, true: b)String keys ("1", "true")
    .inf, .nannull, with a warning

    How to convert YAML to JSON

    1. Paste the YAML or open a .yaml / .yml file. Syntax errors are listed with their line numbers.
    2. Choose the JSON indentation (2 spaces, 4 spaces or tab) and whether to sort keys.
    3. Click To JSON. Use Minify instead for single-line JSON.

    Example: anchors and merge keys

    defaults: &defaults
      retries: 3
      timeout: 30
    production:
      <<: *defaults
      timeout: 60

    converts to

    {
      "defaults": {"retries": 3, "timeout": 30},
      "production": {"retries": 3, "timeout": 60}
    }

    (shown compactly here). The explicit timeout: 60 wins over the merged value.

    Exact numbers

    Integers are parsed as arbitrary-precision values, so an ID such as 12345678901234567890 appears in the JSON exactly as written. Many converters turn it into 12345678901234567000 because they go through JavaScript numbers.

    To go the other way use JSON to YAML; to check the YAML first use the YAML validator.

    YAML to JSON questions

    What happens to comments when converting YAML to JSON?

    They are dropped, because JSON has no comment syntax. If you need to keep them, keep the YAML as the source of truth and generate JSON from it when needed.

    How are anchors, aliases and merge keys handled?

    They are resolved. An alias (*name) is replaced by a copy of the anchored value, and a merge key (<<: *defaults) copies the anchored mapping's keys into the current mapping, with keys written explicitly taking precedence.

    What if my file has several YAML documents?

    Documents separated by --- become the items of one JSON array, in order. A status message tells you how many documents were combined.

    Which YAML version is used?

    YAML 1.2 core schema, the current specification. So yes and no stay strings and 0755 is the decimal number 755. The validator warns about such values because YAML 1.1 tools read them differently; quote them if the YAML is also consumed by PyYAML or similar.

    Can YAML contain things JSON cannot?

    Yes: comments, anchors, non-string keys, special floats (.inf, .nan) and custom tags. Non-string keys become strings, .inf and .nan become null with a warning, and tags are applied where the core schema knows them.