站点介绍

Last Tuesday a backend handed me a 41,000-character response on a single line. The missing comma was in there somewhere, and Counting Colons In Your Head was not going to find it. A formatter that reports the row and column turns a ten-minute hunt into a ten-second fix — and once the JSON side is trustworthy, the YAML side of your config files deserves the same treatment.
Pretty-print, minify, escape, and unescape JSON in one click, with syntax errors resolved to a row and column.
Two-way JSON ⇄ YAML conversion: 2 or 4 space indent, optional key sorting, auto-detected direction.
The YAML parser is written from scratch and ships inside the page — no third-party library, no network call.
Unsupported YAML (anchors, multi-document, tags) fails loudly with a line number instead of silently mangling data.
The four buttons map to four real moments in a developer's day. "Format" unfolds a collapsed response so the nesting is visible. "Minify" produces the one-line payload you paste into a config value or a test fixture. "Escape \n" wraps the whole thing as a string literal — every double quote backslashed, every newline written out — ready to drop into source code. "Unescape" reverses the strings you fish out of logs, where everything arrives doubly quoted and doubly escaped.
Errors come from the browser's native JSON.parse and are converted to a line and column of the text currently in the box. Fix the spot, click again, done.
Converting JSON into YAML is the boring half. The interesting half is taking a Kubernetes manifest or a GitHub Actions workflow and checking it against what the API actually returns — which means the YAML parser has to be strict. This one handles mappings, sequences, indentation nesting, flow style ([a, b], {k: v}, including multi-line flow, so pretty-printed JSON is itself valid input), quoted strings with escapes, numbers in every common notation, booleans, null in its three costumes (null, ~, empty), comments, and block scalars | and > with chomping indicators.
Dates stay strings on purpose — a timestamp silently becoming a number is how timezone bugs are born. YAML 1.1 booleans like yes and no are treated as strings, following the 1.2 core schema, so the two standards never fight over your data.
Anchors and aliases, multi-document streams separated by ---, explicit tags, complex keys. The parser could guess at these; guessing is how keys quietly vanish from converted configs. Instead every unsupported construct fails with the line number where it appears, in plain language. Tab indentation is rejected the same way — YAML itself forbids it, and quiet space-to-tab normalization would just move the problem.
Convert JSON to YAML, click "Move output to input", convert back, and compare. Structure and values survive; key order follows your sorting choice. The parser and serializer were validated against more than a hundred fixed cases — nested maps, arrays of maps, empty containers, special-character keys, multiline strings in every chomping mode — before this page shipped.
No. Pretty-printing, minifying, escaping, and YAML conversion all happen in your own browser. The page has no upload endpoint and works offline; what you paste never leaves your machine. Only interface options such as indent and key sorting are stored on this device.
Mappings, sequences, indentation nesting, flow style, quoted strings, numbers, booleans, null, comments, and block scalars. Anchors & and *, multi-document ---, tags !!, and complex keys ? are not supported — they fail loudly with the line number instead of silently mangling your data.
JSON errors come from the browser's native JSON.parse and are converted to a line and column; YAML errors are reported by the parser built into this page. Both refer to the current text in the input box — count over to the spot, fix it, and run the operation again.
Click "Move output to input" to shift the YAML result into the left box; the direction auto-detects YAML to JSON, and one more click converts back. The round trip preserves structure and values; key order follows your key-sorting option.
中文版:https://www.9314.cn/tools/json-format/
评论列表 (0条)