YAML Formatter, Beautifier & Validator
This YAML formatter beautifies, minifies, and validates YAML right in your browser. Paste a Kubernetes manifest, Docker Compose file, GitHub Actions workflow, or Ansible playbook and get clean, correctly indented output with instant error checking.
YAML's indentation-sensitive syntax makes spacing mistakes easy to introduce and hard to spot. The formatter standardizes indentation, flags syntax errors with the exact line and column, and lets you explore nested structures as an interactive tree — so your configuration files stay readable and deployable.
How to Format YAML
Add your YAML
Paste your YAML into the input editor on the left, or use Upload File to load a .yaml or .yml file. Click Sample Data to drop in a Kubernetes deployment config to try it out.
Format or minify
Click Format to beautify with proper indentation, or Minify to convert to compact flow style. For formatting, pick an indent size of 2, 4, or 8 spaces to match your project.
Check validation
Validation runs automatically as you type or paste. If the YAML is invalid, the error box shows the exact line and column, the line number is highlighted, and the status bar reads Invalid YAML.
Explore, copy, or export
Switch to Tree view to browse the structure, use Sort Keys to order keys alphabetically, then Copy the result or Download it as a .yaml file.
Features
Format & Beautify
Turn messy or minified YAML into clean, properly indented code with a choice of 2, 4, or 8 spaces.
Minify
Convert block-style YAML to compact flow style to shrink file size while preserving all data.
Real-Time Validation
Get instant feedback as you type, with errors reported by exact line and column number.
Syntax Highlighting
Color-coded keys, strings, numbers, booleans, null, comments, and document separators.
Interactive Tree View
Browse your YAML as a collapsible tree, with type badges and item counts on every node.
Sort Keys
Alphabetically order every key in one click — works in both format and minify modes.
Upload & Download
Load .yaml or .yml files from your device and save the formatted output as a .yaml file.
Copy & Sample
Copy the formatted result to your clipboard, or load a sample Kubernetes config to test.
Live Status Bar
See a Valid/Invalid indicator plus a running line count, file size, and key count.
Dark Mode
A comfortable dark theme is built in for long sessions editing configuration files.
Frequently Asked Questions
How do I format YAML online?
Paste your YAML into the input editor and click Format. The tool re-indents the document cleanly and shows the result with syntax highlighting. Nothing to install or sign up for — open the page and format.
What is the correct YAML indentation, 2 or 4 spaces?
YAML does not mandate a specific size — it just has to be consistent. Two spaces is the most common, especially in Kubernetes and Docker configs, while 4 spaces is also widely used. Pick 2, 4, or 8 spaces here to match your project's style guide.
How do I fix YAML indentation errors?
Paste the YAML and let the validator point to the problem line and column, then click Format once the structure parses. Formatting rewrites the whole document with uniform indentation, which clears up most spacing mistakes in one step.
Why can't YAML use tabs for indentation?
The YAML spec forbids tabs for indentation because their width is ambiguous, which would make the indentation-based structure unreliable. Always indent with spaces. In this editor the Tab key inserts spaces that match your chosen indent size.
How do I validate YAML syntax?
Validation is automatic — as you type or paste, the status bar shows Valid YAML or Invalid YAML. When there's an error, the message gives the exact line and column and highlights that line in the gutter so you can jump straight to it.
Why are my comments removed after formatting?
Formatting parses your YAML into a data structure and serializes it back out. Comments are not part of the YAML data model, so they are not preserved through that round trip — this is standard behavior for YAML parsers.
What does Minify do?
Minify converts your YAML from block style (with indentation) to flow style, using curly braces and square brackets. The output is as compact as possible while preserving all of your data — handy for embedding YAML in scripts or trimming payload size.
Can I format a file with multiple YAML documents?
The formatter processes the first YAML document in your input. If your file contains several documents separated by ---, only the first one is formatted.
Is this YAML formatter free and private?
Yes. It is free to use and runs entirely in your browser with JavaScript. Your YAML is never sent to any server, so you can safely format and validate sensitive configuration files.
No comments yet. Be the first to comment!