YAML Formatter and Validator

Paste YAML and it is checked and re-indented as you type. Your comments stay. If something is wrong, you see the line and column, including duplicate keys most parsers ignore.

How it works

The YAML is read with a full YAML 1.2 parser, then written back with even indentation: 2 or 4 spaces per level, as you choose.

Comments, quote styles, anchors and aliases are kept. A value such as 1.10 or NO is written exactly as you typed it, so the formatter never changes what your file means. A file with several documents separated by --- keeps all of them.

If the YAML cannot be read, the tool shows the first error with its line and column and writes nothing. A key that appears twice in the same map counts as an error. The parser runs on this page, and your YAML is not uploaded.

How to use it

  1. 1 Pick 2 or 4 spaces of indent.
  2. 2 Pick whether inline lists and maps, such as [a, b], stay as written or become one item per line.
  3. 3 Paste your YAML into the first box. The formatted YAML appears in the second box, or the error appears under the first.
  4. 4 Press Copy result, or download it as a .yaml file.

Good to know

  • YAML does not allow tabs for indentation. If you see that error, replace the tabs at the start of the line with spaces.
  • Long strings are never folded onto several lines, so a long URL or command stays on one line.
  • The note under the result counts the documents, which is a quick check that a --- did not go missing.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Re-indenting a config file, and the duplicate key that hid in it

Take a small server config. The first line is server:, and under it, indented four spaces, are port: 8080 with a comment "# default" a few spaces after it, and hosts: [a.example, b.example]. At the bottom is log: {level: info}, written as an inline map with extra spaces after the colon. It works, but the indents and spacing are uneven, which is how files look after several people have edited them.

With 2 spaces chosen, the output has server: on the first line and port: 8080 # default on the next, now indented two spaces, with one space before the comment. The hosts list stays inline, written as [ a.example, b.example ] with a space inside each bracket, and log: { level: info } gets the same spacing. The comment is still there. The values are unchanged. If you choose One item per line instead, hosts: becomes a block with - a.example and - b.example on their own lines, and log: becomes a block with level: info indented below it. Both versions mean exactly the same thing to any YAML parser.

Now a mistake that is easy to make in a long file. Add a second line, port: 9090, at the end of the server block, as line 4. Many YAML parsers accept this without a word and keep only the last value, so the server quietly starts on 9090. The YAML standard says keys in one map must be unique, and this tool follows it. The result disappears and the error says the map keys must be unique, at line 4, column 5, which is where the second port starts. You fix the file before anything reads it.

Values are kept as you wrote them, which matters more in YAML than in most formats. Under YAML 1.1, which some older parsers such as PyYAML still follow, an unquoted NO or yes is read as a boolean, so country: NO can turn into false. Under YAML 1.2, which this tool uses, they are strings. Either way, the formatter writes NO back as NO and does not add or remove quotes. The same goes for numbers: version: 1.10 stays 1.10 and does not become 1.1. Re-indenting your file never changes how another program reads it.

There are limits. The tool checks YAML syntax, not meaning. It does not know the keys a Kubernetes manifest, a GitHub Actions workflow or a Docker Compose file expects, so a misspelled key that is still valid YAML passes. It reports the first error only; fix it and the next appears. The exact spacing inside inline lists and before end-of-line comments is not kept. And it uses YAML 1.2 rules, so a file written for an older YAML 1.1 parser may be read slightly differently by that parser, even though the text the formatter writes is the same.

Frequently asked questions

Why is a duplicate key an error?

The YAML standard says keys in a map must be unique. Many parsers do not enforce it and keep only the last value, so a setting you thought you had silently disappears. This tool reports the second key with its line and column so you can decide which one you meant.

Will it keep my comments?

Yes. Comments on their own line and at the end of a line are kept. Extra spaces before an end-of-line comment are reduced to one.

Will it change my values?

No. Values are written back as you typed them. 1.10 stays 1.10, not 1.1, and a quoted string keeps its quotes. Only the indentation and the spacing around punctuation change.

Does it check my file against a schema, such as a Kubernetes manifest or a CI config?

No. It checks that the file is valid YAML. It does not know which keys a particular program expects, so a misspelled key that is still valid YAML passes.

Is my YAML sent to a server?

No. The parser is JavaScript running on this page. Nothing you paste leaves your device.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.