RevealTheme logo

YAML转JSON工具

在你的浏览器中将YAML转换为JSON。支持嵌套映射、列表、字符串、数字和布尔值。

如何使用本工具

  1. 1

    Paste or type your YAML into the input box, using spaces (not tabs) for indentation.

  2. 2

    Read the pretty-printed JSON that appears below the box as you type.

  3. 3

    If a red error message shows instead, check your indentation and remove unsupported syntax.

  4. 4

    Select and copy the JSON output to paste into your config, code, or API client.

什么是YAML转JSON工具?

YAML和JSON都是数据交换格式,能够表示相同的结构。YAML对人来说更易读(没有花括号或引号),而JSON则更具普遍的可解析性。当你需要将数据输入到只接受JSON的工具中时,在两者之间转换是配置文件(GitHub Actions、Docker Compose)的常见需求。

常见使用场景

  • Quickly turning a small docker-compose.yml or GitHub Actions snippet into JSON to inspect its structure.

  • Converting a hand-written config block into JSON to paste into a tool or API that only accepts JSON.

  • Checking how YAML scalars like true, 123, or ~ get typed once they become JSON values.

  • Sanity-checking indentation in a YAML fragment by seeing whether the nesting comes out as you expect.

  • Generating seed JSON fixtures for tests from a more readable YAML draft.

  • Teaching or learning the mapping between YAML structures and their JSON equivalents.

常见问题

支持YAML的高级功能吗?
锚点、别名、多行字符串和标签均不受支持。对于这些情况,请使用js-yaml等功能完整的YAML解析器。

相关工具