Skip to content

JSON to YAML Converter — Convert JSON to YAML Config Format Online

Free

Convert JSON to YAML online instantly. Clean, human-readable output. Free, browser-based, no upload, no account required.

json to yaml onlineconvert json to yaml freejson yaml converter
All Developer Tools

Settings guide

Indent size:

  • ·2 spaces — Default for most YAML tools and Kubernetes manifests.
  • ·4 spaces — Used by some Python and Ansible conventions.

Quoting style:

  • ·Minimal quoting — Strings are unquoted unless they contain characters that would be ambiguous (:, #, YAML special sequences). Produces the cleanest output.
  • ·Always quote strings — All string values are double-quoted. Safer for programmatic consumption where ambiguity must be avoided.

Flow vs block style:

  • ·Block style (default) — Each key-value pair on its own line. Human-readable.
  • ·Inline/flow style for short arrays — Short arrays are written as [a, b, c] instead of multi-line block sequences. Reduces vertical space for compact configs.

Format comparison

When to keep JSON vs convert to YAML: Keep JSON for API payloads, database storage, and machine-to-machine communication. Convert to YAML when the output will be a config file that humans maintain over time — YAML's support for comments and cleaner syntax reduces errors during long-term editing.

JSON to YAML vs writing YAML by hand: For complex JSON structures with deep nesting, converting is faster and eliminates indentation errors. For simple configs, writing YAML directly is fine. Always validate the resulting YAML with your target tool after conversion.

How it works

1

Parse JSON

The JSON input is parsed and validated. If any syntax error exists, it is reported before conversion begins.

2

Map types to YAML

JSON types map directly: objects → YAML mappings, arrays → YAML sequences, strings → unquoted or quoted scalars, numbers → numeric scalars, booleans → true/false, null → null or ~.

3

Serialise in block style

The structure is written as YAML with consistent indentation. Object keys are written unquoted (unless required). Nested objects and arrays use block style for readability.

4

Review and use

The YAML output is ready to paste into a config file. Add your comments (# ...) in the YAML editor to document the values — something JSON cannot do.

About this format

JSON returned by an API or generated by a tool is often the starting point for creating a YAML configuration file. YAML's cleaner syntax — no brackets, no quotes for simple strings, support for comments — makes it far easier for humans to maintain as a long-lived config.

Paste your JSON object and the equivalent YAML is produced in block style: clean indentation, unquoted strings where possible, and proper handling of all JSON types. The output is valid YAML that can be used directly in Kubernetes, Docker Compose, Helm charts, GitHub Actions, or any other YAML-consuming tool.

Frequently asked questions

Is the converted YAML valid for Kubernetes and Docker Compose?+
Yes, for standard JSON inputs. Kubernetes and Docker Compose use YAML 1.1/1.2 with standard types. JSON converts cleanly to YAML that both tools accept. After converting, validate by running kubectl apply --dry-run=client or docker compose config.
Can I add comments to the YAML output?+
The converter does not add comments — it has no way to know what comments are meaningful for your use case. After conversion, open the YAML in an editor and add # comments above keys to explain their purpose. This is one of the main reasons to use YAML over JSON for config files.
How are JSON null values represented in YAML?+
JSON null becomes YAML null, which can also be written as ~ or left as an empty value. The converter outputs null as the explicit word null for clarity. Most YAML parsers treat all three representations identically.
What happens to JSON keys that contain special characters?+
Keys containing YAML special characters (: # [ ] { } , & * ? | - < > = ! % @ `) are quoted in the output. For example, a JSON key "my:key" becomes "my:key": in the YAML (with quotes preserved).
Can I convert a JSON array (not an object) to YAML?+
Yes. A JSON array converts to a YAML sequence. Each element is represented with a - prefix. [{"name": "Alice"}, {"name": "Bob"}] becomes two YAML block sequence items, each with a name key.

Related tools and guides