YAML prettify and format

Prettify your YAML string into a friendly, human-readable format.

Enable JavaScript to use the interactive tool. The guide below explains how it works.

YAML Viewer

What it does

The YAML Viewer validates, cleans and re-formats YAML. Paste any YAML and it returns a tidy version with consistent indentation, optionally with all keys sorted alphabetically. Invalid YAML is flagged with a message.

Why someone uses it

Step-by-step instructions

  1. Paste your YAML into the input box (it is remembered in your browser for next time).
  2. Choose Indent size (1–10 spaces).
  3. Turn on Sort keys if you want alphabetical ordering.
  4. Copy the cleaned YAML from the output.

Examples

Input (messy, mixed indentation):

server:
    port: 8080
    host: localhost
app:
        name: demo

Output with 2-space indent:

server:
  port: 8080
  host: localhost
app:
  name: demo

With Sort keys on, app would be listed before server, and host before port.

Understanding the results

The output is produced by parsing your YAML and writing it out again, so it represents the same data with normalised formatting. Sorting keys changes the order of mappings but never the order of list items, because list order is meaningful. Because the document is re-serialised, comments and some stylistic choices (such as quoting style) may not survive. If the input cannot be parsed, the message "Provided YAML is not valid." appears and the output stays empty.

FAQs

Common mistakes

Use cases

Related tools

All tools

Guides and articles