YAML / JSON
Converter

Two-way YAML ↔ JSON conversion in your browser — nested structures, multiline blocks, and inline line-number errors.

Parsed locally in your browser (js-yaml, MIT) — nothing leaves your device.

輸入

YAML

YAML → JSON

輸出

JSON

About This Tool

JSON is a subset of YAML — meaning every valid JSON file is also valid YAML. This tool uses the bundled js-yaml library (MIT) to parse YAML locally in your browser, then serializes output via JSON.stringify or yaml.dump. No data leaves your device.

The parser uses js-yaml's load() (safe mode) and dump(), handling nested maps and sequences, quoted strings, multiline literal (|) and folded (>) blocks, null, boolean, numbers, and basic anchors (&name) and aliases (*name). Parse failures show a line/column hint instead of a blank panel.

Out of scope: complex YAML 1.1 merge-key resolution, JSON Schema or YAML Schema validation, large-file streaming (keep under ~500 KB), file upload, and other formats like TOML or XML.

Quick guide

Use cases, answers, and nearby tools

Compact below-tool notes that help first-run users and repeated visitors move faster without changing the main interface.

Chinese search: YAML 轉 JSON、JSON 轉 YAML、YAML JSON 轉換、YAML 轉換器、線上 YAML 轉 JSON

How to use

Run a clean first pass

  1. Paste YAML or JSON into the left input panel.
  2. Use the ⇄ swap control to pick the direction (YAML → JSON or JSON → YAML).
  3. Click Convert — parse errors show the failing line below the input instead of a blank panel.

Examples

Real jobs this page helps with

  • docker-compose YAML to JSONConvert a YAML config block to JSON for a settings API call — paste and copy in seconds.
  • Read a deep JSON response as YAMLSwitch a deeply nested JSON payload to block-style YAML to read the structure at a glance.
  • Find the broken line in malformed YAMLPaste improperly indented YAML, read the line-number hint, fix the indentation, and re-convert successfully.

FAQ

What people usually want to know

Does my data leave the browser when converting?

No. All parsing and conversion happen locally using the bundled js-yaml (MIT) library and the native JSON parser. Nothing is sent to any server.

Does it handle multiline blocks and nested structures?

Yes. It handles nested maps, sequences, quoted strings, multiline literal (|) and folded (>) blocks, null, boolean, and number scalars.

What happens when the input is malformed?

The output panel clears and an inline message appears below the input with the parser's line/column (when available) plus a plain-language hint — never a silent blank result.

Are YAML anchors and aliases supported?

Basic anchors (&) and aliases (*) are expanded, and an Anchor Resolution Trail panel lists each anchor and where it was referenced. Complex YAML 1.1 merge-key resolution is out of scope.