Code Tools

YAML Formatter

All tools

Tidy trailing spaces and extra blank lines in YAML while leaving indentation exactly as it is.

How it works

Four simple steps

1

Paste the YAML

Add a full workflow, Compose or manifest file to the input.

2

Whitespace is cleaned

Trailing spaces go and runs of blank lines shrink to one.

3

Compare the result

Indentation, keys and comments are left exactly as they were.

4

Copy or download

Copy the tidy file or save it as formatted.yaml.

YAML Formatter

About YAML Formatter

A CI pipeline file has picked up trailing spaces and triple blank lines from several editors, and the lint step in your repo keeps complaining. You want a clean copy without any risk of changing the nesting.

This is a whitespace cleaner, and a deliberately conservative one. It removes trailing spaces and tabs from every line, reduces three or more consecutive line breaks to a single blank line, trims blank lines at the start and end of the file, and makes sure the output ends with exactly one newline. It does not re-indent nested maps, reorder keys, change quoting or touch comments, so the meaning of the document cannot change. The result updates as you type and downloads as formatted.yaml.

One edge case: if the very first line of your paste is indented, that indent is trimmed along with the surrounding blank lines, so paste complete documents rather than fragments copied from the middle of a file. For real problems such as tabs or a missing space after a colon, use the YAML linter. To confirm the file still parses, run it through the YAML Validator, or inspect the parsed data with YAML to JSON.

Cleanup happens with plain string operations in the page. No parser library is loaded and the file is not transmitted.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

No. Indentation is left exactly as you wrote it, because changing it could move a key under a different parent. Fix indentation errors in your editor, then use this tool for the final tidy.

No. Comment lines and inline comments are kept. Only trailing whitespace and surplus blank lines change.

Yes. Document separators (---) are ordinary lines to this tool, so multi-document files keep their structure. Blank lines between documents are reduced to one at most.

View more FAQs

Related tools

View all

HTML Formatter

Beautify and indent HTML markup.

Open

CSS Formatter

Format and pretty-print CSS.

Open

JS Formatter

Beautify JavaScript code.

Open

JSON Formatter

Beautify and validate JSON.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools