JSON 转 YAML

JSON 转 YAML,适合配置与 DevOps

JSON 输入

Loading editor...

YAML 输出

Loading editor...

Move JSON config into YAML for DevOps tooling

Most cloud-native tools — Kubernetes, Docker Compose, GitHub Actions, Helm, Ansible — speak YAML, not JSON. Converting JSON to YAML gives you a comment-friendly, indentation-based file that's easier for humans to maintain while preserving the exact same data structure.

Use the converter when you need to

Generate a Kubernetes manifest

Build the structure as JSON in your code, then convert to YAML for a manifest you can apply with kubectl.

Author a CI workflow file

Many CI systems require YAML — convert JSON config snippets so they paste cleanly into .github/workflows or .gitlab-ci.yml.

Make a config file human-friendly

YAML supports comments and uses indentation instead of braces, which makes long configs easier to read and review.

How to convert JSON to YAML quickly

  1. 1

    Paste the JSON document into the editor.

  2. 2

    Click Convert to produce equivalent YAML with proper indentation.

  3. 3

    Copy the YAML for use in a manifest, workflow file, or config repo.

Common JSON-to-YAML workflows

Deploy a service with a generated manifest

Build the config programmatically as JSON and emit YAML at the end of the pipeline.

Document API examples in YAML

Some docs systems prefer YAML for examples — convert request and response samples once and reuse.

Migrate config between formats

Move from a JSON-based config repo to a YAML-first one without retyping every value.

相关工具

常见问题

YAML 是 Docker、Kubernetes、GitHub Actions 以及大多数 CI/CD 流水线的配置文件标准格式。把 JSON 转成 YAML 后,更方便直接用于 DevOps 场景。

JSON 用大括号/中括号,语法更严格;YAML 主要靠缩进(不需要大括号),支持注释,通常更易读。两者都能表达同样的数据结构:对象和数组。

支持。所有合法的 JSON 值(string、number、boolean、null、object、array)在 YAML 里都有对应表示。YAML 还支持日期等额外类型,但转换器会保持在 JSON 兼容的类型范围内。

先把 JSON 配置转换成 YAML,然后直接复制到你的 docker-compose.yml 中。注意保留缩进——YAML 对空白非常敏感。