YAML Formatter and Validator - Fix Indentation, Find the Error

Tools /
/ Formatters / YAML Formatter

YAML formatter and validator

What this tool does

YAML has no braces: the indentation is the structure. That makes it pleasant to read and easy to break — one stray space and a key lands under the wrong parent. This tool reindents a document to a consistent width, tells you where it is broken, and shows you how it is actually being read.

How to use it

  1. 1 Paste your YAML into the box and pick an indent width — two spaces is the common choice.
  2. 2 Press Format to reindent, or Validate to check it without changing a character.
  3. 3 Not sure a value is being read the way you meant? Press To JSON and look at it.

Tabs are not indentation

The YAML spec forbids tab characters in indentation, and most parsers refuse the file outright. The error they print is rarely helpful, because the line they blame is often the one after the real problem. This tool names the line with the tab on it.

Your comments survive

Many formatters parse a document into a tree and print it again. That is tidy, and it deletes every comment you wrote — which is unusable for a docker-compose or a CI pipeline. This one only rewrites the leading whitespace, so comments, key order and quoting style stay exactly as you left them.

Why NO became false

In YAML 1.1, the bare words yes, no, on and off were booleans. A country list with the code NO for Norway therefore loaded as false — a bug famous enough to have a name. YAML 1.2 dropped that rule, and this tool follows 1.2: only true, false and null are keywords. If you want a boolean, write true or false; if you want the text, you already have it.

Anchors, aliases and block scalars

An anchor (&name) marks a node so an alias (*name) can reuse it later — handy for repeated service definitions. Block scalars (| and >) carry multi-line text: the pipe keeps your line breaks, the angle bracket folds them into spaces. All three are understood here, and the indentation inside a block scalar is treated as data, not as formatting.

YAML formatting - frequently asked questions

No. Format only rewrites the whitespace at the start of each line. Comments, key order, quoting and the text of every value stay byte for byte as you wrote them. If the document does not parse, it refuses to format it at all rather than guess.
New
Markdown Editor Write Markdown and see the rendered result side by side. Headings, lists, tables, code blocks and links are supported; copy the HTML or download .md and .html files. Runs in your browser.
Popular Today
Markdown Editor Write Markdown and see the rendered result side by side. Headings, lists, tables, code blocks and links are supported; copy the HTML or download .md and .html files. Runs in your browser.

Related Dev Tools

JSON Formatter Format, minify and validate JSON in your browser. Broken input is pinpointed by line and column, and a collapsible tree shows the structure.
HTML Formatter Indent messy HTML so you can read it, or strip it down so it ships smaller. Works on fragments too, and never rewrites your markup into something else.
CSS Minifier Compress CSS by stripping comments and whitespace, or expand it back with clean indentation. Keeps calc() spacing, strings and license comments intact.
XML Formatter Indent messy XML so you can read it, or strip it down so it ships smaller. Handles RSS, CDATA and namespaces, and never rewrites your document.
SQL Formatter Break a long query onto readable lines, or squeeze it back onto one. Keeps your keyword casing, your quoted names and your strings exactly as written.

Other Tools You May Like

Word to PDF Convert Word to PDF for free: upload a DOC, DOCX, ODT or RTF file and download a properly formatted PDF in seconds - no registration or watermark.
PDF to Word Convert PDF to Word for free: upload a PDF and download an editable DOCX in seconds - no registration, no watermark and nothing to install.
Word Counter Free word counter: paste any text to count words, characters, sentences and paragraphs, and see the estimated reading time - nothing leaves your browser.
Character Counter Free character counter: count characters with and without spaces, plus words and lines, and check SEO limits for titles and meta descriptions.
Keyword Density Checker Free keyword density checker: paste text or a URL to see how often each word and phrase appears, with percentages for one, two and three-word terms.