Logo

MonoCalc

/

YAML Prettier

Programming
Runs entirely in your browser
Your document is parsed and re-printed locally. Nothing is uploaded, logged or sent to a server, so manifests carrying cluster names, internal hostnames or image registries are safe to paste.
yes / no stay strings

Load a sample:

2 spacesdashes indentedfold at 80YAML 1.2quotes preservedorder preservedcomments kept
Valid YAML 1.2 · 1 document

13 keys, 4 sequence items, max depth 5.

YAML input

Formatted YAML

Errors and warnings

SeverityPositionWhat happened
warningline 2, col 1

Key "on" means different things in YAML 1.1 and 1.2

on: {push: {branches: [main]}}
^

YAML 1.1 resolves on to the boolean true, while YAML 1.2 core keeps it as the string "on". This is the "Norway problem": the country code NO becomes false. It is also why a GitHub Actions workflow's `on:` key is a boolean under 1.1. Quote it to pin it down.

Documents

1

LF line endings

Structure

13 keys

4 items · depth 5

Size

229 B 210 B

−8.3% · 12 12 lines

Anchors

0

0 aliases · 0 comments

Key paths

Dotted paths for yq queries and Helm --set arguments.

nameon.push.branches[0]jobs.build.runs-onjobs.build.steps[0].usesjobs.build.steps[1].namejobs.build.steps[1].runjobs.build.steps[2].namejobs.build.steps[2].run

Same thing from a script

yq -P -I 2 '.' input.yaml

Close, not identical: yq drops comments and applies its own quoting rules.

About This Tool

YAML Prettier - Format, Validate and Beautify YAML Online

YAML is the configuration language of modern infrastructure. Kubernetes manifests, GitHub Actions workflows, docker-compose.yml, Ansible playbooks, GitLab CI pipelines, OpenAPI specifications, Helm values files and Home Assistant configs are all YAML, which means developers read and write far more of it than they ever intended to. It is also uniquely unforgiving: whitespace carries meaning, so a single stray tab, a mis-aligned dash or a key indented two spaces too far turns a working manifest into a parse error - and the error usually points at a line some distance from the actual mistake.

This YAML formatter parses your document into a node tree that keeps every comment, anchor and source position, applies the style you choose, and re-prints the whole thing from that tree. Because the output is generated from the parsed structure rather than by patching whitespace, indentation, quoting and block style come out consistent no matter how the input was written.

What the formatter fixes

Beautify mode normalises indentation to your chosen width, repairs runaway nesting, explodes flow collections such as {push: {branches: [main]}} into readable block style, tidies comment placement, strips trailing whitespace and collapses runs of blank lines. Minify mode does the opposite, collapsing the document to compact flow style like {server: {host: localhost, ports: [80, 443]}} so it fits in a single environment variable, a --set-string Helm argument or a JSON field.

The full YAML 1.2 grammar is supported: block and flow collections, anchors (&name), aliases (*name), merge keys (<<:), explicit and application-specific tags, literal (|) and folded (>) block scalars with their chomping indicators, multi-document streams, directives, complex keys and non-ASCII content.

Finding the real syntax error

Validate mode reports every problem with its exact line and column, a caret pointing at the offending character, and a plain-English explanation of the rule that was broken - tab character used for indentation, duplicate key, all mapping items must start at the same column - instead of a generic “invalid YAML”. Tabs come with a one-click conversion to spaces, and duplicate keys cite both line numbers, since a silently discarded duplicate is the single most common reason a config change appears to do nothing.

The Norway problem
Under YAML 1.1 the unquoted scalars yes, no, on, off, y and n resolve to booleans, so the country code NO becomes false and a GitHub Actions on: key is technically a boolean. YAML 1.2’s core schema keeps them as strings. Version-like values are just as sharp: unquoted 1.10 is a float, so it silently becomes 1.1. Every one of these is flagged with a quick fix that quotes it.

Converting between YAML and JSON

