YAML Formatter
Paste messy YAML and get a clean, consistently indented version back instantly.
Example
Messy input with inconsistent indentation and spacing:
name: My App
tags: [a, b,c]
server:
host: localhost
port: 80
Clean, re-dumped output:
name: My App
tags:
- a
- b
- c
server:
host: localhost
port: 80
How it works
It parses your YAML with js-yaml, then re-serializes the resulting data with tidy 2-space indentation and unwrapped lines. Everything runs locally in your browser.
Good to know
YAML Formatter takes the YAML you paste in, parses it into a data structure with the js-yaml library, and writes it back out with uniform 2-space indentation, normalized spacing, and block-style sequences. It is built for developers and DevOps engineers who deal with Kubernetes manifests, CI pipelines, Docker Compose files, Ansible playbooks, and app config that has drifted into inconsistent indentation after manual edits or copy-paste.
Reach for it when a file mixes tabs and spaces, uses random amounts of leading whitespace, or crams collections into flow style like tags: [a, b, c] and you want a single canonical layout before committing. Because the tool round-trips through a real parser, formatting doubles as a quick syntax check: if your YAML is broken, you get an "Invalid YAML" message with the parser's first error line instead of cleaned output.
To read the result, compare the structure rather than the characters. Inline arrays become dashed block lists, every nesting level is exactly two spaces deeper than its parent, and trailing blank lines are stripped. The status line reports how many documents it processed, which confirms that --- separators in a multi-document stream were each handled and rejoined.
One caveat worth planning around: this is a lossy reformat, not a text-preserving beautifier. Comments, anchor and alias references that could be inlined, quoting style, and key order beyond what the data dictates are not guaranteed to survive, so keep an original copy if your file relies on comments or specific YAML 1.1 quirks. Everything runs locally in your browser, so even large or sensitive config files never leave your device.
Frequently asked questions
Does formatting preserve my comments?
No. The tool parses YAML into data and re-serializes it, so comments and original formatting choices (like inline vs block style) are not retained. Only the data structure and values are preserved.
Can it handle multi-document YAML files?
Yes. Documents separated by --- are each parsed and re-dumped, then rejoined with --- separators so multi-document streams stay intact.
Is my data uploaded anywhere?
No — this tool runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.
People also ask
What indentation does the YAML Formatter use?
It always outputs two-space indentation for each nesting level, with no tabs and no configurable width. Flow-style inline arrays are expanded into dashed block sequences at the same two-space rhythm.
Will the formatter change my key order?
No. It keeps keys in their original order because sorting is disabled, so the output preserves the sequence you wrote rather than alphabetizing mappings.
Does the YAML Formatter validate my file?
Indirectly, yes. It must successfully parse the input before it can reformat, so invalid YAML produces an error message showing the first problem instead of formatted output.
Can I format Kubernetes or Docker Compose YAML with it?
Yes, since those are standard YAML files the tool parses and re-dumps them like any other input. Note that comments commonly used in those files will be dropped during reformatting.
Why did my anchors and aliases disappear after formatting?
The tool serializes with reference output turned off, so YAML anchors and aliases are resolved into their full expanded values rather than kept as &name and *name references.
How does it handle very long lines or strings?
Line wrapping is disabled, meaning long scalar values and strings are written on a single unwrapped line instead of being folded across multiple lines.
Is there a limit on how large a YAML file I can format?
There is no enforced size limit because processing happens entirely in your browser. Practical limits depend on your device's memory and the browser's performance with very large inputs.
What is the difference between formatting and validating YAML?
Formatting reflows the file into a consistent layout while validating only checks whether the syntax is correct. This tool formats, but it surfaces parse errors as a side effect; dedicated validators focus on reporting correctness without rewriting the file.
Related tools