Skip to main content
UFOZoo

JSON to YAML: Convert JSON to YAML for Docker & K8s

JSON to YAML converter online: convert JSON into YAML for Docker Compose, Kubernetes manifests, and API configuration files.

Updated 2026-08-26

Related Tools

Features

  • One-click JSON to YAML conversion with instant output as you type, no Convert button needed
  • Real-time validation with precise error location: invalid JSON highlights the exact line and column in red
  • Bidirectional support: paste YAML on the left and it converts back to JSON (see yaml-to-json for the reverse workflow)
  • Preserves data types: numbers stay numbers, booleans stay booleans, null becomes YAML null
  • 2-space indentation output that matches the conventions used in Docker Compose and Kubernetes manifests
  • Long strings and URLs are never wrapped or truncated: output uses the same line width as your input
  • Syntax highlighting on both panels: JSON keys/strings/numbers in the input, YAML keys/comments/anchors in the output
  • Drag-and-drop a .json or .yaml file onto the editor, or use the file picker to open one
  • Save the result as a .yml file or copy it to the clipboard with one click
  • Handles deeply nested structures: multi-level objects, arrays of objects, and mixed arrays without choking
  • Useful when migrating API responses to config files, writing Docker Compose from JSON service definitions, or converting OpenAPI JSON specs

How to Use

  1. 1Paste JSON into the left panel. The YAML conversion happens instantly as you type: there is no Convert button to press.
  2. 2Copy a JSON response from Postman, your API docs, or an HTTP inspector, then paste it here to get a ready-to-edit YAML config.
  3. 3Drag a .json file onto the editor, or click the folder icon to open one from your device.
  4. 4After conversion, click the copy icon to grab the YAML, then paste it into docker-compose.yml or a Kubernetes manifest.
  5. 5Click Save to download the output as converted.yml with the exact text you see on screen.
  6. 6Try the sample buttons (Docker Compose, API Response, Kubernetes Manifest) to see how nested JSON maps to YAML.
  7. 7Paste YAML on the left to reverse the direction: the tool detects the format automatically and outputs JSON.
  8. 8If the input is invalid, the error line number turns red in the left gutter; the message panel shows what went wrong and where.
  9. 9Verify the output before overwriting your original file: YAML written from JSON uses 2-space indentation and quotes strings that contain special characters.
  10. 10Use the status bar at the bottom to check input size and the detected format direction (JSON → YAML or YAML → JSON).

Frequently Asked Questions

How do I convert JSON to YAML?

Paste your JSON into the left panel and the YAML output appears instantly in the right panel. There is no convert button; the tool processes the input as you type. The output uses standard 2-space indentation and is ready to paste into Docker Compose, Kubernetes, or any config file.

What is the difference between JSON and YAML?

