TextyConverterbeta
⌘K

YAML Formatter

Re-emit YAML with consistent 2-space indentation and canonical scalar style. Validates as it formats.

0 characters
0 characters

About YAML Formatter

The YAML formatter parses your input with a real YAML 1.2 parser (js-yaml), then re-emits it with consistent indentation and a canonical block style. Because the document is fully parsed and rebuilt, the formatter also acts as a validator — any syntax error is reported with a line and column.

When to use it

  • Cleaning up hand-edited Kubernetes, Docker Compose, or CI configs
  • Normalizing YAML before committing to source control so diffs stay small
  • Verifying that a YAML file parses without surprises
  • Converting flow-style YAML to readable block style

How it works

Input is parsed with js-yaml's safe loader (YAML 1.2 core schema, no arbitrary code execution). The resulting value is re-emitted with the safe dumper using 2-space indentation, block scalar style, and 100-character line width. Comments are not preserved — YAML comments are stripped during parsing.

Examples

Inconsistent input → canonical block style
name:    Ada
skills:  [math, logic]
active:true
name: Ada
skills:
  - math
  - logic
active: true

Frequently asked questions

Are comments preserved?
No. YAML comments are dropped during parsing and not re-emitted. If preserving comments matters, edit the YAML file directly with an editor that respects them.
Is my YAML safe from arbitrary code execution?
Yes. The parser uses safe-load mode, which only resolves the YAML 1.2 core schema — no custom tags, no JavaScript objects, no remote includes.
What about anchors and references?
Anchors (&id) and aliases (*id) are expanded inline. The formatted output contains the dereferenced value at each use site, not the original alias.
Why does the output use block style instead of flow style?
Block style ([key: value] across multiple lines) is the most readable form and matches what most teams check into git. If you need flow style, set the relevant js-yaml options in a custom build.

Related tools