LocalExcelTool
Get started

YAML Formatter

Tidy YAML indentation and whitespace for clean config files.

Runs in your browserNo account neededFree

What is YAML Formatter

YAML formatting normalizes indentation to 2 spaces and trims trailing whitespace, improving readability of configuration files.

🔒 Everything runs in your browser. Nothing is uploaded.

What this tool actually does with your file

Where it runs
In your browser, on this page
Upload
None — the file never leaves your device
Offline
Works with the network disconnected

Tabs are illegal, so they are converted

YAML forbids tab characters for indentation, and half the files that fail to parse fail for that reason. This formatter replaces leading tabs with two spaces and normalises trailing whitespace, which fixes the syntax without changing structure.

It re-indents by tracking the existing indentation levels rather than by parsing the document into a tree. That is safer for comments and anchors, which a full parse-and-reserialise would drop, but it means a file with genuinely inconsistent indentation will be made consistently wrong rather than corrected.

Values that change type without changing text

YAML 1.1 treats yes, no, on and off as booleans — the 'Norway problem', where the country code NO becomes false. Version numbers lose their second dot (1.10 becomes 1.1, a float), and unquoted 22:30 can be read as a sexagesimal integer by some parsers.

A formatter that only touches whitespace does not change these, but a round trip through a parser does. If a field must stay a string, quote it in the source; formatting will not protect you from a consumer that applies its own type resolution.

Multi-document files and block scalars

Documents separated by --- and terminated by ... are supported as separate blocks, and each is indented independently. Block scalars (| and >) are the fragile part: their content is defined by indentation relative to the parent key, so re-indenting the parent changes the string.

Check any indented multi-line value after formatting — a shell script or SQL embedded as a block scalar is the usual casualty. If the value matters, compare its content after parsing rather than eyeballing the indentation.

How to use it

  1. 1.Paste your YAML
  2. 2.Click Format
  3. 3.Copy the result

How YAML Formatter works under the hood

Formatters parse your input into a structure, then serialise it back with consistent indentation. That is why a formatter can also reveal a syntax error: if it cannot parse, it cannot print.

  1. 1

    Parse into a tree

    JSON goes through JSON.parse; YAML, XML, CSS and SQL use their own parsers. The parse either succeeds with a structure or fails at a line and column.

  2. 2

    Serialise with a fixed style

    Indentation width, key order and quoting are applied deterministically, so formatting the same input twice gives identical bytes.

  3. 3

    Show the error position

    When parsing fails, the message includes the position so the fix is obvious instead of guessed.

  4. Processing pipeline

Formatting is not validation

A formatter proves the document is syntactically parseable. It does not prove it is valid against a schema, and it does not check business rules. JSON with a duplicated key parses fine and silently keeps the last value.

What gets normalised

Comments are preserved in CSS and SQL but not in JSON, which has no comment syntax. YAML anchors may be expanded, and quote style may change. Keep the original when exact byte layout matters, such as signed payloads.

Verify it yourself

Formatting is deterministic and local — run it twice and compare.

  1. 1.Open DevTools on this page and switch to the Network tab
  2. 2.Keep the filter on Fetch/XHR and run the tool
  3. 3.Confirm no request carries your file — you should see only page assets and fonts

Frequently asked questions

What is YAML formatting?

It tidies indentation and whitespace to make YAML readable.

Do values change?

No. Only cosmetic whitespace is normalized; the structure stays the same.

What this kind of conversion cannot keep

Formatters parse the input into a tree and print it back with consistent indentation. If the input is invalid, you get the parser's error position instead of a silently mangled file — malformed JSON stays malformed rather than being «repaired» into something that is no longer yours.

More in Format