YAML Formatter
Format and validate YAML in your browser: choose 2 or 4 space indent, wrap width, sort keys A to Z or output JSON. Free, nothing uploaded.
About YAML Formatter
The YAML Formatter checks that your YAML parses and rewrites it with tidy, consistent indentation. Perfect for Kubernetes, CI, Docker Compose and API definition files.
Indent and wrap
Choose 2 or 4 spaces and a wrap width for long lines.
Sort keys
Tick Sort keys A-Z for files that are easy to compare.
Output as JSON
Get the same document as indented JSON instead.
YAML 1.2 rules
yes stays the string yes, not true, matching modern YAML parsers.
Clear errors
Broken YAML shows the reason with the line and column.
Private
Everything runs in your browser. Nothing you paste is uploaded.
What is YAML?
YAML is a human-friendly data format that uses indentation instead of brackets. It is common in configuration files for Kubernetes, GitHub Actions and Docker Compose.
Common YAML mistakes
Tabs are not allowed for indentation, and a key needs a space after its colon. Text that looks like a number or a date, such as 1.10 or 2026-01-01, may need quotes to stay a string.
How to use YAML Formatter
- Paste your YAML or open a file.
- Choose the indent and the line width.
- Tick Sort keys A-Z or Output as JSON instead if you need them.
- Read the result or the error, then copy it or download the .yaml file.
Help & FAQ
What does the YAML Formatter do?
It parses your YAML, reports an error if it is invalid and writes it back with the indent and wrap width you choose.
Does it keep our comments?
No. Comments are dropped when the YAML is re-formatted, as the page itself warns, so keep a copy if they matter.
Why did y become 'y' in quotes?
In the test a bare y in a list was written as 'y' because some YAML 1.1 parsers read a bare y as true, so the formatter quotes it to be safe.
Can it sort keys?
Yes. Tick Sort keys A-Z and keys are put in alphabetical order. In the test a came before b and c.
What does Output as JSON instead do?
It writes the parsed document as indented JSON rather than YAML, with lists as arrays and mappings as objects.
What happens to anchors and aliases?
They are resolved. In the test a key that used an alias came out with the full object, and re-formatted YAML renames anchors, for example to &ref_0.
Does it handle several documents separated by ---?
It parses them, but with JSON output the result was two separate JSON objects, not an array. Use the YAML to JSON tool if you need an array.
Is yes read as true?
No. In the test yes stayed the string yes, following YAML 1.2. Programs that use YAML 1.1 may read it as true.
How does it wrap long lines?
Long text is folded into a block scalar written with >- and wrapped at the width you pick: 80, 120 or no wrapping.
What does an error look like?
It shows Invalid YAML with the reason and position, such as deficient indentation (line 2, column 1), and no result is produced.
Does it validate against a schema?
No. It checks that the text is valid YAML only. It does not check Kubernetes, OpenAPI or any other schema.
Is our YAML uploaded?
No. The formatting runs in your browser and the text is not sent to a server for processing.