Code Formatting

YAML Formatter

Format and validate YAML, and convert it to JSON.

YAML input
Result

What is YAML Formatter?

YAML (YAML Ain't Markup Language) is a human-readable data serialization format commonly used for configuration files.

Features

  • Format: Beautify YAML with consistent indentation
  • Validate: Check YAML syntax
  • Convert to JSON: YAML to JSON conversion
  • Custom Indent: 1-8 spaces

Use Cases

  • Docker Compose files
  • Kubernetes configurations
  • CI/CD pipelines (GitHub Actions, GitLab CI)

Frequently Asked Questions

Why does YAML keep reporting indentation errors?
YAML expresses structure with indentation and is stricter than Python: spaces only (never tabs), and sibling nodes must align. Debugging tip: paste the suspicious region here and the validator points at the first broken line — 90% of the time a tab sneaked in or one level is off by a space.
When do values need quotes?
Whenever they contain special syntax: values starting with * & { } [ ] , # | > ! % @ ` , values containing ": ", leading/trailing spaces, and anything that should stay a string but looks like a number or boolean. Classic traps: 1.20 becomes the number 1.2, and NO becomes boolean false.
Can YAML and JSON be converted to each other?
Yes — YAML 1.2 is a superset of JSON. CI configs (GitHub Actions) and Kubernetes manifests frequently need round-trips; note that comments are lost converting to JSON, since JSON has no comment syntax.