Skip to content

JSON to YAML Converter

Convert JSON documents to YAML format with syntax validation, clean formatting, and instant preview.

JSON to YAML Converter tool

Loading...

Example

Input: {"name":"app","ports":[80,443],"debug":false}

Result: name: app / ports: / - 80 / - 443 / debug: false (list items indented 2 spaces)

Object keys become key: value lines and each array item becomes an indented "- " list entry.

How JSON Values Appear in YAML

JSON valueYAML output
"hello"hello
"yes"'yes'
"true"'true'
"123"'123'
"2024-01-15"'2024-01-15'
"a: b"'a: b'
""''
123123
truetrue
nullnull
[][]
{}{}
"line1\nline2"|- then line1 and line2 indented below

Each value shown as the value of a key; output from this converter.

  1. Paste your JSON data into the input panel on the left side.
  2. The tool validates your JSON syntax and shows an error message if the input is invalid.
  3. View the converted YAML output in the YAML panel with 2-space indentation and proper structure.
  4. To convert the other way, edit or paste YAML into the YAML panel and the JSON panel updates.
  5. Click the copy button to copy the YAML for use in your Kubernetes manifest, Docker Compose file, or CI/CD pipeline.

Converting JSON to YAML for Config Files

This converter rewrites JSON as YAML, the indentation-based format used by Kubernetes, Docker Compose, GitHub Actions and Ansible. {"name":"app","ports":[80,443]} becomes name: app, followed by ports: with each number on its own - line.

Every JSON document is already valid YAML, but hand-written YAML is easier to read because it drops the braces, brackets and most quotes. The converter parses your JSON and writes YAML with 2-space indentation. Arrays become - lists, nested objects become indented blocks, and empty arrays and objects are written as [] and {}. Long lines are never wrapped, and keys keep their original order. Strings are quoted only when they have to be. A string that would change type if left bare, such as "yes", "true", "123" or "2024-01-15", is wrapped in single quotes so any YAML parser still reads it as text. The same goes for a string that contains a colon followed by a space. Multi-line strings become a | block. The table shows these cases.

The panels work in both directions, so you can edit the YAML side and watch the JSON update. If your JSON is invalid, the parser's error appears and the YAML panel keeps its last good result. To tidy YAML you already have, use the YAML Formatter, and for Rust or Python config files, the JSON to TOML Converter.

Sources

Frequently Asked Questions

Without quotes, YAML would read them as another type. A bare 123 is a number, true is a boolean and, in older YAML parsers, yes and no are booleans too. When your JSON has these as strings, the converter adds single quotes so the value stays a string for every parser. Ordinary words are left unquoted.
JSON has no comments, so the output starts without any. You can add lines starting with # by hand once you copy the YAML into your file. Note that if you convert that YAML back to JSON, the comments are dropped, because JSON has nowhere to put them.
It starts a block of literal text. The lines indented below it are the string, with line breaks kept exactly. The minus sign means the final line break is removed, which matches a JSON string that does not end with a newline. This is how the converter writes any string that contains line breaks.
Yes. Keys appear in the YAML in the same order as in the JSON, and array items stay in order. Nothing is sorted. That keeps the result easy to compare with the original and with other config files.

Related Tools

YAML to JSON Converter

Parse YAML documents and convert to formatted JSON with error reporting and syntax validation.

Developer Tools

JSON Formatter and Validator

Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.

Developer Tools

JSON to XML Converter

Convert JSON data to well-formed XML documents with customizable root element and formatting options.

Developer Tools

JSON to TOML Converter

Convert JSON objects to TOML format with type preservation and clean table structure output.

Developer Tools

YAML Formatter and Viewer

Format, validate, and visualize YAML documents with tree view and customizable indentation.

Developer Tools

JSON to CSV Converter

Convert a JSON array of objects to CSV with automatic column headers, and convert CSV back to JSON in the same tool.

Developer Tools