YAML Formatter
Format YAML documents.
About this tool
Paste YAML and get it rewritten with clean two-space indentation and expanded flow style. Key order is preserved, but comments are lost because the document is parsed and re-serialised.
How to use
How it works
The YAML is loaded into a data structure with js-yaml and dumped again with indent 2 and line width 100, without sorting keys. Inline maps like {k: v} are expanded into block style, and strings that YAML could misread (such as y or yes) are quoted.
Worked example
Messy indentation
- Input
- b: 2 a: - x - y c: {k: v}
- Output
- b: 2 a: - x - 'y' c: k: v
- Walkthrough
- Indentation is normalised, the flow map becomes a block, and y is quoted because it is a boolean in YAML 1.1.
Limitations
- Comments are dropped, as are anchors and aliases (they are expanded).
- Only a single document is supported.
- Invalid YAML returns an error instead of formatted text.
Questions
How do I format YAML?
Does it keep comments?
Does it sort keys?
Why was y quoted?
Features
- Two-space indent
- Key order kept
- Syntax errors reported
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Learn JSON - Full Crash Course for Beginners
freeCodeCamp.org
Solid JSON syntax and nesting basics for formatter and validator tools.
Watch on YouTubeInspect Network Activity - Chrome DevTools 101
Chrome for Developers
Debugging payloads you paste into JSON and JWT tools.
Watch on YouTube
- Working with JSON
MDN
Parse and stringify patterns that pair with browser-side JSON tools.
- Introduction to JSON Web Tokens
jwt.io
JWT structure for decoder and debugger pages.