YAML Formatter & Validator

Format, validate, and beautify your YAML online. Instantly highlights syntax errors with line numbers. Free and runs entirely in your browser.

How to Use

  1. Paste your YAML into the input area
  2. Click Format to beautify and validate
  3. If the YAML is invalid, an error message will show the exact line and problem
  4. Adjust the indent selector to control output indentation
  5. Click Copy to copy the formatted result, or Clear to reset

Frequently Asked Questions

  • What is YAML validation?

    YAML validation checks that your document follows correct YAML syntax — proper indentation, no duplicate keys, valid data types, and correct use of special characters.

  • Does formatting change my data?

    No. Formatting only changes whitespace and indentation. The data structure and values remain exactly the same.

  • What are common YAML syntax errors?

    Common errors include inconsistent indentation (mixing tabs and spaces), missing colons after keys, unquoted strings containing special characters like : or #, and duplicate keys.

  • Is my YAML sent to a server?

    No. All formatting and validation happens entirely in your browser using the js-yaml library. Your data never leaves your device.

  • What is the difference between YAML and JSON?

    YAML is a superset of JSON that supports comments, multi-line strings, and is less verbose. JSON uses braces and quotes, while YAML uses indentation. YAML is commonly used for config files, JSON for APIs.

What Is YAML?

YAML (YAML Ain't Markup Language) is a human-readable data serialization format designed to be easily written and read by humans. Where JSON uses braces and quotes, YAML uses indentation and minimal punctuation to represent the same data structures.

A key that looks like this in JSON:

{"database": {"host": "localhost", "port": 5432}}

...looks like this in YAML:

database:
  host: localhost
  port: 5432

The difference in readability becomes significant when configurations grow large.

Why YAML Validation Is Important

YAML's flexibility is also its biggest pitfall. The format has many quirks that can cause silent bugs:

Indentation sensitivity: YAML uses spaces (never tabs) for structure. A single misaligned line can change the meaning of an entire document without causing an obvious error.

Implicit type coercion: YAML attempts to infer types automatically. The value yes becomes the boolean true. The value 1.0 becomes a float. The Norwegian country code NO can become false in some parsers. These implicit conversions are a notorious source of bugs in configuration files.

Special characters in strings: Colons, hashes, and brackets have special meaning in YAML. Strings containing these characters must be quoted or they'll cause parse errors.

Duplicate keys: Some YAML parsers accept duplicate keys silently, keeping only the last value — a dangerous behavior that is hard to detect without explicit validation.

Where YAML Is Used

YAML is ubiquitous in modern infrastructure:

  • Docker Compose: docker-compose.yml defines multi-container applications
  • Kubernetes: All resource definitions (Deployments, Services, ConfigMaps) are YAML files
  • GitHub Actions: Workflow files in .github/workflows/ are YAML
  • Ansible: Playbooks and inventory files use YAML
  • CI/CD: GitLab CI, CircleCI, and most other platforms use YAML for pipeline configuration
  • Application config: Rails, Spring Boot, and many frameworks use YAML for environment configuration

Indentation Best Practices

The YAML specification recommends 2-space indentation. While the spec technically allows any consistent number of spaces, 2 spaces is the dominant convention across Kubernetes, GitHub Actions, and most other ecosystems. Avoid 4-space or tab indentation unless your toolchain requires it.