Help
  • YAML uses spaces, not tabs, for indentation; indent width can be set to 2 or 4 spaces
  • Check "Keep comments" to preserve original comments during formatting
  • Preserves high-precision numbers

YAML Formatter

This free online YAML formatter formats, minifies, and validates YAML, making it easier to read and debug — in one click.

All tools on this site run entirely in your browser locally. No data is uploaded to any server.

Features:

  • Format YAML: Auto-format indentation (2 or 4 spaces, 2 by default), fix nesting structure, support folding/expanding nodes
  • Keep comments: When enabled, original comments are preserved (including trailing comments); the setting is remembered; in compact mode, comments are dropped
  • Compact mode: Converts objects/arrays to flow-style (inline) format, smaller size for comparison
  • Syntax validation: Real-time syntax error hints after input, helps locate indentation or colon issues
  • YAML validation: Click Validate to check for syntax, indentation, duplicate keys, boolean typos, trailing whitespace, long lines, comments, and trailing blank lines.
  • Local files: Drag and drop or select local YAML/YML files
  • Number preservation: Formatting and minifying keep numbers exactly as written, so 1.0 never becomes 1, and long integers like 123456789012345678901234567890 are neither converted to scientific notation nor rounded
  • Real-time processing: Auto-formats on input, or manually click the format button to reformat
  • Export results: One-click copy, save as file, with search, jump to line and fullscreen view

FAQ:

  • Q: The left pane formats as I type. What is the Format button for?
    A: Every edit on the left is formatted automatically and written to the right pane. Format reads the right pane instead, so you can tidy text you've edited there or expand minified inline collections back into indented blocks. Minify, Validate and Save all work on the right-hand text too.
  • Q: Why are my comments missing even with "Keep comments" checked?
    A: That option uses a comment-aware parser. When it meets syntax it can't handle, you'll see "Current content does not support keeping comments" and formatting falls back to normal mode, which drops comments. If the YAML itself is invalid, the right pane shows the parser's error with a line number and a snippet. Inline [] and {} collections are expanded into indented blocks in this mode. Minify never keeps comments, even when the box is checked — it reports "Minified (comments not kept)".
  • Q: Will formatting change 1.0, 1e3 or very long integers?
    A: No. Numbers whose written form would change are swapped for placeholders before parsing and restored afterwards, so 1.0 stays 1.0, 1.50 stays 1.50, 1e3 stays 1e3, and a 30-digit integer keeps every digit instead of turning into scientific notation. Both Format and Minify apply this protection.
  • Q: What does Minify change, and can I get the indented layout back?
    A: Nested objects and sequences become inline {} and [] form and lines are no longer wrapped; top-level keys still appear one per line, and the indent width follows the Indent setting. Documents separated by --- are processed individually and joined back with ---. Click Format to expand the output again, but comments lost during minifying can't be recovered.
  • Q: Why does the right pane show an error message instead of formatted YAML?
    A: It means the YAML has a syntax error and neither parser could format it. The right pane shows the parser's message with the line number and a short excerpt, then switches back to formatted output once the input is valid. Run Validate afterwards to check for style issues; clicking a row in the results jumps to that line.
  • Q: What does Validate check, and why does it sometimes report only one issue?
    A: Errors cover syntax problems, tabs and duplicate keys at the same level (with the line of the first occurrence). Warnings cover trailing spaces, indentation that isn't a multiple of two, lines over 120 characters, a missing space after #, boolean typos such as tru or flase, and missing or extra blank lines at the end of the file. Results are ordered by line and clicking a row jumps to it. A syntax error is reported on its own — fix it and run Validate again to see the rest. Duplicate keys are the exception and appear alongside the other issues.
  • Q: Are the indent and comment settings remembered?
    A: Yes. The 2 spaces or 4 spaces indent, "Keep comments", line wrapping and the divider position are stored locally in the browser. Changing the indent or the comment option reformats the current input straight away, with no need to click Format. Line wrapping only changes how the right pane displays text, not the output. Indentation is judged in multiples of two, so 4 spaces output won't be flagged by Validate.

Common uses:

  • Formatting and beautifying YAML config files (e.g., Docker Compose, Kubernetes, Spring Boot)
  • Troubleshooting YAML indentation or syntax issues and quickly locating the errors
  • Comparing config differences across versions; compact mode is ideal for diff
  • Organizing Ansible Playbooks, GitHub Actions and other YAML script files
  • Converting JSON results to YAML for use in configuration management tools