Skip to content
SmaftyTools

YAML Formatter

Format and validate YAML, or convert between YAML and JSON. Free online YAML formatter for configs, pipelines and Kubernetes files.

About YAML Formatter

The YAML Formatter is a free yaml formatter and yaml validator that reformats YAML with consistent indentation and converts in both directions between YAML and JSON. It's built for the files developers and DevOps engineers actually touch day to day: Kubernetes manifests, GitHub Actions and GitLab CI pipelines, Docker Compose files, Ansible playbooks and application config.

YAML's whitespace sensitivity makes it uniquely easy to break — a single misaligned space, a tab character where a space was expected, or an inconsistent indent level between siblings can take down a deployment with an error message that doesn't point at the real problem. Paste your file here to validate it instantly and get a specific, line-referenced error message the moment something's wrong, well before it reaches your cluster or pipeline. It's especially useful right before a kubectl apply or a CI pipeline run, when a single bad indent would otherwise only surface as a cryptic runtime error after the deploy has already started. The yaml to json and json to yaml converters solve a different, equally common problem: a tool or API expects JSON but your source of truth is YAML, or vice versa, and hand-converting nested structures is slow and error-prone.

The parser correctly handles YAML features that trip up naive converters: anchors and aliases (&ref / *ref) for reusing blocks, multi-line string styles (| for literal blocks, > for folded), and deeply nested maps and sequences. Because valid JSON is already valid YAML, JSON to YAML conversion always succeeds; going the other way requires real parsing, since YAML's indentation-based syntax and extra features (anchors, comments, multiple document markers) don't exist in JSON.

Parsing and conversion happen locally in your browser, so infrastructure configs and secrets embedded in them stay private.

How to Use the YAML Formatter

  1. Pick a mode: Format YAML, YAML → JSON, or JSON → YAML.
  2. Paste your document into the input pane.
  3. Fix any reported syntax errors, then copy the formatted result.

Features

  • YAML validation with clear, specific error messages
  • Consistent re-indentation of messy YAML
  • Two-way YAML ↔ JSON conversion
  • Handles anchors, multi-line strings and nested structures

Examples

Validating and reformatting messy YAML

Input

name: api
ports:
 -   80
 -  443
env:
    DEBUG: "false"

Output

name: api
ports:
  - 80
  - 443
env:
  DEBUG: "false"

Converting YAML to JSON

Input

service: web
replicas: 3
tags:
  - prod
  - api

Output

{
  "service": "web",
  "replicas": 3,
  "tags": ["prod", "api"]
}

Frequently Asked Questions

Why does my YAML fail to parse?

The usual causes are inconsistent indentation (tabs are not allowed), a missing space after a colon, or unquoted special characters. The error message points at the offending line.

Is YAML a superset of JSON?

Effectively yes — valid JSON is valid YAML, which is why the JSON → YAML conversion always works. The reverse needs conversion because YAML's syntax (indentation, anchors) doesn't exist in JSON.

Can I convert a Kubernetes manifest between YAML and JSON?

Yes — kubectl and the Kubernetes API accept both formats, so you can paste a YAML manifest, convert it to JSON for tooling that expects it, or go the other way to make a JSON manifest easier to hand-edit.

Is the YAML Formatter free?

Yes, the YAML Formatter is completely free with no usage limits. No signup, no account and no installation required.

Is my data safe?

Yes. All processing happens locally in your browser using JavaScript — nothing you type is uploaded or stored on our servers.