Skip to content
MoneyDeck

JSON to YAML Converter

Convert JSON into clean, correctly quoted YAML for configs and manifests

Updated · Free, no signup

YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 3
  template:
    spec:
      containers:
        - name: web
          image: nginx:1.27
          ports:
            - containerPort: 80
          env:
            - name: DEBUG
              value: "false"

Validation

Valid JSON

Keys (all levels)

18

Nesting depth

8

YAML lines

18

  • 1 string value was quoted because unquoted it would be read as a number, boolean or null.

About the JSON to YAML Converter

This JSON to YAML converter rewrites a JSON document as clean, human-friendly YAML. Paste an API response, a package manifest or a JSON config and get YAML ready for Kubernetes manifests, Docker Compose, GitHub Actions or GitLab CI workflows, Ansible, Helm values files or OpenAPI specs.

The output is built to be both readable and safe. Objects become indented key: value blocks and arrays become "- " lists; multi-line strings become literal | blocks; and any string that a YAML parser could misread is quoted — numbers stored as text ("8080"), version strings like "1.10", booleans in disguise ("false", "yes", "no", "on", "off" — the Norway problem), dates, and values containing ": " or " #". Everything else is left unquoted, so the YAML stays tidy.

Choose 2- or 4-space indentation, indented or flush list items under a key (both are valid; Kubernetes docs use either), minimal, double or single quoting, and optional alphabetical key sorting. Every JSON document is valid input, the conversion is lossless, and it runs entirely in your browser.

How to use the json to yaml converter

  1. 1Paste your JSON document into the input.
  2. 2Choose 2- or 4-space indentation and the list style.
  3. 3Pick a quoting style and whether to sort keys.
  4. 4Check the validation message, then copy the YAML.

Formula and method

The JSON is parsed and written back out as YAML block style. Each object becomes a set of "key: value" lines; a nested object or non-empty array goes on the following lines, indented by the chosen step (lists can also sit flush with their key, which YAML allows). Array items start with "- ", and an object inside an array begins on the same line as its dash. Empty objects and arrays are written inline as {} and [].

Strings are left plain only when every YAML parser will read them back as the same string. Anything that looks like a number, boolean, null, date, or YAML 1.1 boolean word (yes, no, on, off), anything with leading or trailing spaces, a leading indicator character, ": " or " #", and anything containing control characters is double-quoted using JSON escape rules, which YAML double-quoted strings accept. Multi-line strings become literal blocks (| keeps the final newline, |- strips it). Numbers, true, false and null are written unchanged.

Worked examples

Kubernetes Deployment from JSON

Nested objects become indented blocks and the containers, ports and env arrays become "- " lists with each object starting on the dash line. "nginx:1.27" stays unquoted because its colon is not followed by a space, but the string "false" is quoted so it is not read as a boolean. The document has 18 keys and is 8 levels deep.

Values that must be quoted, flush lists, 4-space indent

NO (Norway) is quoted because YAML 1.1 parsers read no/NO as false — the famous Norway problem. "1.10" and "8080" would become the numbers 1.1 and 8080, "yes" a boolean and the date a timestamp, so they are quoted too, as are "a: b" and "#x", which contain YAML indicators. Lists sit flush with their key and 1.5 stays a number.

Multi-line string, sorted keys and document marker

Keys are sorted alphabetically, the empty object is written inline as {}, and the two-line script becomes a literal | block whose final newline is kept. The --- marker explicitly starts the YAML document.

Frequently asked questions

How do I convert JSON to YAML?+

Paste the JSON into the input box. Objects become indented key: value lines, arrays become "- " lists and strings are quoted only when needed. Copy the YAML output into your config file, Kubernetes manifest or CI workflow.

Is every JSON file valid YAML?+

Practically yes — YAML 1.2 was designed as a superset of JSON, so most YAML parsers can read JSON directly. Converting to block-style YAML is still worthwhile because it is easier to read, review in diffs and annotate with comments.

Why are some strings quoted in the YAML output?+

Unquoted, they would change type when parsed: "8080" would become a number, "1.10" the number 1.1, "false" or "yes" a boolean, and "2026-01-01" a date in some parsers. Quoting keeps them as the exact strings that were in the JSON.

What is the Norway problem in YAML?+

YAML 1.1 parsers such as PyYAML treat yes, no, on and off as booleans, so the country code NO for Norway could turn into false. This converter quotes these words so the YAML is safe for both YAML 1.1 and 1.2 parsers.

Should YAML list items be indented under their key?+

Both styles are valid YAML and parse identically. Indented items (key:\n - item) are the default in most formatters like Prettier, while flush items (key:\n- item) are common in Kubernetes and Ansible examples. Pick whichever your project’s linter expects.

Related tools