Convert JSON to YAML!

Input JSON to convert it into readable YAML (yml)! For Kubernetes, docker-compose and Spring application.yml.
JSON
Result
 

Convert JSON to YAML!

This turns JSON into indentation-based YAML. Braces and most quotes disappear, which makes the result easier to maintain by hand as a config file, and key order stays exactly as in the source JSON.

It helps when you move a resource fetched with kubectl get -o json into a manifest, or paste settings received from an API into docker-compose.yml, application.yml or a GitHub Actions workflow.

How to use

  1. Paste JSON into the JSON box. Invalid syntax shows JSON parsing failed in the result; run it through the JSON validator first if needed.
  2. Review the YAML under Result. Indentation is two spaces.
  3. Copy it into your .yml file, adjusting the indent depth if you nest it under another block.

Example

Input (JSON)
{
  "services": {
    "web": {
      "image": "nginx:1.27",
      "ports": ["8080:80"],
      "environment": { "FEATURE_FLAG": "on", "GREETING": "hello\nworld" }
    }
  }
}
Output (YAML)
services:
  web:
    image: nginx:1.27
    ports:
      - 8080:80
    environment:
      FEATURE_FLAG: "on"
      GREETING: |-
        hello
        world

The string "on" keeps its quotes: written bare as on, a YAML 1.1 parser would read it as boolean true. GREETING contains a newline, so it is emitted as a |- block that shows each line as written.

Supported features

  • Quoting follows YAML 1.1. Strings like yes, no, on, off, y, n, ~, null, and look-alikes such as "0777", "1.0" or "2024-01-01", are quoted so PyYAML (1.1) and modern 1.2 parsers read the same value.
  • Strings such as 22:22, which YAML 1.1 can read as a base-60 number, are quoted too, avoiding a classic docker-compose port-mapping bug.
  • Multi-line strings become |- literal blocks.
  • Long strings are never folded (no line width limit).
  • Empty arrays and objects stay as [] and {}.

Use cases

From kubectl JSON output to a manifest

Convert a Deployment or ConfigMap pulled from the cluster as JSON, delete fields like status and metadata.uid, and you have a manifest ready for Git.

Writing Spring Boot application.yml

A block of properties received as JSON from a config server or docs becomes a YAML hierarchy, so you don't have to indent keys like spring.datasource.url by hand.

Notes and limitations

  • No comments, anchors (&) or aliases (*) are generated; an object repeated in the JSON is repeated in the YAML.
  • Integers above 9007199254740991 lose precision because of JavaScript's number limit; keep long IDs as strings in the JSON.
  • The output is a single document. For a multi-resource file separated by ---, convert each resource and join them yourself.

FAQ

Why are some strings quoted and others not?

Quotes are added only where a bare value would be read as another type. nginx:1.27 is a string either way, but on, 010 and 22:22 turn into booleans or numbers in some parsers, so they get quoted.

Can I apply the output to Kubernetes directly?

The structure is valid as is. Output from kubectl get -o json carries server-populated fields such as status, resourceVersion and managedFields, though, and those are best removed before applying.

Can I switch to four-space indentation?

There is no option; it is fixed at two spaces, the convention used throughout Kubernetes, docker-compose and GitHub Actions documentation.