YAML Formatter
Format, validate, and lint YAML in your browser — privately.
How to use YAML Formatter
- Paste YAML into the input panel on the left.
- Pick your indent (2 or 4 spaces) — YAML forbids tabs at the indent level, so only space widths are offered.
- Toggle `Sort keys` to alphabetize every mapping in the document at every depth.
- Toggle `Single quotes` to prefer `'...'` over `"..."` when strings need quoting.
- Adjust `Line width` (0 disables folding, 80 is the default) to control soft-wrap of long scalars.
- Press the Format button (or ⌘/Ctrl + Enter) to pretty-print. The output panel on the right updates with your formatted YAML.
- Use Copy output to grab the result, or Share to generate a URL that restores your session.
YAML Formatter
A keyboard-driven YAML formatter, validator, and linter that runs entirely in your browser. Paste raw YAML, get a clean, indented, validated document back. Sort keys for diffable output. Tune indent, line width, and quote style. Every transformation happens on your device; no payload ever leaves your browser.
Why another YAML formatter?
Most online YAML formatters do the work on a server. That's fine for toy documents, but nearly every real-world YAML file is a config — a Kubernetes manifest, a GitHub Actions workflow, a Helm values file, a Docker Compose declaration, a CloudFormation template. Those files routinely contain internal registry URLs, IAM roles, image digests, environment variables that were once secrets, and comments documenting trade-offs that nobody wants sitting in a third-party server log.
This page runs the parser locally. The page ships with the yaml (eemeli/yaml) reference-quality YAML 1.2 parser bundled into the client, and both the validator and the formatter go through it. No network call, no server log, no telemetry. Your YAML stays on your machine.
What it does
- Format: parse, then re-emit with your chosen indent (2 or 4), line width, and quote style. Output is always block-style for diff-friendliness.
- Validate: every keystroke re-parses the input and flips a badge to Valid YAML or Invalid. On failure, the error banner shows the exact line and column from the YAML parser.
- Sort keys: alphabetize every mapping in the document at every depth, including mappings inside sequence items. Ideal for generated manifests where stable key order makes diffs readable.
- Line-width control: 0 disables folding entirely (good for API keys or base64 blobs you don't want wrapped). 80 is the default. Higher values are allowed for wide-terminal workflows.
- Single vs double quotes: pick the style your style guide prefers. Strings that don't need quoting at all stay unquoted.
- Multi-document streams:
---separators are preserved. Paste an entirekubectl get ... -o yamldump and each document is formatted independently. - BOM stripping: files exported from Windows tooling often carry a leading UTF-8 byte order mark that breaks naive parsers; this tool detects and removes it before parsing.
Examples
Sort keys turns this:
z: 1
a: 2
nested:
z: 10
a: 20
into this:
a: 2
nested:
a: 20
z: 10
z: 1
Line width 0 keeps a long scalar on one line:
url: https://example.com/a/very/long/path/that/would/otherwise/fold?across=several&lines=yes
instead of YAML's default folded block form.
What's preserved, what isn't
Preserved: scalar types (numbers, booleans, null), key order (unless Sort keys is on), sequence order, explicit tags like !!str, multi-document --- markers, UTF-8 characters, nested structure.
Expanded: anchors (&name) and aliases (*name). The formatter resolves them into concrete values because JSON-shaped intermediate representations don't preserve reference identity. If you need byte-level fidelity of anchor syntax, use a source-preserving formatter instead.
Dropped: comments. YAML comments don't round-trip through the JavaScript object graph used internally. A comment-preserving mode is on the roadmap.
Privacy and performance
There is no analytics, no telemetry, no third-party script that touches your input. The Share button encodes a base64url snapshot of your input and settings into the URL fragment (#s=…), which by HTTP design is never sent to any server. Sharing a link is a peer-to-peer transfer of state.
The parser handles multi-megabyte documents comfortably; the bottleneck is textarea rendering rather than the parse itself. For hundreds-of-megabytes streams, use the yaml CLI directly — yaml < input.yaml > output.yaml — rather than forcing a browser textarea to render them.
Keyboard shortcuts
- ⌘/Ctrl + Enter — Format
The shortcut works even while focus is in the input textarea, because it includes a modifier key.
Related tools
- JSON ↔ YAML Converter — when you need to hop between the two formats.
- JSON Formatter — the same privacy-first treatment for JSON.
- JSON Minifier — compress JSON for production payloads.
Frequently asked questions
Is the YAML I paste sent to your servers?
No. Every transformation runs locally in your browser via the `yaml` (eemeli/yaml) parser bundled into the page. There is no YAML-handling endpoint on dev101.io — we deliberately avoid round-trips so your Kubernetes manifests, GitHub Actions workflows, Docker Compose files, and Helm values — which routinely contain image tags, environment variables, and endpoints you don't want indexed — never leave your device. The Share button encodes state into the URL hash, which by HTTP design is never transmitted to any server.
Why did my tab-indented YAML fail with "Tabs are not allowed as indentation"?
The YAML 1.2 spec forbids tabs at the indent level — only space characters count as indentation. This is one of the most common YAML traps, especially when converting from a tab-indented editor. The error banner shows the exact line and column so you can jump to the offending whitespace. Replace each leading tab with 2 or 4 spaces and re-format.
Are anchors and aliases preserved in the formatted output?
Aliases are expanded into concrete values when we re-emit. The formatter parses your input into a JavaScript object graph, then serializes that graph back to YAML — at that point `*name` references are resolved into the full value they reference, and any anchor that was never referenced is simply dropped. If you need to preserve structure-sharing syntax exactly, format with a source-preserving tool like `yamllint` or your editor's native YAML plugin; this tool optimizes for readability and roundtrip-safety, not byte-level fidelity.
What happens to comments when I format?
Comments are dropped. YAML comments aren't part of the data model — they live in the parse tree but don't survive a `parse → stringify` round-trip through the JavaScript object graph. A future "comment-preserving format" mode may be added using `yaml.parseDocument`, which retains comment nodes; today's formatter prefers the simplicity of a deterministic, data-equivalent output.
Does sorting keys recurse into nested maps and sequences?
Yes. With `Sort keys` enabled, every mapping in the document — at any depth, including mappings inside sequence items — is sorted alphabetically. This produces stable, diffable output ideal for generated manifests, rendered Helm templates, and any CI artifact where order should not be meaningful. Sequence element order itself is preserved; only map key order changes.
What does `Line width 0` mean?
A line width of `0` disables soft wrapping entirely, so long scalars are emitted on a single line regardless of length. This is useful when you need to paste the YAML into a system that doesn't tolerate folded block scalars (`>` style), or when you're copying a single-line API key, commit SHA, or base64 blob and don't want it broken across lines. The default is 80 — matching most editors' ruler — and you can go as high as 200 for wide terminals.