Skip to content
Tezmy Tools

YAML Formatter

Validate, format and tidy YAML, keep your comments, sort keys or convert it to JSON

Output

Indent

Valid YAML.

# app config
name: demo
ports: [ 80, 443 ]
env:
  DEBUG: "false"
  LEVEL: info
services:
  - name: web
    image: nginx:1.27
  - { name: db, image: "postgres:16" }

Runs in your browser. Nothing is uploaded.

About the YAML Formatter

YAML Formatter checks your YAML for errors and rewrites it neatly. Paste a YAML file, such as a Docker Compose file, a Kubernetes manifest, a GitHub Actions workflow or any config, and the page validates it, tells you the line and column of the first error and shows a clean version with a 2 or 4 space indent. Your comments are kept, you can sort the keys alphabetically, and files with several documents separated by three dashes are handled. You can also convert the YAML to JSON. The work happens in your browser, so private configuration files are not uploaded.

Updated October 2026

How to use the YAML Formatter

  1. 1Paste your YAML into the box.
  2. 2Choose formatted YAML or JSON as the output.
  3. 3Choose a 2 or 4 space indent, and sort keys if you like.
  4. 4Read the result or the error message with its line number.
  5. 5Copy the result or download it as a file.

Why YAML goes wrong

YAML uses indentation to show structure, which makes files pleasant to read and easy to break. A single space too many moves a key into another block, and a tab is an error. Running the file through a validator before you commit saves time, because the error message points at the line.

Common YAML mistakes

Most errors fall into a few groups. Learning them makes your files safer.

  • Tabs instead of spaces
  • A missing space after the colon: key:value
  • Values like yes, no and on that are read as true or false
  • A colon or hash inside an unquoted text
  • Different indent in a list

Formatting for teams

Pick one indent for the whole project and keep the same order of keys in similar files. Sorting keys makes changes easier to review but may hurt the readability of a file that is meant to be read from top to bottom, so use it for data, not for pipelines.

Related tools

Convert with the YAML to JSON Converter and the JSON to YAML Converter, format JSON with the JSON Formatter, compare versions with the Diff Checker and check JSON with the JSON Validator.

Features

  • Validation with line and column of errors
  • Indent of 2 or 4 spaces
  • Comments are kept
  • Optional alphabetical key sorting
  • Several documents in one file
  • Convert to JSON, private in your browser

Frequently asked questions

How do I validate YAML?

Paste it in. If it has a syntax error, the page shows the message and the line and column. If it is valid, you see the tidy version.

Does it keep my comments?

Yes. Comments are part of the document and stay in place when it is formatted.

What indent should I use?

Two spaces is the most common in YAML files, such as Kubernetes and GitHub Actions. Never use tabs, since YAML does not allow them for indentation.

Why does my YAML fail?

The usual causes are tabs instead of spaces, wrong indentation, a missing space after a colon or a dash, or special characters such as a colon in a value that need quotes.

What happens to the quotes and flow style?

The formatter keeps your quotes and arrays written in brackets, and spaces them consistently. Long lines are not wrapped.

Does it sort keys?

Only if you tick the option. Be careful with files where the order matters, such as a CI pipeline.

Can it convert YAML to JSON?

Yes. Choose JSON as the output.

Can I format a Docker Compose or Kubernetes file?

Yes. Both are plain YAML. The formatter checks the syntax, but it does not know the rules of Compose or Kubernetes, so it cannot tell whether a field name is valid for them.

What are anchors and aliases?

YAML lets you name a block with an anchor (&name) and reuse it with an alias (*name). They are kept as written when the file is formatted, and the JSON output expands them.

Is my YAML uploaded?

No. Everything runs in your browser, so secrets and configuration stay on your device.

Related tools