b2KIT

YAML Formatter & Validator

Format, validate, and lint YAML files with proper indentation and error highlighting.

Tested tool guide Tested browser tools Checked August 16, 2026

What YAML Formatter & Validator does, with a checked example

YAML is forgiving about whitespace, which is why config files drift into a mess: sequences at odd indent levels, double spaces after colons, tabs where spaces belong. This tool parses the document you paste, re-emits it with a consistent two-space layout, and flags anything that does not parse, highlighting the offending line and column. The surprise most people hit: validation passing does not mean the document means what you think. Unquoted values become numbers, booleans, or timestamps, duplicate keys are often accepted with the last one winning, and processing happens entirely in the browser, which matters because config files routinely contain credentials. Read the lint output, not just the check mark.

Worked example

A concrete input and expected output from the current implementation.

Input

name: demo
version: "1.0"
enabled: true
servers:
- host: web1
  port: 80
- host: web2
  port: 8080

Expected output

name: demo
version: "1.0"
enabled: true
servers:
  - host: web1
    port: 80
  - host: web2
    port: 8080

The input parses as written, because YAML permits a block sequence at the same column as a top-level key, so validation passes before formatting runs; the formatter then re-emits the same structure with two-space indentation, dashes under their key and nested keys two spaces deeper, while the quotes around 1.0 are untouched because quoting controls the value's type.

How the result is produced

1

Parse, then re-serialize

The formatter does not edit the text line by line. It parses the whole document first, so malformed input stops with a line-and-column error rather than half-formatted output. The parsed structure is then written back with fixed rules: two spaces per indentation level, one space after each colon, dashes indented under their parent key. Scalar quoting is preserved as written, because rewriting quotes can change a value's type.

2

Validation versus lint

Results come from two separate passes. Validation checks the grammar: tabs used for indentation, mismatched flow-collection brackets, unterminated quotes, and inconsistent indentation inside one block all fail here. Lint runs on top for constructs that parse but look wrong, notably duplicate keys, which many parsers accept silently, last value winning. Read them together: green validation with lint warnings means the file will load, but possibly not as you wrote it.

Good uses

  • A hand-edited GitHub Actions workflow or docker-compose file has drifted into mixed two- and four-space indentation; run it through before committing so the diff stays readable.
  • A build tool rejects a config with an opaque message like 'mapping values are not allowed here'; paste the file to locate the exact line and column of the offending construct.
  • You generated a Kubernetes manifest or pipeline definition with a script or AI assistant; verify it parses and contains no duplicate keys before applying it.

Limits and checks

  • Valid is not the same as intended. Unquoted values are typed by YAML: version: 1.0 loads as a number, 2024-11-05 as a timestamp in parsers built on YAML 1.1, and yes or on as booleans there too. The formatter deliberately keeps your quoting, so it will not fix a value that loads with the wrong type; the quotes have to come from you.
  • The YAML version matters. The 1.1 and 1.2 specifications differ in what plain scalars mean, and a file that passes here can load differently, or fail outright, in a parser built on the other version. If the tool offers a version selector, match it to your target toolchain; PyYAML, for instance, follows 1.1 in several behaviors while most newer libraries implement 1.2.
  • Duplicate keys are the quiet failure. Most linters treat them as an error, yet common parsers accept them and take the last value, so a file that loads cleanly can silently shadow an earlier setting, typically after a merge or a generator run. Treat duplicate-key warnings from the lint pass as real errors.

Common questions

The validator says my file is fine, but my application still refuses to load it. Why?

Validation covers YAML syntax only; applications add their own requirements, like mandatory keys, allowed value types, or a different YAML version, and 1.1 versus 1.2 changes how values such as yes and 07 are read. Duplicate keys are another gap: this tool flags them, while your app's parser may accept them with the last value winning. Compare the app's exact error message with the line the validator highlights.

Will formatting change what my YAML means?

Not for ordinary documents: the formatter re-serializes the same parsed structure, and it never rewrites quotes because quoting controls type. The caveats are edge-case documents that implementations parse differently, and comments, which formatters attach to the re-emitted structure in different ways, so check the diff if your file is comment-heavy.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools