YAML Beautifier

For files a person has been editing by hand: mixed tabs and spaces, indentation drifting by a column, list items wandering, Windows line endings pasted from a ticket. Paste the file, pick a layout profile, and get one consistent shape back with a list of everything changed.

YAML beautifier workspace

Profile
Your file0 lines
Rebuilt filewaiting
WaitingParse
0Documents
0Keys
0Nesting depth
0Longest line
Change log
  • Nothing to report until a file goes in.

A beautifier reads your file, then writes a new one

This is the part people get caught out by. Nothing here walks your text fixing indentation line by line. The file is parsed into real values, keys, lists, numbers, booleans, and then printed again from scratch using the profile you picked. The result is guaranteed consistent because it never saw your original spacing. The cost is equally absolute: anything the parser does not keep is gone from the output.

Comments do not survive. A YAML parser reads # lines as whitespace, so they never reach the value the printer writes back. If your file carries explanations your team relies on, keep the original open beside this page and paste your comments back in. The change log counts the comments in your input so the number never surprises you.

What a broken file usually looks like

Four problems account for most of the YAML people arrive here with, and all four come from editing by hand rather than from a generator.

What is in the fileHow it failsWhat happens here
A tab character in the indentationThe spec forbids tabs for indentation, so the parser stops with a message about a character not allowed in this contextLeading tabs are turned into spaces before parsing, and the line numbers are listed in the change log
CRLF line endingsUsually parses, then leaves stray carriage returns inside block scalars and quoted valuesThe browser normalises them to LF the moment text lands in the box, so the rebuilt file is LF only. Nothing to set
Indentation drifting by one columnA key silently lands under the wrong parent, so the config loads and behaves wrongly instead of erroringThe rebuild flattens every level onto your chosen indent, which makes the real structure visible
A byte order mark from NotepadParse error on line one pointing at a key that looks fineStripped silently before anything else runs

The third row is the dangerous one. A tab error stops your deploy immediately and you fix it in a minute. A key sitting one level too deep passes validation, ships, and turns up later as a setting nobody applied. Rebuilding the file is how you see where the parser thinks each key belongs.

Two indentation styles, both correct

Lists are the one place YAML tooling genuinely disagrees, and the disagreement is cosmetic. Both forms below parse to the same three item list.

Flush dashes, the kubectl style
ports:- name: http
port: 80
- name: metrics
port: 9090
Indented dashes, the Compose and Ansible style
ports:- name: http
port: 80
- name: metrics
port: 9090

Pick whichever matches the files already in your repository. Mixing the two inside one project is what makes diffs noisy, not the choice itself. The profile buttons set this along with the indent width, so choosing Kubernetes gives you flush dashes at two spaces, while Compose, Actions and Ansible give you indented dashes.

Sorting keys is a decision, not a cleanup

Alphabetical sorting is off by default here, which differs from most formatters. Sorted output is excellent for one job: comparing two versions of the same config, where key order noise hides the real change. It is bad for almost everything else. A Compose file reads image, then ports, then volumes because a person put them in the order you need them. Sorting moves build to the top and volumes to the bottom, and the next reviewer sees a rewritten file instead of a two line change.

Turn sorting on when you are about to diff. Leave it off when the file goes back into the repository.

Multi-document files stay multi-document

Kubernetes manifests routinely hold a Deployment, a Service and a ConfigMap in one file separated by ---. Each document is parsed and printed on its own, then joined back with the separators intact, so a bundle goes in and a bundle comes out. The document count in the gauges tells you how many the parser found, which is a quick way to catch a separator someone typed as -- or indented by mistake.

Anchors, aliases and the expansion switch

YAML lets you name a block with &defaults and reuse it with *defaults. Expansion is on by default, so every reference is written out in full. That makes the file longer and repeats the shared block, and it also makes the file readable by tools with partial YAML support, which is most non-Python ecosystems. Turn expansion off when you want the compact form back, and be aware the printer regenerates its own anchor names rather than keeping yours.

Where this tool stops

Your file never leaves the browser. Parsing, printing, copying and downloading all run in JavaScript after the page loads, so a manifest holding internal hostnames or a token is never sent anywhere. If you only want to know whether a file parses, the YAML validator reports errors without rewriting anything.

YAML beautifier questions

Comments, tabs, list indentation, sorting and the limits of a parse and reprint formatter.

Why did my comments disappear?

The file is parsed into data and printed again from that data, and a YAML parser treats comment lines as whitespace. They never reach the printer, so no output format can bring them back. Every parse and reprint formatter behaves this way, including the ones built into most editors. The change log counts the comments found in your input so you know how many to restore, and keeping the original file open in another tab is the practical workaround.

My file has tabs and nothing else will parse it. Will this?

Yes. YAML forbids tabs in indentation, which is why most parsers stop with an error about a character not allowed in that context. Leading tabs are converted to spaces before parsing here, using your chosen indent width, and the affected line numbers appear in the change log. A tab inside a quoted string value is left alone, because there it is legitimate content.

Should list dashes be indented or flush with the key?

Both parse identically, so it comes down to matching the files you already have. Kubernetes tooling emits flush dashes, while Docker Compose, Ansible and most GitHub Actions examples indent them. The profile buttons set the convention along with the indent width, and the toggle underneath overrides it if your repository does something else.

Why is key sorting turned off by default?

Because sorted output destroys the reading order a person chose. Config files are usually written so the important keys come first, and alphabetising moves them around for no benefit. Sorting earns its place in one situation, comparing two versions of the same file, where consistent order strips out noise. Turn it on before a diff and off again afterwards.

Does it handle several documents in one file?

Yes. Documents separated by three dashes are parsed and printed individually, then rejoined with the separators in place, which is the normal shape of a Kubernetes manifest bundle. The document count in the gauges shows how many were found, so a mistyped or indented separator is easy to spot.

Why does my CloudFormation template fail?

CloudFormation uses custom tags such as an exclamation mark followed by Ref or GetAtt. A standard YAML load has no definition for them and stops with an unknown tag error. The same applies to any dialect that adds its own tags. Those templates need a formatter that knows the dialect, since guessing at unknown tags would silently change what the file means.

Are quoted strings kept exactly as I wrote them?

Quotes are re-applied by the printer, not copied from your input. On the default setting quotes appear only where the value needs them, so a string wrapped in unnecessary quotes comes back bare. If a value must keep its exact text, a version number or a numeric string like an account code, quote it and check the result, or switch the quoting option to force quotes on every string.

Is my file uploaded anywhere?

No. The parser and printer run in your browser after the page loads, with no request carrying your input. Nothing is stored, and closing the tab clears both panes. That matters for manifests holding internal hostnames, image registries or credentials.