JSON to YAML Converter

Convert JSON into readable YAML text.

What This Tool Does

This tool converts JSON into standard YAML text, right in your browser. Every JSON object is rewritten as a block of key: value pairs, and nested objects are indented two spaces deeper than their parent, with the child's keys placed on new lines under a key: header. JSON arrays are rendered using YAML's dash-list syntax: each item gets its own - line. When an array holds plain values (strings, numbers, booleans), each one becomes a simple - value line. When an array holds objects, each item starts with a dash on its own line, and the object's keys are indented two spaces beneath that dash. Any null (or missing/undefined) value in the source JSON is written out as the literal word null.

The conversion is purely structural and happens entirely client-side - nothing you paste into the input box is uploaded or stored anywhere.

How to Use It

  1. Paste or type valid JSON into the Input box on the left.
  2. Click the Run button to convert it.
  3. The resulting YAML appears in the read-only Output box on the right.
  4. Copy the YAML output and paste it into your config file, pipeline definition, or documentation.
  5. Click Clear to reset both boxes and start over.

Worked Example

Here is a typical config-style JSON object - it has a nested object (database) and an array of objects (services) - converted exactly as the tool's logic produces it:

Input JSON:

{
  "app": "web-service",
  "port": 8080,
  "debug": false,
  "database": {
    "host": "localhost",
    "port": 5432,
    "user": null
  },
  "services": [
    { "name": "api", "replicas": 3 },
    { "name": "worker", "replicas": 2 }
  ]
}

Output YAML:

app: web-service
port: 8080
debug: false
database:
  host: localhost
  port: 5432
  user: null
services:
  -
    name: api
    replicas: 3
  -
    name: worker
    replicas: 2

Notice that the nested database object is indented two spaces under its database: key, and each entry in the services array starts with a dash on its own line, with the object's fields indented two further spaces beneath it. This is the exact indentation pattern the converter's recursive logic produces for any depth of nesting.

Common Use Cases

Note on TOON vs YAML

This site also has a JSON to TOON converter. TOON is a different, more token-efficient format built specifically for pasting structured data into LLM prompts - it is not meant to replace YAML in config files. YAML, produced by this tool, is the standard format that most infrastructure and automation tools already expect. If you're feeding a config file to Docker, Kubernetes, or a CI/CD pipeline, use YAML. If you're compressing data for an LLM prompt to save tokens, use TOON instead.

Frequently Asked Questions

Does it preserve key order?

Yes. The converter reads your object's keys in the same insertion order JavaScript already preserves for JSON, so the YAML output lists keys in the same order they appeared in your input.

How are null values written?

Any null value, whether it's an object property or an array item, is written as the literal word null - not left blank and not quoted.

Is my data uploaded anywhere?

No. Everything runs client-side in your browser. Your JSON never leaves your machine or touches a server.

Does it handle deeply nested JSON?

Yes. The converter recurses into nested objects and arrays at any depth, adding two spaces of indentation per level.

What happens if my JSON is invalid?

The tool shows an error message below the input/output boxes instead of producing output, so you can fix the JSON and try again.

Related Tools & Guides