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
- Normalising the indentation of a hand-edited manifest or pipeline file.
- Sorting keys so two configs can be compared without noise.
- Verifying that a YAML file parses before you commit or deploy it.
- Reading dense YAML generated by another tool.
Step-by-step instructions
- Paste your YAML into the input box (it is remembered in your browser for next time).
- Choose Indent size (1–10 spaces).
- Turn on Sort keys if you want alphabetical ordering.
- 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
- Will my comments stay? Do not rely on it; re-serialising may drop them, so keep an original copy.
- Does sorting keys change meaning? For most configuration it does not, but order can matter in some tools, so check before applying.
- Is my YAML stored? Only in your own browser's local storage, to restore your last input. It is not sent to a server.
- Can it validate against a schema? No, only YAML syntax.
Common mistakes
- Using tabs instead of spaces.
- Sorting keys in a file where order is significant.
- Assuming a successful format means the configuration is correct for its application.
- Pasting secrets and leaving them in local storage on a shared computer.
Use cases
- Preparing config for code review.
- Diffing two YAML files after sorting keys.
- Debugging indentation errors.
- Formatting examples for documentation.
Related tools
- YAML to JSON: Inspect data types explicitly.
- JSON to YAML: Generate YAML from JSON.
- Text Diff: Compare two formatted YAML documents.