Skip to content

Convert JSON to YAML online

Convert JSON to readable YAML with correct quoting, block literals for multi-line text, optional key sorting and 2 or 4 space indentation.

  • Runs in your browser
  • Files are never uploaded
  • Free, no account
YAML output style
The serialiser runs locally — nothing is uploaded.

Sequences always use a two-space “- ” marker.

Uses | instead of escaping \\n inside quotes.

Safest for values that could be read as numbers or booleans.

Adds the document marker some tools expect.

JSON input

YAML output

How to convert JSON to YAML

  1. Paste the JSON into the left pane, or drop a .json file onto it.
  2. Choose an indent width. Two spaces is the community default and what Kubernetes, Docker Compose and GitHub Actions examples use.
  3. Optionally sort keys so two generated files can be diffed line by line.
  4. Copy or download the .yaml. Any parse error in the JSON is reported with its line and column before anything is emitted.

Why YAML instead of JSON?

YAML is a superset of JSON aimed at humans: no braces, no trailing-comma traps, comments allowed, and multi-line strings that stay readable. That is why configuration ecosystems standardised on it. The cost is that YAML’s scalar rules are subtle, and a converter that ignores them produces files that parse — just not into the values you meant.

The quoting rules this converter applies

A string is written bare only when it can be read back as exactly the same string. Anything that could be reinterpreted gets quoted:

JSON value YAML written Reason
"production" production Unambiguous plain scalar
"yes" 'yes' YAML 1.1 parsers would read it as true
"007" '007' Otherwise becomes the number 7
"2026-08-16" '2026-08-16' Otherwise resolves to a timestamp
"key: value" 'key: value' A bare colon-space would start a nested mapping
"# not a comment" '# not a comment' A leading hash starts a comment
"line1\nline2\n" | block literal Readable multi-line text without escapes
"" '' A bare empty value would parse as null

Block literals and chomping

Multi-line strings are emitted as block scalars, and the chomping indicator encodes what happens to the trailing newline. | keeps exactly one, |- strips it, and |+ keeps every trailing blank line. Picking the right one is what makes a round trip byte-for-byte accurate — run the result back through YAML to JSON and you get your original document.

Structure mapping

  • Objects become block mappings, one key: value per line.
  • Arrays become block sequences with a - marker, indented under their key.
  • Empty containers are written inline as {} and [], because an empty block has no representation.
  • null is written as null rather than left blank, so the intent is explicit.
  • Keys that contain a colon, start with an indicator character, or look numeric are quoted too.

Nothing is uploaded

Config files carry hostnames, bucket names and occasionally secrets. This converter is a few kilobytes of JavaScript that runs in your tab — no request is made, so there is nothing to intercept or retain. It works offline once the page has loaded.

Questions

Will strings that look like numbers stay strings?

Yes. Values such as "007", "1.10", "yes" and "2026-08-16" are quoted automatically, because an unquoted version would be read back as a number, boolean or date.

How are multi-line strings written?

As block literals using the | indicator, which keeps the line breaks readable instead of escaping them as \n inside quotes. You can switch that off if your parser prefers quoted scalars.

Is the output valid for Kubernetes, Docker Compose and GitHub Actions?

Yes — the serialiser emits plain YAML 1.2 with two-space indentation, which every mainstream parser accepts. Add the --- document marker if your pipeline expects one.

Are comments preserved?

JSON has no comments to preserve, so the YAML output has none. Converting the other way, YAML to JSON, does read and skip comments correctly.