# YAML Formatter

URL: https://tools.otaku-dojo.com/en/yaml-formatter
Updated: 2026-10-03

The YAML Formatter checks YAML syntax, reports the line and column of any error and re-outputs the document with consistent indentation. It can also convert YAML to JSON or JSON to YAML in one click. It is handy for Docker Compose, Kubernetes and CI configuration files, and everything runs in your browser.

## How to use the YAML Formatter

1. Pick a mode: "Format YAML", "YAML → JSON" or "JSON → YAML".
2. Paste your content on the left, or press "Sample" to load a Docker Compose example.
3. The result appears on the right; on a syntax error the status bar shows the line and column.
4. Press "Copy" or "Download" to get the result.

## Specs & key facts

- **Spec**: YAML 1.2 (powered by js-yaml 4.3)
- **Modes**: Format YAML, YAML → JSON, JSON → YAML
- **Indentation**: 2 or 4 spaces
- **Errors**: Line and column of the error
- **Processing**: In your browser (nothing is uploaded)
- **Price**: Free, no sign-up

## Examples: YAML to JSON

```yaml
services:
  web:
    image: nginx:1.27
    ports:
      - "80:80"
```

→

```json
{
  "services": {
    "web": {
      "image": "nginx:1.27",
      "ports": [
        "80:80"
      ]
    }
  }
}
```

## FAQ

### What is the difference between YAML and JSON?

YAML uses indentation and supports comments, which makes it pleasant for hand-edited config files; JSON uses braces and brackets with strict syntax, which suits data exchange between programs. YAML 1.2 is a superset of JSON, so every valid JSON document is valid YAML.

### Are comments kept after conversion?

No. Comments are not part of the data, so they are dropped when converting or reformatting.

### Can it validate Kubernetes or Docker Compose files?

It validates YAML syntax, but it does not check whether Kubernetes or Compose field names and values follow their schemas.

### What about files with multiple documents (---)?

Only the first document is processed. Paste multiple documents separately.
