JoyToolsJoyTools

YAML Formatter

100% Client-Side Private — Zero Server Uploads

Format and validate YAML documents. Convert between YAML and JSON effortlessly, all in your browser.

🔒 100% Client-Side: All data is processed locally in your browser and never leaves your device (Zero Server Uploads).
E-E-A-T Security Proof →
Interactive Workspace
556 chars
Share & Developer Embed

How do I use YAML Formatter?

1

Paste your Kubernetes manifest, Docker Compose file, or GitHub Actions YAML into the editor, or click 'Sample'.

2

Choose your indentation width (2 Spaces or 4 Spaces), enable Sort Keys if desired, or switch to 'To JSON' mode.

3

Inspect any YAML 1.2 indentation or tab errors with exact line numbers, then copy the normalized output.

What features does YAML Formatter offer?

Format and validate YAML syntax

Bidirectional YAML ↔ JSON conversion

Indentation and sorting controls

100% client-side local browser processing

YAML 1.2 Specification, Indentation Rules & The 'Norway Problem'

YAML relies on spaces (never hard tabs) for hierarchy and differentiates between YAML 1.1 and YAML 1.2 scalar type coercion rules.

YAML 1.2 Scalar Styles & Special Syntax Reference
YAML ConstructSyntax TokenNewline / Escape BehaviorTypical DevOps Use Case
Literal Block Scalar| (Pipe)Preserves internal newlines; clip/strip trailing via |- or |+Embedded bash scripts in GitHub Actions
Folded Block Scalar> (Greater-than)Folds single newlines into spacesLong multi-line descriptions in K8s
Anchor & Alias&base / *baseReuses a node reference across mappingsDRY environment blocks in docker-compose.yml
Quoted Scalars"22:20" or 'NO'Forces string type; prevents sexagesimal/boolean coercionCountry codes ('NO') & port mappings

Frequently Asked Questions about YAML Formatter

Why does YAML throw a syntax error when I indent with the Tab key?

The YAML 1.2 specification strictly forbids hard tab characters (`\t`) for structural indentation because different editors render tab stops at different widths (2, 4, or 8 spaces). Always indent YAML with spaces.

What is the YAML 'Norway Problem' (`NO: false`) and how does YAML 1.2 fix it?

Under legacy YAML 1.1, unquoted strings like `no`, `yes`, `on`, and `off` were coerced into booleans, turning Norway's ISO country code `NO` into `false`. Our `js-yaml` YAML 1.2 engine only treats `true` and `false` as booleans, though quoting `'NO'` remains best practice.

How are YAML anchors (`&`) and aliases (`*`) handled when converting YAML to JSON?

Because JSON has no native pointer syntax, converting YAML to JSON automatically dereferences and expands all `*alias` nodes inline with the full content of their target `&anchor`.

What is the difference between `|` and `|-` in multi-line YAML strings?

The pipe `|` (literal clip) keeps a single trailing newline at the end of the block, whereas `|-` (literal strip) removes all trailing newlines—which is critical for Kubernetes Secret values and CI tokens.