YAML Pretty Print

Reprint a YAML file with consistent indentation, a line width you choose, a single quoting style and optional spacing between sections.

YAML
Pretty printed YAML
Runs locally in your browser

About the YAML Pretty Print

Hand-edited YAML drifts. One block is indented by two spaces and the next by four, half the strings are quoted and half are not, and long values wrap in one place but not another. Reprinting the file from its parsed value removes all of that variation in a single pass, because every line is emitted by the same writer with the same settings.

Line width decides where long scalars fold onto a continuation line; pick Never wrap when a value such as a command line or a URL must stay on one line for grep to find it. Quote style fixes whether emitted strings use single or double quotes, and Quote every string puts quotes around all of them, which removes any doubt about whether a value will be read as a boolean or a number later. Sorting keys makes two files comparable, and blank lines between top-level keys give a long manifest visible sections.

Multi-document files are supported: each document is reprinted and separated with its own --- marker, and you can force that marker on a single document too when a downstream tool expects it. Comments are not carried over, since the loader drops them before the writer sees the data. For editing with live feedback rather than a one-off reprint, the YAML Editor is the better page, and YAML Validator answers the plain question of whether the file parses.

How to use

  1. Paste the YAML you want to tidy, or upload the file.
  2. Set the indent, line width and quote style your project uses.
  3. Turn on key sorting or section spacing if you want the file normalised further.
  4. Copy the reprinted document or download it as pretty.yaml.

Common questions

Why did my quoted numbers lose their quotes?
The writer quotes only what needs quoting. Tick Quote every string to keep quotes on every string value.
Does it keep my comments?
No. The document is rebuilt from parsed data and YAML loaders discard comments during parsing.
What does line width do to block scalars?
Long plain scalars fold at the chosen column. Literal blocks written with the pipe character keep their own line breaks.
Can it handle a file with several documents?
Yes. Every document is reprinted and separated by a --- line.