YAML formatter

Paste messy YAML and get it re-indented consistently. The YAML formatter parses the document first, keeps your comments and reports the line and column of any syntax error.

  • Free
  • No sign-up
  • Runs in your browser

Runs in your browser — your text is never sent to our servers.

How to use YAML Formatter

  1. Paste your YAML into the Input box, or click Open a file to load a .yaml or .yml file.
  2. Choose the Indentation, 2 or 4 spaces.
  3. Optionally tick Sort mapping keys A to Z, or set Wrap long text to At 80 characters or At 120 characters. By default long text is never folded.
  4. Read the formatted YAML in the Output box, then click Copy or Download to save formatted.yaml.

Features

  • Re-prints YAML with consistent 2-space or 4-space indentation
  • Keeps comments, and keeps several documents separated by ---
  • Optional sorting of mapping keys from A to Z, with comments moving along with their key
  • Optional wrapping of long text at 80 or 120 characters, off by default
  • Error messages with line and column
  • Runs in your browser, so the YAML is never uploaded

Supported formats and limits

  • Maximum input: 10,000,000 characters

Examples

InputResult
name: OneVixa tools: - json # data - yaml settings: free: true limit: null name: OneVixa tools: - json # data - yaml settings: free: true limit: null — Indentation is reduced to 2 spaces and the comment is kept.
b: 1 a: - xa: - x b: 1 — With Sort mapping keys A to Z ticked, keys are ordered alphabetically. With it off, b stays first.

Limitations

  • The formatter changes layout only. It does not change values, but quote styles and some spacing may be normalised.
  • Sorting keys changes the order of the keys in the output, and it can matter if a tool reads them in order.
  • It checks YAML syntax, not a schema, so it will not tell you whether a Kubernetes or Docker Compose file is correct.
  • Very large files can be slow to process in the browser.

Learn more

In YAML, indentation is part of the syntax. Nested mappings and lists are defined by how far a line is indented, and the specification forbids tab characters for indentation. A formatter is therefore more than a cosmetic tool: a consistent indent makes the structure visible and helps you spot a line that is one level off.

This formatter parses the text into YAML's document model and prints it again with the indentation you choose. Because it reads the comments as part of that model, they survive the round trip. Values are not evaluated or changed, so an unquoted 8080 stays 8080 and "8080" stays text.

Sorting keys can make diffs smaller and files easier to scan, but not every consumer ignores key order, so use it with care on configuration you do not fully control. Formatting never checks meaning: a file can be well-formed YAML and still be wrong for the tool that reads it, which needs that tool's own schema validation.

Frequently asked questions

Does the YAML formatter keep my comments?

Yes. Comments stay in the output, and with sorting on they move together with the key they belong to.

Will formatting change what my YAML means?

It is meant to change layout only. Because the document is parsed and printed again, quote styles and spacing can be normalised, but values stay the same.

Why does it say my YAML is invalid?

Typical causes are tabs used for indentation, inconsistent indentation, a missing space after a colon, or an unclosed bracket or quote. The message shows the line and column.

Can it format a file with several documents?

Yes. Documents separated by --- are kept as separate documents.

Is my YAML uploaded?

No. Formatting runs in your browser.

Sources

Last reviewed: September 30, 2026