NV ToolkitFormat · Validate · Convert

Converters

JSON to YAML Converter

Re-express JSON as clean, human-friendly YAML — smart quoting, two-space indentation, list dashes done right.

In short

Convert JSON to YAML online: clean indentation-based output with smart quoting, ready for Kubernetes, CI pipelines, and config files. Free and instant.

By NaveenKumar T · Updated

Learn: JSON vs YAML: Which Format When?

  • Instant in-browser conversion
  • Validates input first
  • Smart YAML quoting rules

Runs entirely in your browser — nothing you paste or open here is uploaded, logged, or stored.How we handle data →

Example

JSON to YAML: input and output

A CI job definition: the values mix a numeric-looking string, a real boolean, strings containing YAML indicator characters (-, *, @) and a hyphenated key.

Input · JSON
{
  "name": "build-and-test",
  "on": { "push": { "branches": ["main", "release/*"] } },
  "env": { "NODE_VERSION": "20", "CI": true },
  "steps": [
    { "run": "npm ci" },
    { "run": "npm test -- --coverage", "timeout-minutes": 10 },
    { "uses": "actions/upload-artifact@v4", "with": { "path": "coverage/" } }
  ],
  "notes": ""
}
Output · YAML
name: "build-and-test"
on:
  push:
    branches:
      - main
      - "release/*"
env:
  NODE_VERSION: "20"
  CI: true
steps:
  - run: npm ci
  - run: "npm test -- --coverage"
    "timeout-minutes": 10
  - uses: "actions/upload-artifact@v4"
    with:
      path: coverage/
notes: ""

The string "20" stays quoted so YAML doesn't read it as the number 20, while the boolean true is bare. build-and-test, release/*, npm test -- --coverage and actions/upload-artifact@v4 are quoted because -, *, and @ are YAML indicator characters, and the key timeout-minutes is quoted for the same reason; npm ci and coverage/ need no quotes.

Learn more

How JSON to YAML conversion works

Objects map to YAML's key: value pairs, arrays to dash-prefixed list items, and nesting to two-space indentation. Strings are emitted unquoted when safe and automatically quoted when they'd otherwise change meaning — values containing colons, leading digits, or words like true and null that YAML would re-type. Numbers, booleans, and null pass through natively.

The result is valid YAML 1.2, which means any YAML parser — kubectl, Ansible, GitHub Actions, docker-compose — will load it to exactly the same data structure as your original JSON.

When to convert JSON to YAML

Most cloud-native configuration is YAML, but most APIs and generators speak JSON. This converter bridges that gap: turn a JSON Kubernetes manifest into the YAML kubectl expects, convert exported CI config to a pipeline file, or rewrite a JSON config example from documentation into the YAML your tool actually reads. Because every JSON document is representable in YAML, the conversion is always lossless. Run the output through the YAML validator before `kubectl apply`.

Help

Frequently asked questions

Everything you need to know about the JSON to YAML.

01Does the YAML output use anchors to shorten repeated data?

The serializer writes structurally, with no anchor or alias generation, so a value that appears twice in your JSON is written out in full both times rather than referenced once with & and *. That keeps the output simple to diff even though it isn't the smallest possible file. Add anchors by hand afterward for genuinely shared config blocks.

02Why are some strings quoted in the YAML output and others not?

Because bare scalars get re-typed: a YAML 1.2 parser turns 1e3 into a number and true into a boolean, and older 1.1 loaders also read yes/no as booleans and 08:30 as sexagesimal. The converter quotes the strings a 1.2 parser would misread — anything starting with a digit or with true/false/null, containing indicator characters such as : # , @ * or quotes, or with leading/trailing spaces — and leaves the rest clean. yes and no stay bare, which is correct for 1.2; quote them yourself if a PyYAML-style 1.1 loader will read the file.

03How do empty arrays, empty objects, multi-line strings, and unusual keys come out?

Empty containers use flow syntax — tags: [] and meta: {} — and null is written as null. A string containing a line break is emitted as one double-quoted scalar with \n escapes rather than a | block scalar, so it stays on a single line. Keys go through the same quoting rules as values: a key containing a hyphen, colon or hash, or starting with a digit, is wrapped in quotes ("content-type":, "1st":), while plain keys such as name: stay bare. Nested arrays render as - - item.

04Does converting back with YAML to JSON restore the original document?

For data, yes: values this converter quoted because they looked like numbers, booleans or YAML keywords come back as the exact original strings, and JSON key order is preserved. For formatting, no — YAML to JSON re-serializes at its own indentation, so custom spacing you applied to the YAML by hand does not follow through, and there were never any comments to lose in the first place.

Keep working

Related tools

Learn the format

Related guides

All guides →