PrettifyPrettify

YAML to JSON Converter

Paste YAML and get formatted JSON in the same window. Prettify parses the YAML in your browser, expands anchors and merge keys, and writes JSON with two-space indentation. Copy the result or download it as prettify.json. A file with several documents converts one document at a time.

JSON
The converted result shows here as you paste.
Runs in your browser. Nothing is uploaded.

How YAML maps to JSON

A YAML mapping becomes a JSON object, and a sequence becomes an array. A scalar becomes a string, a number, a boolean, or null. Keys keep the order you wrote, except that keys that are whole numbers, such as 2024, move to the front.

YAML allows some things that JSON does not. Anchors (&name), aliases (*name), and merge keys (<<) are resolved first, so the JSON holds full values and no references. The anchor definition stays in the output as an ordinary key.

Key features

YAML hides a lot of typing in plain text, so a value can mean more than it shows. These are the rules Prettify uses when it decides what each value is, and what the JSON then holds.

  • Comments are removed, because JSON has no comments. The panel always shows a note about this, even when your YAML has none.
  • A date such as 2026-03-01 stays the string "2026-03-01". It does not become a timestamp.
  • The words true and false become booleans. The words null and ~, and an empty value, become null.
  • The words yes, no, on, and off stay strings, as they do in YAML 1.2.
  • A block scalar written with | keeps its line breaks. A folded scalar written with > joins its lines with spaces.
  • A number is a plain number: 30.0 becomes 30, and 1.10 becomes 1.1.
  • An integer past 9007199254740991 loses its last digits, and the panel gives no warning. Quote it in the YAML to keep it as a string.

How to convert YAML to JSON

Start in the box at the top of this page. It reads documents up to 512 KB. When the YAML has an error, the panel shows the line and column, and the button changes to "Fix it in the editor".

  1. Paste your YAML into the box labeled "Paste your YAML", or select "Try an example".
  2. Read the JSON in the result panel. The summary tells you how many keys the document has and how deep it goes.
  3. Select Copy to put the JSON on the clipboard, or select Download to save it as prettify.json.
  4. Select "Open in full editor". The editor opens at /app/editor with the JSON in the Raw view.
  5. Switch to the Tree or Table view to check the structure.
  6. For a file with several documents, or a file above 512 KB, open the YAML in the editor and use Convert in the Transform group.

Worked example: a Compose file

The YAML below has a comment, an anchor named defaults, and two services that merge it. It also has a quoted port, a decimal with a trailing zero, and an empty value. The block after it is the JSON that Prettify produces.

The comment is gone. The api service lists restart and environment first, because the merge key copied them in. The x-defaults key stays, because it is ordinary data.

The image tag and the date stay strings. The number 30.0 becomes 30, and the empty notes value becomes null. The ports entry stays a string, because the YAML quoted it.

# Defaults shared by both services
x-defaults: &defaults
  restart: always
  environment:
    TZ: UTC

services:
  api:
    <<: *defaults
    image: acme/api:1.10
    ports: ["8080:80"]
    timeout: 30.0
    released: 2026-03-01
    notes:
  worker:
    <<: *defaults
    command: [run, --queue, jobs]

{
  "x-defaults": {
    "restart": "always",
    "environment": {
      "TZ": "UTC"
    }
  },
  "services": {
    "api": {
      "restart": "always",
      "environment": {
        "TZ": "UTC"
      },
      "image": "acme/api:1.10",
      "ports": [
        "8080:80"
      ],
      "timeout": 30,
      "released": "2026-03-01",
      "notes": null
    },
    "worker": {
      "restart": "always",
      "environment": {
        "TZ": "UTC"
      },
      "command": [
        "run",
        "--queue",
        "jobs"
      ]
    }
  }
}

Common use cases

Many tools read only JSON, while teams write their settings in YAML. Converting links the two without a script. These are the jobs people bring to this page most often.

  • Feed a Kubernetes, Compose, or CI file to a script or an API that expects JSON.
  • Turn an OpenAPI spec written in YAML into the JSON that a code generator needs.
  • See what a YAML parser really sees: expanded anchors, real types, and the final value of each key.
  • Find a value with the wrong type, such as a version that became a number.
  • Check a config in the Tree view after conversion, where a missing level is easy to spot.

Files with several documents

A YAML stream can hold several documents, separated by --- lines. JSON cannot join them into one value, so each document converts on its own.

The box on this page converts the first document and does not warn you about the rest. The editor reads all of them. It shows a Documents row above the view, with a button for each, such as Doc 1 and Doc 2. Pick a document, select Convert in the Transform group, and pick JSON. You get the JSON for the document you picked.

Frequently asked questions

Why are yes and on strings in the JSON?

Prettify follows YAML 1.2, where only true and false are booleans. Tools that follow YAML 1.1 read yes, no, on, and off as booleans. Quote those words when you write YAML for such a tool.

What do the error messages mean?

They come from the YAML parser and carry a line and column. Common ones are "tab characters must not be used in indentation", "bad indentation of a mapping entry", and "duplicated mapping key". Fix the named line and the box converts again.

Is my YAML uploaded to convert it?

No. The parser and the JSON writer run in your browser tab, so a manifest with image names, hostnames, or secret references stays on your device. Only a share link, which you create on purpose, sends data.

Can I query the YAML with jq without converting it first?

Yes. The jq panel in the editor runs on YAML as it does on JSON. jq is a Pro tool.

Can I get my comments back when I convert the JSON to YAML?

No. The JSON never held them. Keep the original YAML as your source, and use the JSON to YAML page only when you need the data back as YAML.

Related tools