YAML Formatter & Validator
Pretty-print, minify, validate, and convert YAML — client-side.
output
result
About YAML formatting
YAML is everywhere in config: CI pipelines, Kubernetes manifests, docker-compose, and application settings. But hand-written YAML drifts — mixed indentation, inconsistent quoting, and trailing spaces. This formatter parses your document withjs-yaml (a full YAML 1.2 implementation) and re-emits it in a canonical 2-space block style, so it reads cleanly and behaves predictably. Everything runs in your browser.
How to use it
Paste or type your document — it parses as you edit, with syntax errors reported by line and column in the status bar. Then choose an output: Pretty re-emits canonical block-style YAML, Minify produces the single-line flow-style equivalent, and→ JSON converts to JSON for use with tools that don't speak YAML. Copy or Download grabs the result.
Pretty, minify, and JSON
Pretty re-emits block-style YAML with 2-space indentation. Minifyproduces a single-line flow-style YAML document — handy when you need the smallest possible representation. → JSON converts the parsed YAML to JSON, the exact complement of the JSON to YAMLconverter. Because parsing and dumping both go through a real YAML engine, anchors and aliases are resolved before output, so the result is self-contained: what you copy is exactly what a reader gets, with no hidden references.
Common YAML errors — and their fixes
Most invalid YAML comes from a handful of recurring mistakes. The parser here reports the same messages js-yaml throws in Node, so fixing the document here fixes it in your pipeline:
- Bad indentation of a mapping entry
- Nested keys under one parent must share identical indentation. Two spaces is conventional; four works if consistent. Re-formatting the document normalizes every level.
- Found a tab character that violates indentation
- YAML forbids tabs in indentation entirely — spaces only. Editors that insert tabs silently break pipelines; re-pasting through this formatter replaces them.
- Could not find expected ':'
- A key line is missing its colon, or an unquoted value contains a colon-space sequence. Quote the value:
url: "http://example.com". - Values that change type on their own
- Bare words like
no,on, ornullcan parse as booleans or null rather than strings, and unquoted version numbers like1.20become numbers (1.2). Quote anything whose literal spelling matters. - Duplicate keys
- YAML parsers let later keys silently override earlier ones instead of erroring. If a config behaves mysteriously, re-format and scan for repeated keys at the same level.
YAML vs JSON — when to use which
They encode the same data model, so the choice is about who edits it. YAML wins for hand-edited files: comments, no quote noise around every key, multi-line strings that stay readable. JSON wins for anything machines exchange: it has one legal syntax (no indentation ambiguity), parses faster everywhere, and never surprises you with type coercion. A practical split used by many teams: keep configuration in YAML where humans maintain it, and convert to JSON at the edges with this tool's → JSON button when feeding APIs, validators, or scripts. The round trip through a real parser also catches the indentation mistakes that YAML tolerates visually but punishes semantically.
Why canonical output matters
Re-formatting through one deterministic style does more than look tidy. Git diffs shrink to the lines that actually changed instead of every line a colleague's editor re-indented. Code review stops debating formatting and starts reviewing substance. And copy-pasting a stanza between files can't silently change its meaning, because indentation depth — the one thing that defines structure in YAML — is now uniform everywhere. Teams that adopt a single formatter tend to stop having YAML syntax debates entirely; the tool settles them mechanically.
Edge cases
Multi-document streams (a file with several ---separated documents) are handled as the first document. Complex keys, custom tags, and extremely long documents are all supported by the underlying parser, and syntax errors report the offending line and column in the status bar.
Related tools
Generate YAML from a JSON document with the JSON to YAMLconverter, spot what changed between two pipeline files with the JSON difftool after converting both, or validate the JSON equivalent against a schema with the JSON Schema validator.
FAQ
Is full YAML supported?
Yes. The tool uses js-yaml (YAML 1.2), so anchors, aliases, tags, block scalars, and flow collections parse correctly.
Is my YAML sent to a server?
No. Parsing and formatting run entirely in your browser — the document never leaves this tab.