GALAXY OF TOOLS

DEV SECTOR

YAML Formatter & Validator

Re-indent and validate YAML without losing comments, anchors or documents — and catch YAML 1.1 “Norway” traps.

Runs entirely in your browser. Nothing you enter or upload is sent to a server.

A YAML formatter that keeps your comments

The YAML formatter and validator re-indents messy YAML into a consistent style and tells you exactly what is wrong when a file will not parse. Paste a Kubernetes manifest, a Docker Compose file, a GitHub Actions workflow, an Ansible playbook or an OpenAPI spec, and you get clean output in the same format — not JSON — with every # comment, anchor, alias and --- document separator still in place.

Many beautifiers convert YAML to data and back, which throws comments away and expands anchors. This one edits the YAML document itself, so only layout — and, if you ask, quoting and key order — changes. It then re-reads its own output to confirm the data is identical and counts comments before and after.

It also checks portability. A value like NO, on, 0755 or 2026-03-15 means one thing to a YAML 1.2 parser and another to a YAML 1.1 parser such as PyYAML; each one is flagged with its line and column. Everything runs in your browser — your configuration and secrets are never uploaded.

How to use the YAML Formatter & Validator

  1. Paste YAML into YAML input, drop a .yaml/.yml file on it, or press Load file.
  2. Choose Format to beautify, or Validate only for a clear valid/invalid verdict without changing anything.
  3. Pick the Indentation, how Lists under a key are indented, the String quotes style and the Line width.
  4. Optionally tick Sort keys A–Z, Expand [flow] and {flow} collections or Quote values YAML 1.1 would misread.
  5. Read the Problems and warnings list — click a line number to jump to it — then Copy or Download .yaml.

YAML Formatter & Validator features

Comments survive

Full-line and end-of-line comments stay attached to the keys they describe, even when keys are sorted.

Anchors, aliases and merge keys

&defaults, *defaults and <<: are written back as anchors and aliases, never expanded.

Values written as you wrote them

Numbers such as 0755, 1.50 and +8080, and booleans like yes, keep their original spelling.

Precise error locations

Tabs used for indentation, duplicate keys (with the line of the first one), bad indentation, unclosed quotes and aliases without an anchor are reported by line and column.

YAML 1.1 vs 1.2 check

The file is read with both rule sets and every unquoted value that changes meaning is listed: the Norway problem, octal numbers, base-60 times and unquoted dates.

Multi-document files

Several --- documents, %YAML directives and ... end markers are kept.

Values that change meaning between YAML 1.1 and YAML 1.2

YAML 1.2 (2009) shrank the list of words treated as booleans and changed how numbers with a leading zero are read. Many tools still use YAML 1.1 rules — PyYAML, and with it much of the Python ecosystem, is the best-known example. The formatter follows YAML 1.2 and flags each of these:

Unquoted valueYAML 1.2 readsYAML 1.1 readsSafe spelling
country: NOstring “NO”boolean falsecountry: "NO"
enabled: yes / onstringboolean truetrue, or "yes" for text
mode: 0755number 755octal = 493"0755" for a file mode
zip: 01234number 1234octal = 668"01234"
port: 22:22string “22:22”base-60 number 1342"22:22"
released: 2026-03-15stringtimestamp"2026-03-15" if it must stay text
python: 3.10number 3.1number 3.1"3.10" — trailing zero lost in both

What formatting changes — and what it never touches

  • Changed: indentation, the position of list dashes, spacing inside flow collections ([a, b] becomes [a, b]) and before end-of-line comments, and trailing whitespace.
  • Changed only if you ask: quote style, key order, flow collections expanded into block style, and long strings folded at your chosen line width.
  • Kept: comments, blank lines between sections, anchors, aliases, merge keys, tags such as !Ref, literal | blocks and document markers.
  • Folded > blocks may be re-wrapped, because their single line breaks are not part of the value.
  • With 4-space indentation, “Compact” lists keep the dash inside the indent, so item text lines up with the key’s children.
  • JSON Schema validation is not included: the tool checks YAML syntax and portability, not whether a Kubernetes or Compose file uses the right fields.

Reading the error messages

Lines and columns count from 1. The first error is shown in context with a caret under the exact position, and tabs drawn as →. Common messages:

MessageUsual cause and fix
Tabs are not allowed as indentationAn editor inserted a tab. Replace it with spaces.
Duplicate key “name”The same key appears twice in one mapping. Delete or rename one — parsers disagree on which value wins.
Nested mappings are not allowed in compact mappingsA line is indented one space too far, so it looks like it belongs to the key above.
Missing closing "quoteA quoted string never ends — often an apostrophe inside single quotes. Double it ('it''s') or use double quotes.

YAML Formatter & Validator FAQ

Does this YAML formatter keep comments?

Yes. The YAML formatter works on the YAML document itself rather than converting it to JSON, so comments are written back next to the keys they belong to. The status bar shows how many were kept, and warns if any could not be placed.

How do I validate a YAML file without changing it?

Switch to Validate only. You get a verdict — Valid YAML or Invalid YAML — with counts of documents, errors and YAML 1.1 warnings, and a clickable list of every problem. Nothing is rewritten.

What is the Norway problem in YAML?

In YAML 1.1 the unquoted words yes, no, on, off, y and n are booleans, so the country code NO for Norway becomes false. YAML 1.2 fixed this, but many parsers still follow 1.1. Quote such values, or tick “Quote values YAML 1.1 would misread” to do it automatically.

Will sorting keys break my anchors?

No. If A–Z order would move an alias such as *defaults above its &defaults anchor, that document keeps its original order and a note says why. Merge keys (<<) stay first.

Can I format Kubernetes, Helm or GitHub Actions files?

Kubernetes manifests, Compose files and workflows format fine, including multi-document files. Helm templates containing {{ … }} are usually not valid YAML until rendered, so run helm template first.

Is my YAML uploaded anywhere?

No. Parsing, checking and formatting run in your browser using the open-source yaml library (version 2.9.1, ISC licence), downloaded once from the jsDelivr CDN. Your file never leaves your device.

How do I convert YAML to JSON instead?

Use the YAML ↔ JSON Converter. For other formats there are YAML to XML and XML to YAML, and the JSON Formatter for JSON files.

You might also need