YAML Formatter & Validator
Normalize YAML indentation and catch common mistakes like duplicate keys and mixed tabs. Runs entirely in your browser.
Calculator
0 warnings found
Formatted YAML
—
Line Count
—
Character Count
—
Indentation Level
—
Key Count
—
Result
—
How YAML Formatter & Validator Works
What is YAML?
YAML ("YAML Ain't Markup Language") is a human-readable data format built around indentation and minimal punctuation, widely used for configuration files — Kubernetes manifests, Docker Compose files, GitHub Actions workflows, CI/CD pipelines, and application config all commonly use it. Unlike JSON, YAML has no braces or brackets required for basic structure — nesting is expressed purely through consistent indentation, which makes it easy to read but unforgiving of indentation mistakes.
YAML vs JSON
YAML is a superset of JSON — any valid JSON document is also valid YAML. The difference is readability versus explicitness: JSON's braces and brackets make structure unambiguous to a parser but verbose to a human; YAML's indentation-based structure reads more naturally but means whitespace is semantically significant, and a single misplaced space can silently change what a document means. This tool exists specifically because that class of mistake — inconsistent or ambiguous indentation — is so easy to introduce and so hard to spot by eye in a long file.
Why Formatting Matters
Because YAML's structure is entirely defined by indentation, an inconsistently indented document is both harder to read and more likely to be interpreted differently than intended. Two sibling keys indented by a different number of spaces might still parse, but a real YAML consumer determines nesting strictly by column position — so cleaning up formatting isn't just cosmetic, it removes an entire class of "why doesn't my config do what I expect" bugs before they happen.
Indentation Rules
- Spaces only — never tabs. The YAML specification disallows tabs for indentation entirely; a tab-indented line is a real parsing hazard, not just a style inconsistency.
- Indentation must be consistent within a block. Sibling keys under the same parent should use the exact same indentation; a dedent that doesn't land on an already-established column is ambiguous.
- List items may sit at the same indent as their parent key, or one level deeper —
both
items:\n- aanditems:\n - aare valid; this tool preserves whichever structure your document establishes rather than forcing one style.
Common Mistakes
- Mixing tabs and spaces. Even a single tab character in otherwise space-indented YAML is invalid per the specification, and many parsers reject it outright.
- A duplicate key at the same level. Most YAML parsers silently keep only the last occurrence of a repeated key — a genuinely easy mistake to introduce during a merge or copy- paste, and one that produces no error, just silently wrong data.
- A trailing colon with no value and no children.
name:with nothing indented underneath and nothing on the same line usually means a value was meant to be filled in and wasn't. - An indentation level that doesn't match any enclosing block. Dedenting to a column that doesn't correspond to any actual ancestor level makes it genuinely ambiguous which block a line belongs to.
Best Practices
- Pick one indent width and use it everywhere (2 spaces is the most common convention) — this tool normalizes to a consistent 2-space-per-level output regardless of the original width.
- Quote strings that could be misread as another type — an unquoted
yes,no,on,off, or a bare version number like1.20can be parsed as a boolean or number instead of the string you meant. - Keep related configuration in one document rather than splitting logically connected settings across multiple files, which makes indentation-related structure easier to verify at a glance.
YAML Security Notes
This tool only formats text — it never parses YAML into live objects, never executes anything found in a document, and never loads external files or references. That distinction matters for YAML specifically: some YAML libraries historically supported "unsafe" loading that could construct arbitrary objects (or in the worst case, execute code) from a maliciously crafted document. This tool sidesteps that entire class of risk by design — it's a lexical line-based formatter, not a YAML deserializer, so there is no object construction or code execution surface here at all. When you do use a real YAML library in your own code, always prefer its "safe load" function over any variant that permits arbitrary object construction.
Related Tools
Working with configuration and structured data often overlaps with other developer utility tasks: reformat a JSON payload with the JSON Formatter, beautify a SQL query with the SQL Formatter & Validator, generate a request snippet for a config-driven API with the OpenAPI Snippet Generator or the cURL Command Builder, validate a pattern used to extract values from a config file with the Regex Tester, or fingerprint a config file's contents with the Hash Generator.
Accuracy & Sources
Last reviewed: August 2026. Formula source: YAML Specification 1.2. All calculations run in your browser. No data is sent to any server.
Frequently Asked Questions
No — it's a lexical, line-based formatter, not a YAML deserializer. It never executes YAML, never constructs arbitrary objects, and never loads external files or references. It only reformats the text and checks for a small set of lexical issues visible in the text itself.
No — it formats generic YAML only, with no awareness of any application-specific schema. It doesn't know which keys a Kubernetes manifest or GitHub Actions workflow expects; it only normalizes indentation and catches structural issues in the YAML syntax itself.
Warnings (mixed tabs/spaces, ambiguous indentation, a duplicate key, a dangling colon) describe issues found in your original YAML, not the formatter's own doing. The tool still produces its best-effort formatted output alongside the warning, so you can see the document clearly enough to find and fix the actual problem.
The YAML specification disallows tabs for indentation entirely — it's not just a style preference. A tab-indented line is a real parsing hazard that many YAML libraries reject outright, which is why this tool flags any tab found in leading whitespace as a warning.
It's syntactically accepted by most parsers, but semantically almost always a mistake — most YAML libraries silently keep only the last occurrence of a repeated key at the same level, discarding the earlier one with no error message. This tool flags it so you can catch it before it causes silently wrong configuration.
No — it has no knowledge of what keys or values your specific application, Kubernetes cluster, or CI system expects. It only catches lexical and structural issues in the YAML syntax itself, like indentation problems or duplicate keys — whether the content is semantically correct for your use case can only be confirmed by the actual consuming system.