usefmtly

YAML Formatter & Validator

Format, validate, and convert YAML online. Instant syntax highlighting, configurable indent, JSON output. Free — no signup required.

Indent
input.yaml
output.yaml
{

Paste YAML on the left to format it here

How to use the YAML Formatter

  1. Paste your YAML into the input panel on the left, or click “Load sample” to try an example.
  2. The output updates instantly in the right panel with syntax highlighting. If there are errors, the exact line and message appear at the bottom of the input.
  3. Configure the output — switch between 2 and 4-space indent, toggle JSON output, or sort keys alphabetically.
  4. Copy or apply — click Copy to copy the output, or Apply (←) to replace your input with the formatted version.

What is YAML?

YAML (YAML Ain't Markup Language) is a human-readable data serialisation language designed to be easy to write and read. Unlike JSON or XML, YAML uses indentation to represent structure — which makes it highly readable for configuration files but also sensitive to whitespace errors.

YAML is the standard format for Kubernetes manifests, GitHub Actions workflows, Docker Compose files, Ansible playbooks, and countless other DevOps and development tools. Consistent formatting is important because a misplaced space or inconsistent indent can cause a valid-looking file to fail silently.

Common YAML formatting mistakes

Inconsistent indentation

YAML requires consistent indentation throughout a file. Mixing 2-space and 4-space indents in the same file will cause a parse error. This formatter normalises all indentation to your chosen size.

Tabs instead of spaces

YAML explicitly forbids tab characters for indentation. Any tab will cause a parse error. Most editors can be configured to insert spaces when you press Tab, but if you paste YAML from another source, tabs can sneak in. This formatter removes tabs automatically.

Unquoted special characters

Values containing colons, hash signs, or other YAML control characters must be quoted. For example, a value like "http://example.com" needs quotes because the colon has a special meaning. The formatter adds quotes where needed.

Wrong boolean values

YAML 1.1 (used by many tools) interprets "yes", "no", "on", "off" as booleans. If you intend them as strings, they must be quoted. YAML 1.2 only treats "true" and "false" as booleans. Be explicit.

YAML vs JSON — when to use each

YAML and JSON represent the same data structures and are fully interconvertible. The choice between them comes down to context:

Use YAML when…

  • ·Writing configuration files humans will read and edit
  • ·You need comments (JSON has none)
  • ·You want a cleaner look without braces and quotes
  • ·Working with DevOps tooling (Kubernetes, Ansible, GitHub Actions)

Use JSON when…

  • ·Sending data over HTTP APIs
  • ·Your language's standard library parses it natively
  • ·Strict interchange format is required
  • ·You need wide tool compatibility (every language supports JSON)

Frequently Asked Questions

What does this YAML formatter do?

It parses your YAML input, validates that it is syntactically correct, and re-serialises it with consistent indentation and formatting. If your YAML has errors, it shows the exact line and reason so you can fix it quickly.

Can I convert YAML to JSON?

Yes. Use the JSON toggle above the output panel to switch between YAML and JSON output. The tool parses your YAML and re-serialises it as JSON with your chosen indent size.

What indent size should I use?

Both 2 and 4 spaces are valid YAML. 2 spaces is the most common convention (used by Kubernetes, GitHub Actions, and most YAML-heavy tools). 4 spaces is preferred in some Python and Ruby projects. The default here is 2 spaces.

Does it support multi-document YAML?

The formatter currently handles single-document YAML. Multi-document files (separated by ---) load the first document only. Multi-document support is on the roadmap.

Why does my YAML look different after formatting?

The formatter normalises your YAML: it standardises quoting, rewrites keys with consistent spacing, and optionally sorts keys alphabetically. The values themselves are never changed — only the presentation.

What is YAML used for?

YAML (YAML Ain't Markup Language) is a human-readable data serialisation format widely used for configuration files. Common uses include CI/CD pipelines (GitHub Actions, GitLab CI), container orchestration (Kubernetes), infrastructure as code (Ansible, Terraform), and application configuration.

Is my data sent to a server?

No. All formatting and validation happens entirely in your browser using JavaScript. Your YAML content is never sent to any server.

Related Tools