YAML Formatter
Format, validate, and clean up YAML in your browser. Catches common pitfalls like boolean coercion and tab indentation. No data leaves your device.
About this tool
YAML is a human-friendly data serialization format used heavily in DevOps
config (Kubernetes manifests, Docker Compose, CI pipelines, Ansible
playbooks). It is designed to be readable by people first and machines
second, which is both its strength and its most common source of bugs.
This formatter parses your input with js-yaml, the most
widely used JavaScript YAML library, and re-emits it with consistent
indentation.
Use Format to fix inconsistent indentation, normalize quoting, and reshape block/flow style where the parser prefers one over the other. Use Validate to check for well-formedness without changing the output. Errors include the line and column of the problem, and — for common issues like tab characters and unquoted colons — a short hint explaining the fix.
The most famous YAML gotcha is boolean coercion. In YAML 1.1, the
unquoted values yes, no, on, and
off parse as booleans. That means a country code of
NO, a config flag for on, or a Japanese "yes"
written as y silently becomes true or
false. YAML 1.2 fixed this — only true/
false are booleans — but most libraries (including js-yaml
in default mode) still honor the 1.1 behavior for compatibility. Turn on
Strict (JSON schema) to parse using the stricter 1.2
behavior that only accepts true and false.
Other common pitfalls this formatter helps with: unquoted version
strings (1.0 parses as a number and drops trailing zeros),
sexagesimal literals (12:34:56 can parse as a number in
YAML 1.1), and mixed indentation depths that parse but produce surprising
nesting. When in doubt, quote strings and prefer two-space indentation.
Frequently asked questions
Why does "yes" or "on" turn into true?
YAML 1.1 treats yes, no, on, off, y, n, true, false (and several capitalizations) as booleans. The Norwegian country code NO, a "yes" answer, and the switch state "on" all get silently coerced. Quote values that should stay as strings ("yes", "NO") or switch to strict/JSON schema mode, which only recognizes true/false.
Can I use tabs for indentation?
No. The YAML specification disallows tab characters for indentation. Only spaces are allowed. Most YAML parsers will reject a document that uses tabs. The tool flags this with a clear error.
Does formatting preserve my comments?
No. js-yaml parses YAML into a plain data structure, then re-emits it — comments are not part of the data model and are lost. If preserving comments matters, format manually or use a comment-aware parser like yamllint for validation only.
How do multi-line strings work?
YAML supports two block scalar styles: literal (|) preserves every newline, folded (>) collapses single newlines into spaces. The formatter picks whichever the js-yaml serializer chooses; the choice is based on content (newlines, indentation, special characters).
What is the difference between strict and default mode?
Strict mode uses the JSON schema, which only allows JSON-compatible types (null, boolean, number, string, array, object). Default mode uses the full YAML schema, which additionally recognizes dates, timestamps, binary data, and the notorious "yes/no → boolean" coercion. Strict mode is safer for configs that will round-trip through JSON-based systems.
Will this work on a very large YAML file?
Yes, up to browser memory limits. Files in the low megabytes parse in a second or two. Beyond that, consider command-line tools like yq. Everything runs in your browser — no upload, no transmission.