JSON is a strict data format used by APIs: it requires quotes around keys and strings, and supports no comments. YAML is a superset that allows comments (#), unquoted strings, anchors, and multi-line blocks, which makes it popular for configuration files. This tool converts between the two while preserving the underlying data structure.

Does the conversion preserve my data types?

Yes. Numbers stay numbers, true/false stays boolean, null becomes YAML null (the literal 'null' or empty value), and strings stay strings. One caveat: a string like "true" or "123" in JSON is already a string, and it stays quoted in YAML so it doesn't get reinterpreted.

Why are some strings wrapped in quotes in the YAML output?

js-yaml quotes strings that could be misread as another type, such as '123', 'true', 'null', or strings containing ':', '#', or leading special characters. Quoting guarantees that when the YAML is parsed again, the value is still a string. This is intentional and safe.

What happens to JSON null when converted to YAML?

JSON null becomes the YAML null value, which is usually written as 'null'. Depending on how you write it, YAML also accepts '~' or an empty value, but the converter outputs the literal 'null' for clarity. If you need empty strings instead, change the JSON to "" before converting.

Can I convert large JSON files?

Yes, typical API responses and config files (up to a few MB) convert instantly. Very large files (10 MB+) may slow down the browser because everything runs locally. For huge files, command-line tools like yq (yq e -P) or Python's PyYAML are faster.

Why does my JSON show as invalid?

Common causes: trailing commas (not allowed), single quotes instead of double quotes, unquoted keys, comments inside the JSON, and unescaped control characters. The validator highlights the exact line and column in red; check the error panel for the message and fix that position.

Does the YAML output support comments or anchors?

The generated YAML does not add comments, because JSON input carries no comments (JSON has no comment syntax). Anchors are also not generated; the output is fully self-contained. However, if you paste YAML containing anchors on the left, the reverse conversion expands them into plain JSON values.

Can I convert a Kubernetes manifest or Docker Compose JSON to YAML?

Yes. Paste the JSON form of the manifest (for example exported from kubectl with -o json) and you get an equivalent YAML manifest with 2-space indentation. Note that YAML formatting differences (for example how empty maps are written) do not change the meaning of the manifest.

Why does my converted YAML fail to parse in Docker Compose or Kubernetes?

The usual culprits are invisible: a tab character where the linter expects spaces (YAML forbids tabs for indentation), an unquoted value that looks like another type ("on", "yes", "null"), or a string with a special character like ':' or '#' that changes meaning. This tool quotes ambiguous strings and outputs 2-space indentation, so if parsing still fails, run the output through a YAML linter that shows the exact line, and make sure you did not edit the file with an editor that inserts tabs.

Does this tool work offline?

Yes. All logic is bundled into the page and runs locally; after the first load, you can disconnect from the internet and conversions keep working. The page itself may still require a network connection to load on repeat visits.

Can I convert JSON to YAML with Python or command-line tools?

Yes. In Python, json.load() plus yaml.safe_dump() from PyYAML does the same job. From the command line, yq (yq e -P) converts JSON to YAML and supports custom indentation, and jq can preprocess the JSON first. This page is faster for one-off conversions and inspection; scripts and batch jobs are where the CLI tools shine.

How is this different from the yaml-to-json tool?

Both tools support the same bidirectional conversion under the hood. This page is tailored for the JSON → YAML workflow (JSON-first examples, JSON-focused help), while yaml-to-json is tailored for the YAML → JSON direction. Use whichever matches your task.

Can I convert dates or timestamps to YAML?

Yes, but note the conversion keeps values as plain strings: a JSON string like "2025-07-01T08:30:00Z" stays a quoted string in YAML and is not reinterpreted as a timestamp. If you need YAML timestamps, write the YAML manually.

Why does my json to yaml converter online garble Chinese, Japanese, or emoji characters?

YAML is a UTF-8 format and this converter preserves Unicode as-is, so 中文, 日本語, and emoji come through unchanged. If you see mojibake (like é䏿), the problem is upstream: the original JSON file was opened or copied with the wrong encoding (for example GBK read as UTF-8). Re-save the source file as UTF-8 and convert again.

Can I change the indentation of the YAML output?

The output is fixed at 2 spaces per level, which matches the convention used by Docker Compose, Kubernetes, and most YAML linters. If your project needs 4 spaces or tabs, save the output and re-indent it with a formatter, or use yq (yq e -P) for batch conversion with custom indentation.

Does the converter support JSON Lines (JSONL)?

No. Paste one JSON document at a time. JSON Lines (JSONL/NDJSON) is a sequence of independent JSON objects separated by newlines, which this tool does not parse as a single document. Since each line is valid JSON on its own, you can convert each line separately or use a streaming tool like jq for JSONL files.

What happens to duplicate keys in my JSON?

JSON.parse keeps the last occurrence of a duplicate key; earlier values are silently overwritten, and the YAML output contains only one entry per key. JSON allows duplicate keys syntactically but they are almost always a mistake; remove them from the input if you want all data preserved.

Can I load JSON from a URL?

No. This tool does not fetch remote URLs. Copy the JSON content and paste it into the left panel, or open a local .json file.