Conversion runs in both directions with key order preserved. Going to JSON, aliases are resolved, <<: merge keys are applied, and a multi-document stream becomes a JSON array with one entry per document. Integers larger than JavaScript can hold are kept exactly rather than being pushed through a float. Coming from JSON, the result is idiomatic block-style YAML at your chosen indent and quote style, and NaN, Infinity and malformed input are reported with the position of the problem.

Team style, anchors and multi-document streams

Indent width and whether block sequence dashes sit under their parent key are the two things teams argue about most, so both are configurable, along with quote style, null spelling, document markers and boolean normalisation. One-click presets cover Prettier defaults, Kubernetes, GitHub Actions, Ansible, docker-compose and OpenAPI. Key sorting is available alphabetically, in reverse, or recursively, but defaults to preserve order, because order is semantically meaningful in CI configs - and the tool warns you when the document looks like one.

Anchors and aliases are preserved by default and listed in a usage table showing where each is defined and referenced, or they can be expanded inline to reveal the fully resolved document. A ----separated stream, the normal shape of a kubectl apply -f bundle, is split into individually formatted documents, each labelled with its Kubernetes kind/name where one is detectable, with its own copy button. A key path explorer produces dotted paths such as spec.template.spec.containers[0].image for yq queries and Helm --set arguments.

Your meaning is protected
After re-printing, the formatter parses its own output again and compares the resulting data with the input. If the two do not match, the output is suppressed and an error is shown instead of handing you a document that no longer says what you wrote.

Private by design

Most online YAML formatters POST your document to a remote endpoint, which is unacceptable when the file contains cluster names, internal hostnames, image registries, service topology or a secret nobody remembered to strip. Everything here happens in your own browser tab: no upload, no round-trip, no logging. Diff mode shows a line-by-line comparison so a reviewer can confirm a change is whitespace-only, and the error list exports as CSV for a code review or a ticket.

Frequently Asked Questions

Is the YAML Prettier free?

Yes, YAML Prettier is totally free :)

Can I use the YAML Prettier offline?

Yes, you can install the webapp as PWA.

Is it safe to use YAML Prettier?

Yes, any data related to YAML Prettier only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

How does this YAML formatter work?

Your document is parsed in the browser into a node tree that keeps every comment, anchor and source position, the style options you pick are applied to that tree, and it is re-printed from scratch. Because the output is generated from the parsed structure rather than by patching whitespace, indentation, quoting and block style all come out consistent no matter how the input was written.

Is my YAML uploaded anywhere?

No. Parsing and formatting are JavaScript running inside your own browser tab, with no server round-trip and no logging. That matters for YAML in particular, because manifests and pipeline files routinely carry cluster names, internal hostnames, image registries and the occasional secret nobody remembered to strip.

Will formatting change what my config means?

Not in Beautify mode. After re-printing, the tool parses its own output again and compares the resulting data with the input; if the two do not match, the output is suppressed and an error is shown instead. Only the options that deliberately rewrite values - boolean normalisation, anchor expansion and key sorting - can change the document, and each one says so.

Why does my file break when I indent with tabs?

YAML forbids the tab character for indentation, because a tab has no fixed width and nesting would then depend on the reader's tab stops. The tool reports the exact line and column of every offending tab and offers a one-click conversion to spaces at your chosen indent width.

What is the Norway problem?

Under YAML 1.1, the unquoted scalars yes, no, on, off, y and n resolve to booleans - so the country code NO becomes false. YAML 1.2's core schema keeps them as strings. The tool flags every one of these, and the version-like scalars such as 1.10 that silently become the number 1.1, with a quick fix that quotes them.

Can it handle multi-document files and anchors?

Yes. A stream separated by --- is split into individually formatted documents, each labelled with its Kubernetes kind and name where one is detectable. Anchors, aliases and << merge keys are preserved by default, listed in an anchor usage table, and can be expanded inline so you can see the fully resolved document.