YAML to JSON

Read a YAML config into JSON: nested maps, sequences, block scalars, inline collections and comments, with the ambiguous parts refused rather than guessed.

Indent
yaml
JSONjson
The result appears here
Maps, sequences, quoted strings, comments, block scalars and inline collections are read. Anchors, aliases, tags and multiple documents are refused rather than half-read, because a config that comes back subtly wrong is worse than one that comes back rejected.

Questions

Which YAML does it read?+

The subset config files are written in: nested maps and sequences, quoted and plain scalars, comments, block scalars with | and >, and inline [] and {} collections. That covers a GitHub workflow, a docker-compose file and a Kubernetes manifest.

Why are anchors refused?+

Because expanding them wrong is worse than saying no. Anchors, aliases, tags, directives and multi-document files are rejected with a message instead of being half-read.

Why did my key `on:` stay a string?+

Because it should. YAML 1.1 turns on, yes and no into booleans, which is how a GitHub workflow's on: becomes true: in half the parsers out there. Keys are read as text here; values still get the booleans.

Related tools

The tools are free. So is most of the library.

1935 blocks and 989 pieces for shadcn/ui and Tailwind, built on the same tokens these tools write. Install one with a command and the code is yours.

No signup for the tools. MIT for free blocks, commercial licence for Pro.

Markdown version