Skip to content

YAML Formatter and Viewer

Format, validate, and visualize YAML documents with tree view and customizable indentation.

YAML Formatter and Viewer tool

Loading...

Example

Input: server: / host: example.com / ports: [80, 443] (nested with 6-space indents)

Result: server: / host: example.com / ports: / - 80 / - 443 (each level indented 2 spaces)

The YAML is parsed and re-written with consistent 2-space indentation, single spaces after colons and flow lists expanded to block lists.

  1. Paste your YAML document into the input text area.
  2. Choose an indent size (2 or 4 spaces) to match your project conventions.
  3. Click "Format YAML" - any syntax error, such as tab characters or inconsistent indentation, is reported with its line and column.
  4. View the reformatted YAML with clean, consistent indentation in the output area.
  5. Click "Show Tree View" to interactively expand and collapse nested nodes for easier navigation.
  6. Click the copy button to copy the formatted YAML to your clipboard.

Formatting YAML and Finding Indentation Errors

A YAML formatter rewrites a YAML file with consistent indentation and spacing, so its structure is easy to see. This one also validates the syntax, points to the line and column of any error, and can show the data as a collapsible tree.

YAML uses indentation instead of brackets to show structure. A key that is two spaces too far right quietly becomes the child of the wrong parent, and tabs are not allowed for indentation at all. Pasting a Kubernetes manifest or a GitHub Actions workflow here catches those mistakes before a deploy does. Duplicate keys and unclosed quotes or brackets are reported too.

Click Format YAML to parse the document and write it back with 2 or 4 spaces per level. Extra spaces after colons are removed and inline lists like [80, 443] are expanded into - items. Files with several documents separated by --- are supported, and each is formatted in turn. The YAML 1.2 core schema is used, so dates like 2024-01-01 stay as written instead of turning into timestamps.

Because the file is parsed and rewritten, some details are not kept. Comments are removed, and anchors and aliases are expanded into full copies of the data. Keep your original if those matter. Show Tree View displays the parsed data with the top two levels open and an item count on each branch. To use the result in code, convert it with YAML to JSON.

Sources

Frequently Asked Questions

The YAML specification forbids tabs for indentation, because editors show them at different widths and the structure would become ambiguous. The formatter reports tab characters must not be used in indentation, with the line and column. Replace the tabs with spaces; most editors can do this for the whole file at once.
The formatter parses your YAML into data and writes that data back out, and comments are not part of the data. They are lost in the process, along with anchor names. If your file relies on comments, fix the indentation by hand using the error location this tool gives you, rather than replacing the file with the formatted output.
Yes. Documents separated by --- are each parsed and formatted, then joined again with --- between them. This is common in Kubernetes, where one file holds several manifests. The tree view shows multiple documents as a list, one entry per document.
Two spaces is the most common style and matches Kubernetes and GitHub Actions examples. Four spaces can be easier to read in deeply nested files. YAML accepts either, as long as each level is consistent. Pick one per project and let the formatter apply it everywhere.
It catches anything the YAML parser rejects: tab indentation, a child indented to an impossible level, duplicate keys, unclosed quotes or brackets, and similar problems. Each error shows the line and column plus a short snippet. It does not check whether the content is correct for your tool, such as a misspelled Kubernetes field.

Related Tools

JSON to YAML Converter

Convert JSON documents to YAML format with syntax validation, clean formatting, and instant preview.

Developer Tools

YAML to JSON Converter

Parse YAML documents and convert to formatted JSON with error reporting and syntax validation.

Developer Tools

YAML to TOML Converter

Transform YAML documents to TOML configuration format with proper table structure and types.

Developer Tools

JSON Formatter and Validator

Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.

Developer Tools

XML Formatter and Prettifier

Format, indent, and validate XML documents with customizable indentation and output options.

Developer Tools

TOML to YAML Converter

Convert TOML configuration files to YAML format seamlessly with structure preservation.

Developer Tools