Skip to main content

JSON to YAML Converter — and YAML Back to JSON

Paste JSON and get block-style YAML with safe quoting, or switch to YAML → JSON to turn a config file into JSON. Everything runs locally in your browser; nothing is uploaded.

Features

  • JSON to YAML and YAML to JSON in one tool
  • Block-style YAML with two-space indentation
  • Quotes strings YAML would misread, such as "yes", "8080" or "nginx:1.27"
  • Reads comments, quoted strings, nested lists and lists of objects
  • JSON output with 2 or 4 spaces, tabs or compact
  • Runs entirely in your browser, nothing is uploaded

JSON or YAML: When You Need to Convert

YAML holds the same data as JSON (objects, lists, strings, numbers, booleans and null) but uses indentation instead of braces and allows comments. That is why configuration lives in YAML: Kubernetes manifests, docker-compose.yml, GitHub Actions workflows and many OpenAPI specs.

APIs and scripts, on the other hand, speak JSON. Convert JSON to YAML when an API response should end up in a manifest, and YAML to JSON when code or a JSON-only system needs your config. The page opens in JSON → YAML mode; YAML → JSON is in the same dropdown.

How the Converter Writes YAML

  • Indentation: always two spaces per level, with list items indented under their key. The Indentation setting only affects JSON output (YAML → JSON).
  • Quoting: a string gets quotes only where a YAML parser would read it differently: number-like values ("8080", "3.8"), words like "yes", "no", "on", "off", "true" or "null", empty strings and anything containing :, # or quotes. Keys follow the same rule.
  • Line breaks stay escaped as inside double quotes; the converter does not write | or > blocks.
  • Empty objects and lists become {} and [].

Example: a docker-compose Service

This JSON

{"services":{"web":{"image":"nginx:1.27","ports":["8080:80"],"environment":{"DEBUG":"false"},"restart":"always"}}}

becomes this YAML:

services:
  web:
    image: "nginx:1.27"
    ports:
      - "8080:80"
    environment:
      DEBUG: "false"
    restart: always

The image tag and the port mapping are quoted because of the colon, and "false" stays a string instead of turning into a boolean. Switch to YAML → JSON, paste the result back, and you get the same data as JSON again.

YAML to JSON: What the Parser Understands

The YAML reader covers what typical config files use: nested mappings, lists (also at the same indentation as their key), lists of objects like - name: web, comments, single- and double-quoted strings, unquoted values with colons such as nginx:1.27, true/false, null/~, integers, decimals and simple inline lists like [main, dev]. It is a subset, not a full YAML parser:

  • Anchors, aliases and merge keys (&base, *base, <<:) are not resolved: they stay as text or cause an error.
  • Block scalars (| and >), common in run: steps, stop with an indentation error.
  • Inline objects like {a: 1} stay a string, and a comma inside a quoted list item splits it.
  • Several documents: --- separators are skipped, so the documents are merged into one object.
  • Types: only lowercase true and false become booleans; yes, on, True, 1e5, 0x1F and dates stay strings.

For files that rely on these features, use a full YAML library.

Useful Resources

YAML 1.2.2 Specification The official YAML spec, including anchors, block scalars and the core schema for types
Wikipedia: YAML Overview of YAML syntax, its history and how it relates to JSON
RFC 8259: The JSON Data Interchange Format The standard that defines JSON syntax and data types
Kubernetes: Objects in Kubernetes How Kubernetes manifests are structured and why they are usually written in YAML
GitHub Docs: Workflow syntax for GitHub Actions Reference for the YAML keys used in GitHub Actions workflow files