YAML Formatter

Paste inconsistent or minified YAML and get it back cleanly reindented. Pick the indent width, alphabetize keys, or switch to compact flow style — all locally, nothing is uploaded.

Try:
Formatted YAML

What this tool does

Paste messy, inconsistently-indented, or minified YAML and get it back cleanly reindented and normalized. Choose how many spaces to indent per nesting level, alphabetize every mapping's keys, or collapse the whole document to compact flow style. It parses the YAML, so invalid input is reported as an error instead of being silently mangled.

Everything runs locally in your browser via WebAssembly — your YAML never leaves your machine and there are no network requests.

Options

Worked example

Input (inconsistent spacing and inline collections):

name:   gizza
tags: [a, b]
nested: {x: 1}

Style block · Indent 2 spaces · Key order preserve

Output:

name: gizza
tags:
  - a
  - b
nested:
  x: 1

Switch Output style to flow to get {name: gizza, tags: [a, b], nested: {x: 1}} on a single line, raise Spaces per level to 4 to widen the indentation, or set Key order to asc to alphabetize the keys.

Limits and edge cases

FAQ

Does formatting change my data?

The values are preserved — the document is parsed and re-emitted with the same data. What changes is the presentation: indentation, quoting, key order (if you sort), and block-vs-flow layout. Comments, blank lines, and anchors are not carried over, and aliases are expanded to their referenced value.

Can I indent with tabs?

No. The YAML specification forbids tab characters for indentation, so the tool only offers spaces (1 to 8 per level). If your editor inserts tabs, this formatter will replace them with consistent spaces.

What is the difference between block and flow style?

Block style is the familiar expanded, multi-line layout where each key and list item sits on its own indented line. Flow style is compact and JSON-like, putting mappings in { } and sequences in [ ] on a single line — useful for minifying a document or writing a short value inline.

Why were some of my strings put in quotes?

A plain YAML scalar like true, null, or 123 is read back as a boolean, null, or number. When your data holds those as strings, the formatter double-quotes them ("true", "123") so they keep their string type on the next parse. Values that are unambiguous are left unquoted.

Why did my YAML fail to format?

The formatter parses the input first, so anything that isn't valid YAML — an unterminated flow collection, bad indentation, or a duplicate key — is reported as an error with the parser's message rather than being guessed at. Fix the reported issue and try again.

Is my YAML uploaded anywhere?

No. The formatter runs entirely in your browser via WebAssembly. Your document never leaves your machine and there are no network requests.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool yaml-formatter "name:   gizza
tags: [a, b]
nested: {x: 1}"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/yaml-formatter/?yaml=name%3A%20%20%20gizza%0Atags%3A%20%5Ba%2C%20b%5D%0Anested%3A%20%7Bx%3A%201%7D&indent=2&style=block&sort_keys=preserve

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.