YAML Formatter - Pretty Print, Minify, Validate & Convert with JSON
Pretty Print / Minify / Validate (with Error Location) / YAML↔JSON
About the Online YAML Formatter
This tool is built on the yaml library (YAML 1.2 spec) and supports YAML/YML pretty-printing, compression to a single-line JSON, syntax validation (with line/column error locations), and two-way conversion between YAML and JSON. YAML (a recursive acronym for "YAML Ain't Markup Language") expresses hierarchy through indentation, making it more readable than JSON and widely used for configuration files. Everything runs locally in your browser—your data is never uploaded to any server. After formatting, you can continue inspecting the structure with JSON Formatter, or cross-check data validity with JSON Validator.
Features Explained
YAML Pretty-Print
Re-layouts messy YAML/YML text with the chosen indentation (2 or 4 spaces) so the hierarchy becomes clearly readable. Ideal for reviewing and editing config files such as Docker Compose (docker-compose.yml), Kubernetes manifests, and GitHub Actions workflows (.github/workflows/*.yml).
YAML Compression
Compresses multi-line YAML into a compact single-line JSON, stripping comments and whitespace to reduce file size for network transfer or embedding in API requests. After compressing, you can convert it back to YAML with JSON→YAML.
YAML Validation
Checks whether YAML follows the syntax rules. If errors exist—such as inconsistent indentation, mixing tabs and spaces, a missing space after a colon, or illegal characters—the tool returns the specific error message and its location so you can fix it quickly. We recommend validating CI/CD config files before committing them.
YAML & JSON Conversion
Supports two-way conversion between YAML→JSON and JSON→YAML. After converting YAML to JSON, cross-verify the data structure with the JSON Validator; converting JSON to YAML is handy for turning API responses into more readable config-file format.
Frequently Asked Questions
How do I check YAML indentation errors?
Just use the Validate button on this page. Common indentation mistakes include mixing tabs and spaces (YAML only allows spaces for indentation) and inconsistent indent levels (for example, mixing 2-space and 4-space indents). YAML is extremely sensitive to indentation—a single indent error can make the whole file fail to parse.
What happens when comments are lost after converting YAML to JSON?
This is expected—the JSON format does not support comments. Comments in YAML (content starting with #) are automatically dropped when converted to JSON. If you need to preserve notes in JSON, use a key-value pair instead, such as "comment": "some note".
What is the difference between .yml and .yaml files?
They are completely equivalent with no functional difference. .yaml is the extension YAML officially recommends; .yml is a leftover from older DOS systems that only supported 3-character extensions. This tool accepts both, so you can paste content from a .yml file directly.
Does it support multi-document YAML (--- separators)?
Yes. This tool parses multi-document YAML files separated by --- (common in Kubernetes resource manifests). After formatting, documents remain separated by ---. When compressing or converting to JSON, multiple documents are merged into a single JSON array.