YAML Formatter & Validator

Paste YAML, click Format to prettify with 2-space indentation, or Validate to check syntax. YAML 1.2 strict mode. Runs in your browser — no upload.

  1. Paste your YAML into the left textarea.
  2. Click Format to round-trip through the parser and emit canonical YAML.
  3. Click Validate to check syntax without modifying the input.
  4. Errors point at the offending line and column.
What does it do?

Parses your YAML with js-yaml in YAML 1.2 strict mode and re-emits it with 2-space indentation, 100-column line width, and consistent quoting. The Validate button checks syntax and reports the first error without changing the input. The output is semantically equivalent to the input — values, types, and structure are preserved.

Example

Messy YAML input:

name:    Ada
tags: [math,logic]
active:true

Formatted output:

name: Ada
tags:
  - math
  - logic
active: true

Common YAML errors and how to fix them

YAML 1.2 in strict mode is unforgiving about whitespace. The patterns below cover most parser failures.

  • Tabs instead of spaces. YAML 1.2 forbids tabs for indentation. Replace every tab with spaces.
  • Inconsistent indent levels. A child indented 2 spaces under a sibling indented 4 spaces will fail. Pick one indent width and use it consistently.
  • Boolean traps. In YAML 1.1 (not the mode here), `yes`, `no`, `on`, `off` parsed as booleans. js-yaml uses 1.2, but real-world inputs that depend on the old behavior surprise users. Quote ambiguous values: `country: "NO"`.
  • Unquoted special characters. Values starting with `:`, `?`, `&`, `*`, `!`, `|`, `>`, `\'`, `"`, `%`, `@`, `` ` `` need quoting.
  • Unterminated quote. A missing closing quote makes the parser absorb the rest of the file as part of the string. The reported line number can be far from the actual error.
  • Anchor / alias mismatch. An alias `*name` referencing an undeclared anchor `&name` raises an error. Verify every alias has a matching anchor declared earlier.
Frequently asked questions

Does Format change my data?

No — only the whitespace, quoting, and ordering of representational details. The parsed value graph is identical. Formatted YAML re-parses to the same in-memory structure as the original.

Are comments preserved when formatting?

No. js-yaml does not retain comments through a parse-and-dump round-trip. If you need comment-preserving YAML formatting, use a different library (yaml.js with options, or a CLI tool like `prettier --parser yaml`).

Can I customize the indentation?

The current build uses 2-space indentation. To customize, run js-yaml on the command line — same library — and pass `{ indent: 4 }` or whatever you need.

How big a YAML file can it handle?

Up to about 10 MB before the textarea slows down. Most config files are well under 1 MB.

Is my YAML uploaded?

No. Everything runs in your browser — your input is parsed and re-serialized by JavaScript on this page and never sent to any server.

Does this lint for style issues like duplicate keys?

js-yaml in default config will reject duplicate keys (a YAML 1.2 strict requirement). Other style issues like inconsistent quoting or anchor naming are not flagged — that needs a dedicated linter like yamllint.