YAML formatter, validator and comment remover
Paste YAML to re-emit it with consistent indentation, quoting and wrapping, or to tidy the whitespace without touching a single comment. A separate action strips every # comment — correctly, leaving the hashes that live inside quoted strings, URLs and block scalars alone. Validation runs as you type and reports the exact line and column, plus a count of documents, keys, depth, comments, anchors and aliases, and a warning when tabs have crept into the indentation.
About the YAML formatter
How it works
- 1. Paste a YAML file — a single document or several separated by ---.
- 2. Validation runs as you type: the line and column of any syntax error, or a summary of the document.
- 3. Format reparses and re-emits with your indent, wrap, quoting and sorting options. Tidy fixes whitespace and tabs without touching comments.
- 4. Remove comments strips every # comment and leaves the rest of the file byte for byte as it was. Copy the result, or send it back to the editor to run another action.
Common use cases
- • Cleaning a hand-edited Kubernetes or Compose file before committing it
- • Stripping the commentary out of a config before pasting it into a ticket
- • Finding the line a "bad indentation" error is really talking about
- • Fixing an editor that inserted tabs into a YAML file
FAQ
Why does Format lose my comments?
Because Format parses the document and writes it out again, and the YAML parser does not keep comments. Tidy is the comment-preserving option: it only touches whitespace, tabs and blank lines.
Will Remove comments break a string containing a #?
No. A # only starts a comment at the start of a line or after a space, and never inside quotes or a block scalar, so a URL fragment, a "50% # done" string and a shell script in a | block all survive intact.
Does it handle multi-document files?
Yes. Documents separated by --- are validated and re-emitted individually, which is what Kubernetes manifests usually look like.
What happens to anchors and aliases?
They are kept by default. Tick "Expand anchors" to resolve them and write the values out in full, which is useful when you want to see what a merge key actually produced.