Skip to content

Runs entirely in your browser. Nothing you paste leaves this page.

Free / No sign-up

YAML to JSON converter (and back).

Convert YAML to JSON or JSON to YAML as you type, with the exact line and column of any error, multi-document streams, anchors and merge keys, and YAML 1.1 vs 1.2 gotchas flagged.

Direction
YAML version
Indentation

Output JSON

[
  {
    "defaults": {
      "region": "eu-west-1",
      "replicas": 2
    },
    "services": {
      "api": {
        "region": "eu-west-1",
        "replicas": 2,
        "image": "nexzem/api:3.10"
      },
      "worker": {
        "region": "eu-west-1",
        "replicas": 4
      }
    },
    "countries": [
      "GB",
      "NO",
      "IE"
    ],
    "backup_window": "22:30",
    "zip": 2134
  },
  {
    "kind": "feature-flags",
    "dark_mode": "on"
  }
]

4 YAML 1.1 vs 1.2 gotchas

  • L12 NO1.2: "NO" · 1.1: false. YAML 1.1 reads yes/no/on/off/y/n as booleans (the Norway problem: NO for Norway becomes false).
  • L13 22:301.2: "22:30" · 1.1: 1350. YAML 1.1 reads colon-separated numbers as base 60 (22:30 becomes 1350).
  • L14 021341.2: 2134 · 1.1: 1116. Leading zero: YAML 1.1 reads 0-7 digits as octal, YAML 1.2 drops the zero. Quote codes like ZIPs and phone numbers.
  • L17 on1.2: "on" · 1.1: true. YAML 1.1 reads yes/no/on/off/y/n as booleans (the Norway problem: NO for Norway becomes false).

2 documents (output as a JSON array), 1 anchor, 2 aliases resolved. Parsed with YAML 1.2 rules (the current spec); merge keys (<<) are supported.

How to use it.

  1. 01

    Paste YAML (or JSON) or load the sample. It converts as you type.

  2. 02

    Pick the direction, YAML 1.2 or 1.1 rules, and the indent width. Swap sends the output back as input.

  3. 03

    Check the gotcha list for values the two YAML versions read differently, then copy the result.

What it does.

Everything this tool handles, all of it inside your browser tab.

  • YAML to JSON and JSON to YAML, converted as you type
  • YAML 1.2 (default) or YAML 1.1 parsing rules
  • Flags Norway-problem booleans, octals, base-60 numbers, lost trailing zeros and unsafe big integers
  • Multi-document streams output as a JSON array
  • Anchors, aliases and << merge keys resolved, with alias-bomb protection
  • Errors with exact line and column, and Show me to jump there
  • Swap sends the output back as the new input
  • 2 or 4 space indentation and one-click copy
  • Runs entirely in your browser: no upload, no sign-up

Worked examples.

  • The Norway problem

    countries: [GB, NO, IE]
    port_mode: 0755
    window: 22:30
    
    > YAML 1.2: {"countries": ["GB", "NO", "IE"], "port_mode": 755, "window": "22:30"}
    > YAML 1.1: {"countries": ["GB", false, "IE"], "port_mode": 493, "window": 1350}

    Three values, three different readings. Quote them ("NO", "0755", "22:30") and every parser agrees.

  • Anchors and merge keys to JSON

    base: &base
      image: node:22
      retries: 2
    build:
      <<: *base
      script: npm run build
    
    > {
      "base": { "image": "node:22", "retries": 2 },
      "build": { "image": "node:22", "retries": 2, "script": "npm run build" }
    }

    The merge key copies image and retries into build. JSON has no references, so the values are duplicated.

  • Two Kubernetes documents become an array

    apiVersion: v1
    kind: Service
    ---
    apiVersion: apps/v1
    kind: Deployment
    
    > [
      { "apiVersion": "v1", "kind": "Service" },
      { "apiVersion": "apps/v1", "kind": "Deployment" }
    ]

    Each document separated by --- becomes one element, in order.

  • A key indented one space too far

    items:
      - a
      - b
     key: c
    
    > All mapping items must start at the same column at line 4, column 1.

    key starts in column 2 while items starts in column 1. Move it back to column 1, or indent it under a list item if that was the intent.

  • JSON to YAML with safe quoting

    {"name":"api","version":"3.10","zip":"02134","enabled":"yes"}
    
    > YAML 1.1 mode:
    name: api
    version: "3.10"
    zip: "02134"
    enabled: "yes"

    In 1.2 mode enabled: yes is left unquoted (it is a string in 1.2) and flagged, because a 1.1 parser such as PyYAML would read it as true.

How the converter works

YAML is parsed with the open-source yaml library by Eemeli Aro, a zero-dependency parser that implements both YAML 1.2 and YAML 1.1 and reports exact positions. It runs inside your browser tab, so configs with hostnames, secrets placeholders or customer data never leave your machine.

Every document in the stream is read, anchors and aliases are resolved, and merge keys (<<) are applied. One document becomes one JSON value; several documents become a JSON array, one item per document. In the other direction, JSON is validated first (with the same line-and-column errors as our JSON formatter) and then written as block-style YAML.

Comments do not survive YAML to JSON, because JSON has no comment syntax. Key order is preserved both ways.

The Norway problem: YAML 1.1 vs 1.2

YAML 1.1 (2005) treats many plain words as booleans: yes, no, on, off, y and n in several capitalisations. So a list of country codes [GB, NO, IE] comes out as ["GB", false, "IE"], and Norway disappears. YAML 1.1 also reads 0755 as an octal number (493) and 22:30 as base-60 (1350). YAML 1.2 (2009, revised as 1.2.2 in 2021) keeps only true, false and null as special words, reads 22:30 as a string and treats a leading zero as plain decimal.

Which one you get depends on the library, not the file. PyYAML, and therefore many Python tools, follows 1.1. Ruby's Psych follows 1.1. go-yaml v3 reads 1.2 but still accepts yes/no/on/off when decoding into a bool field. js-yaml 4 and the yaml package follow 1.2. A classic case: PyYAML loads the top-level on: key of a GitHub Actions workflow as the boolean True.

The gotcha list under the output flags every plain value that the two versions read differently, plus values that quietly change in both: 3.10 becomes 3.1 and integers above 2^53 lose precision. The fix is always the same: quote the value. JSON to YAML in 1.1 mode quotes these strings for you, and the result reads the same under either version.

Anchors, aliases and merge keys

An anchor (&defaults) names a node, an alias (*defaults) reuses it, and a merge key (<<: *defaults) copies the anchored mapping's keys into the current one, with local keys winning. CI pipelines, Docker Compose files and Helm values use this to avoid repetition. Merge keys come from YAML 1.1 and are not part of the 1.2 core schema, but most tools support them and so does this converter.

JSON has no references, so each alias is expanded into a full copy. To stop a crafted file with nested aliases (a "billion laughs" attack) from freezing the tab, expansion is capped; real configuration never comes close to the cap.

Multi-document YAML

A line containing only --- starts a new document, and ... can end one. Kubernetes manifests often bundle a Deployment, a Service and a ConfigMap in one file this way. The converter outputs a JSON array with one element per document, in order, and the status line tells you how many it found.

If you need one JSON file per resource, copy the elements individually. Note that kubectl accepts JSON manifests too, so the converted output can be applied directly. If you are new to the platform, our Kubernetes for small teams guide explains when it is worth it.

Reading YAML error messages

Most YAML errors are indentation errors. Indentation must use spaces, never tabs, and every key in a mapping (or item in a list) must start in the same column. A key indented one space too far is read as a continuation of the previous value, which produces messages such as "All mapping items must start at the same column" or "Nested mappings are not allowed in compact mappings".

Each error shows the line and column where the parser gave up, and Show me selects that spot in the input. When several errors are listed, fix the first one: the rest are often consequences of it. Unquoted values containing ": " or starting with characters such as @, `, % or * are another common cause; wrap them in quotes.

YAML in CI, Kubernetes and Docker Compose

Most YAML that developers touch configures another tool: GitHub Actions and GitLab CI pipelines, Kubernetes manifests, Helm values, Docker Compose files, OpenAPI specs and Ansible playbooks. Each tool picks its own parser, which is why the same file can behave differently in two places. The JSON output shows exactly what a parser sees, with no ambiguity: a string has quotes, a number or boolean does not.

Converting also helps with tooling. jq, API clients and every language's standard library read JSON, so turning a manifest into JSON lets you query it, diff it or feed it to a script without a YAML dependency. In the other direction, JSON produced by a script or an API becomes readable YAML for a pull request.

Template syntax such as Helm's {{ .Values.image }} or a GitHub Actions expression like ${{ github.ref }} is not part of YAML; those tools expand it before or after parsing. The converter treats it as plain text, which is what you want when you are checking structure. Unquoted, a value that starts with {{ is read as a flow mapping and fails, which is why Helm charts quote such values.

JSON to YAML: what to expect

Every JSON document is also valid YAML 1.2, so YAML tools can read JSON directly. Converting is about readability: block style with indentation, no braces and fewer quotes. Strings that would be misread as numbers or booleans stay quoted, so "02134" and "3.10" keep their meaning.

Numbers go through JavaScript, so integers above 9,007,199,254,740,991 lose precision; send large IDs as strings. Line width is unlimited, so long strings stay on one line instead of being folded. For typed code from the same payload, try JSON to TypeScript.

Questions, answered

Something else on your mind? Ask a consultant and get a reply within one business day.

Is my YAML uploaded anywhere?

No. Parsing and conversion run in your browser with the open-source yaml library. Nothing is sent to a server.

What is the YAML Norway problem?

In YAML 1.1, plain NO, no, off and n are booleans, so the country code NO for Norway becomes false. YAML 1.2 reads them as strings. Quote such values to be safe with every parser.

Should I use YAML 1.2 or 1.1 mode?

Use the version your consuming tool implements. Python's PyYAML and Ruby follow 1.1; js-yaml 4, the yaml package and most newer libraries follow 1.2. When unsure, quote ambiguous values and both agree.

How are multiple YAML documents converted?

Each document separated by --- becomes one element of a JSON array. A single document converts to a single JSON value.

Are anchors and aliases supported?

Yes. Anchors, aliases and << merge keys are resolved. Because JSON has no references, aliased content is copied into each place it is used.

Why are my YAML comments missing from the JSON?

JSON has no comment syntax, so comments cannot be carried over. Converting JSON back to YAML will not restore them.

Why does 3.10 become 3.1?

An unquoted 3.10 is a number in YAML and JSON, and numbers drop trailing zeros. Quote version strings as "3.10" to keep them as text.

Can I use tabs for indentation in YAML?

No. The YAML spec forbids tabs for indentation, and parsers reject them. Use spaces, typically two per level.

Is JSON valid YAML?

Yes, any JSON document is valid YAML 1.2, so YAML tools can read it as is. Converting to block-style YAML just makes it easier for people to read and edit.

Is there a size limit?

No fixed limit. Files of a few megabytes convert quickly; very large files may take a moment because everything runs in the tab.

More free tools.

All tools

Need tooling like this inside your product?

We build internal tools, developer platforms and APIs. Tell us what your team keeps doing by hand.