YAML Formatter

Format and pretty-print YAML online, or convert YAML to JSON. Re-indents nested mappings and validates structure. 100% client-side, no upload.

Input YAML
Output

How it works

About YAML

YAML is the dominant human-readable data format for Kubernetes manifests, Docker Compose, GitHub Actions, Terraform, Ansible, and most CI and CD systems. Its whitespace-sensitive syntax is both its greatest strength and its most frequent source of mistakes. This tool is a pretty-printer for the block-mapping subset of that format: use it to normalise indentation, and use a real YAML parser whenever you need validation, sequences, anchors, or multi-document streams.

A structural subset, not a full YAML parser

This is a hand-written line scanner built on an indentation stack, not a YAML 1.2 implementation, and knowing that explains every limitation below. It reads block mappings — `key: value` lines nested by leading-space count — and re-emits them with consistent indentation. Plain block sequences are not modelled at all: under a mapping key, a `- item` list is dropped and the key ends up as an empty object, so a list survives only when written inline in flow style, and even then it stays a string.

Scalars are recognised by a small pattern table rather than by schema resolution. Integers and decimals are parsed, `true`/`false`/`null`/`~` are honoured with their capitalised forms, and quoted scalars are unwrapped — but the colon split happens before quote handling, so a quoted value containing a colon is truncated at the first one. Sexagesimal and octal forms such as `0o14` and `1:30` are left as strings.

Anchors, aliases and multi-document streams

Anchors and aliases are not resolved. Because `&anchor` reads as an ordinary scalar and `*alias` as another, an anchor line becomes a string value and the indented block beneath it is reattached at the top level — the structure is genuinely lost, not merely reformatted. The merge key `<<` is treated as a literal key name. Any input relying on anchors to share configuration across trees will not survive.

Multi-document streams fare worse. A `---` or `...` delimiter resets the result object and the indentation stack rather than starting a new document, so only the final document in the stream is retained: two Kubernetes manifests separated by `---` format down to the second one alone. Comments are dropped rather than preserved — full-line comments are skipped, and a trailing comment on a value line becomes part of the string.

Output shape and error reporting

Strings containing a colon, a hash, or a newline are emitted as JSON double-quoted scalars, which is valid YAML but looks foreign next to hand-written config. Selecting the JSON output mode runs `JSON.stringify` over the same parsed structure, and that is the more reliable path for piping into anything that consumes JSON. Numbers are re-emitted in their normalised form, so `007` becomes `7`.

There is no error reporting. The scanner does not throw on malformed input, and the `Validate only` button performs the same lenient parse before reporting success unconditionally — a syntax error surfaces as silently wrong output rather than as a diagnostic. Treat this as a cosmetic normaliser for block-style mappings, and reach for a real YAML parser whenever the document contains sequences, anchors, or multiple documents.

Frequently Asked Questions

How do I format YAML?
Paste your YAML into the input and click Format. The tool re-scans your block mappings and re-emits them with consistent indentation. It is a cosmetic normaliser, not a validator: it does not detect syntax errors, so compare the output against your input rather than trusting a success message.
Can I convert YAML to JSON at the same time?
Yes. Set the Output dropdown to JSON and the parsed structure is serialised with JSON.stringify. Both operations run locally with no data upload.
Why does my list disappear?
Block sequences written as `- item` under a key are not modelled by the scanner; the key comes back as an empty object. Anchors, aliases and multi-document streams are not resolved either, and a quoted value containing a colon is truncated at the first colon. For documents using any of those features, use a real YAML parser such as PyYAML or js-yaml.
Is my data sent to a server?
No. Every tool on jsonversal runs entirely in your browser using the Web Crypto API, File API, and Clipboard API. Nothing is ever uploaded — not even the JSON you paste in.
Do I need an account or API key?
No signup, no email, no API key. All tools are free to use with no signup required.
Can I use these tools offline?
Yes. Once the page loads, all tools work offline. There are no external API calls or CDN dependencies at runtime.
🔒
Your data never leaves your device

All processing happens in your browser. No uploads, no tracking, no servers. Your API keys, configs, and private payloads stay private — 100% client-side.

esc
↑↓ navigate ↵ open esc close