// Poorly indented → normalised
name: Acme
version: 1.4.2
servers:
- https://api.acme.example
- https://api-staging.acme.exampleStart typing to search, or pick a tool.
Prettify YAML with consistent 2-space indentation and helpful line-aware errors.
YAML input
Formatted YAML
Well-formatted YAML is easier to read, review, and maintain. When multiple developers contribute to the same configuration files, inconsistent formatting makes diffs noisy and code reviews painful. A formatter normalises indentation, spacing, and line wrapping so every file follows the same structure regardless of who wrote it.
This formatter parses your YAML into an abstract syntax tree and re-serialises it with consistent 2-space indentation, clean line wrapping at 120 characters, and proper structural spacing. The result is YAML that looks the same every time — whether it came from a colleague, an API response, or an automated tool.
The formatter uses js-yaml to parse your input, then dumps it with controlled options: 2-space indentation, no reference expansion, and a 120-character line width. This means your YAML will have consistent structure without losing any data or changing values.
If your YAML has syntax errors, the formatter displays the parse error with the exact line and column where the problem occurred. Fix the error in the input pane and the formatted output will update automatically once the YAML is valid.
Before code review. Format YAML files before committing so reviewers focus on content changes, not formatting noise. Consistent indentation eliminates irrelevant diffs and makes reviews faster.
Kubernetes manifests. Kubernetes YAML files can be complex with deep nesting. Formatting ensures every resource spec is consistently indented, making it easier to spot misconfigurations and maintain large manifests.
CI/CD pipelines. Automated formatting in your pipeline prevents style drift. Tools like Prettier or yamllint with auto-fix can enforce formatting on every commit, keeping your entire codebase consistent.
The most widely adopted YAML formatting standard is 2-space indentation. This is used by Kubernetes, Docker Compose, Ansible, and most open-source projects. The YAML specification itself does not mandate a specific indent size, but 2 spaces has become the de facto standard across the industry.
Key ordering is preserved by this formatter — it does not sort keys alphabetically. This is intentional because many YAML files rely on specific key ordering for readability or tool compatibility. If you need sorted keys, use a dedicated YAML sort tool before formatting.
Long lines are wrapped at 120 characters by default. This balances readability with line length, and matches the default used by many popular formatters. For projects with different line length preferences, consider using a local YAML formatter configured to your team's standards.
Prettier is the most popular code formatter for web projects and it supports YAML natively. Install Prettier and add a .prettierrc with your YAML preferences: { "tabWidth": 2, "useTabs": false }. Run npx prettier --write "**/*.yaml" to format all YAML files in your project.
Prettier and this online tool use the same underlying formatting logic — consistent indentation, proper spacing, and clean structure. Use this tool for quick one-off formatting, and Prettier for automated project-wide formatting as part of your development workflow.
Mixed indentation. The most common YAML issue is mixing tabs and spaces. YAML is whitespace-sensitive and a single tab where a space is expected causes a parse error. This formatter normalises all indentation to 2 spaces, eliminating the problem.
Inconsistent list markers. YAML allows both - and * for list items. The formatter standardises on - for sequences, which is the more common and readable convention.
Unnecessary quoting. YAML does not require quoting most strings. The formatter removes unnecessary quotes to produce cleaner output while preserving quotes where they are needed for special characters, reserved words, or values that could be misinterpreted as other types.
// Poorly indented → normalised
name: Acme
version: 1.4.2
servers:
- https://api.acme.example
- https://api-staging.acme.exampleA YAML formatter is a tool that automatically organizes and prettifies YAML files with consistent indentation, proper spacing, and clean structure. It makes YAML documents easier to read and maintain without changing the actual data values.
YAML formatters are used to standardize indentation in configuration files, clean up messy YAML from different sources, ensure consistent style across team projects, and make Kubernetes manifests, Docker Compose files, and CI/CD configs more readable.
Install a YAML formatter extension like "YAML" by Red Hat or "Prettier YAML". You can also use this online formatter by pasting your YAML — it applies consistent 2-space indentation automatically.
For DevOps workflows, use yq (CLI), yamllint for validation + formatting, or IDE extensions in VS Code/IntelliJ. This online tool is great for quick formatting of Kubernetes manifests, Docker Compose files, and Ansible playbooks.
No. It only normalises whitespace and indentation. The parsed values, structure, and data types remain exactly the same.
No. Strings are emitted with the same quoting that js-yaml determines is canonical. Your intentional quoting choices are preserved.
No. Formatting happens entirely in your browser using JavaScript. Your data never leaves your device.
The formatter parses your YAML into an abstract syntax tree, then re-serializes it with consistent indentation (2 spaces by default), proper line wrapping, and clean structure. All while preserving the original values and types.