Back to Tools

JSON to YAML Converter

Convert JSON to clean, readable YAML with indentation and hierarchy control

📝 Pretty YAML🔗 Nested Support
JSON Input

Write config files in YAML instead of JSON

YAML drops most of the braces, quotes and commas that make JSON tiring to hand-edit, which is why Kubernetes manifests, CI pipelines, Docker Compose files and many other configs use it. This converter takes valid JSON and re-writes it as YAML using the js-yaml library, loaded from a CDN when the page opens, so an internet connection is needed for the conversion to work.

Converting a document

  1. Paste JSON into the JSON Input box. Sample loads an app configuration with server, database, feature list and contacts; Paste pulls from the clipboard.
  2. Pick a YAML Indent of 2 or 4 spaces.
  3. Optionally tick Sort Keys to order keys alphabetically, and Compact Arrays to collapse nested structures onto single lines.
  4. Press Convert to YAML.

A status badge shows whether the input was valid JSON. Below it you see input and output sizes in bytes. Use Copy or the YAML button, which saves output.yaml.

What the two checkboxes really do

Sort Keys is handy when you want consistent diffs between versions of a config file, since the same content always produces the same order. Compact Arrays asks the library to switch to inline flow style once nesting reaches the third level, so top-level and second-level entries stay in block style, while deeper lists and objects are written like [a, b] or {x: 1}. Try it on the sample to see where the line falls.

Everyday situations

  • Converting an API response or package manifest into YAML for documentation.
  • Starting a Kubernetes or Compose file from a JSON snippet someone sent you.
  • Comparing two configs by normalizing them into sorted YAML.
  • Making a long JSON settings file more readable for review.

Notes and limits

Only JSON is accepted as input, and comments are not allowed in JSON, so remove them first. When the JSON is invalid, the result box displays the parser error and the badge says Invalid JSON. Key order is preserved unless you enable sorting. YAML output uses whichever quoting style the library judges necessary, so some strings that look like numbers or booleans will be quoted to remain strings. If the page cannot reach the CDN because of a network or content-blocker issue, the conversion will fail until the script loads.

Related Tools


Frequently Asked Questions

Do I need an internet connection to convert?
Yes, in practice. The conversion uses the js-yaml library, which the page loads from a public CDN. If that script is blocked or offline, the Convert button cannot produce YAML until the library loads. Refresh the page or disable the blocker.
What does the Compact Arrays option do?
It turns on flow style from the third nesting level down, so deeper lists and objects appear inline such as [a, b] or {x: 1}. The first two levels remain in normal indented block style.
Does Sort Keys change my data?
It only changes the order in which keys are written, alphabetically at every level. The values and structure are the same. Sorting is useful for stable version control diffs, but leave it off if the original order matters to a human reader.
Why are some values wrapped in quotes in the YAML?
The library quotes strings that would otherwise be read as another type, such as the text 123, true or null, or strings with special characters. That keeps the round trip accurate when the YAML is read back.
What happens with invalid JSON?
The status badge changes to Invalid JSON and the result area shows an error line with the parser's message. No YAML is produced, so fix the issue, commonly a trailing comma, single quotes or a missing bracket, and convert again.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.