How to use the YAML Validator and Formatter
Start with YAML input, browse files, or drop a file on Drop a YAML file here. The YAML Validator and Formatter checks each document, shows the document, line, and column for reported errors, and builds a formatted output preview from the settings you choose.
- Paste YAML into YAML input, click browse files, or drop a file on Drop a YAML file here.
- Choose Indentation, Line endings, Quote style, Max consecutive blank lines, and Key order.
- Review Documents, Errors, parser limitations, and Formatted output preview after the input is checked.
- Select Export errors to download the listed rows, or correct the YAML and let it be checked again.
- Select Export YAML when Errors shows zero. Select Clear to remove the current input.
How to validate YAML syntax
The parser reads multi-document streams with --- and ... markers. It handles block and flow mappings or sequences, quoted and plain scalars, literal and folded block scalars, anchors, aliases, and merge keys. A duplicate mapping key is reported at the line where it appears again. Documents are parsed independently.
Open Errors to see rows under Doc, Line:Col with the parser message. The tool records one thrown YAML error per document, and Export errors downloads those rows as CSV.
The page reads the YAML in the browser and creates the downloads there. Its code does not send your YAML content in a network request.
How to format YAML with custom indentation
The initial settings are 2 spaces, LF (Unix / Mac), Preserve as written, 1 under Max consecutive blank lines, and Preserve declaration order. Change Indentation to 4 spaces, choose CRLF (Windows), select another Quote style, or choose Alphabetical (per mapping) under Key order. Changing a setting checks and formats the current non-empty input again.
name: Ada
roles:
- admin
- editor
With 4-space indentation selected, the sequence is previewed as:
name: Ada
roles:
- admin
- editor
Alphabetical ordering sorts mapping keys recursively and leaves sequence item order alone. Comments and document boundaries stay where the transformation allows it. Quote conversion applies to values the parser resolves as strings. Recognized booleans, numbers, nulls, infinity, and NaN stay unquoted; date-like values can be treated as strings. Flow collections and some multiline quoted or folded scalars can remain unchanged and appear as parser limitations.
Which YAML syntax errors are reported
Tab indentation, unsupported directives such as %TAG and %YAML, complex mapping keys, and unresolved aliases produce parser errors. Parser limitations are listed separately, so a preserved flow collection does not by itself block Export YAML. Reported errors disable formatted export. The tool does not repair semantics, fetch schemas, or convert YAML to JSON.
Where YAML validation comes up
- For a deployment file with an anchor or merge key, check the reported document and line location before editing the source.
- For a multi-document YAML stream, export the error rows as a CSV for a code review.
- For a configuration file, select 4-space indentation, one blank line, and alphabetical mapping keys before exporting the preview.
When to choose YAML or TOML validation
Use the Config File Validate Tools category when you need to check another configuration format in the browser. Keep this page for YAML streams and YAML presentation rules. Choose the TOML Validator and Formatter for TOML tables, inline tables, arrays, arrays of tables, quoted or dotted keys, booleans, numbers, or dates.
Frequently asked questions
How does the YAML Validator and Formatter show syntax errors?
Errors shows one parser error per affected document, with the document index, line, column, and message. Later documents are checked independently.
How do I format YAML with four spaces?
Choose 4 spaces under Indentation, then review Formatted output preview. The current input is checked and formatted again when the setting changes.
Can YAML Validator and Formatter export YAML with errors?
No. Export YAML stays disabled while reported errors remain. Correct the source and let the input be checked again before exporting.
Does YAML formatting change comments or values?
Comments and document boundaries stay where the transformation allows it. Quote conversion targets values resolved as strings, while flow collections and some multiline scalars can remain unchanged.