📋

YAML Formatter

Beautify or minify YAML, validate syntax, and convert between YAML and JSON. Runs entirely in your browser.

Updated July 11, 2026

100% Private & Secure

This tool runs in your browser.
Your data is never uploaded or stored.

1
1
Click an action button to see results

How to use

  1. 1

    Paste YAML or JSON into the input.

  2. 2

    Click Format, Minify, or Convert.

  3. 3

    Copy or download the result.

When to use it

Debugging a broken CI/CD pipeline config

GitHub Actions, GitLab CI, Ansible, and Kubernetes all read YAML. A misindented key silently changes semantics — a step meant to run inside a job can be parsed at the wrong nesting level. Formatting and validating surfaces structural problems before you push.

Normalizing a hand-edited YAML file

Different editors use different indentation widths and styles. Re-formatting produces a consistent, reviewable baseline so diffs reflect real changes rather than whitespace noise.

Switching between YAML and JSON

YAML is more pleasant for humans to write; JSON is easier for scripts to consume. Converting a YAML config to JSON feeds it into templating engines, validators, or API clients that expect JSON.

port: 8080\nhosts:\n - web1\n - web2 -> { "port": 8080, "hosts": ["web1", "web2"] }

Compressing YAML for transport

Minifying removes comments and collapses flow-style collections, shrinking a verbose config for inclusion in a build artifact or an environment variable.

How it works

Significant indentation and the tab error

Unlike JSON, YAML uses indentation to express structure — there are no braces or brackets in block style. Two spaces of extra indent on a line mean "this is a child of the line above." Get the indent wrong and you change the data model, not the cosmetics.

Per the YAML 1.2.2 specification (Section 5.5), YAML recognizes two whitespace characters: space and tab. Tabs are permitted inside scalar content and comments, but they must never be used for indentation. Mixing a tab into indented block context is one of the most common YAML errors — many editors silently insert tabs when you press Tab, and the parser rejects the file with a message that does not obviously point at whitespace.

  • Use spaces only — never tabs — for indentation
  • Be consistent: pick one indent width (2 spaces is the de facto standard) and stick to it within a file
  • A single extra space can move a key into the wrong parent without any syntax error

Scalars, collections, and anchors

YAML has two collection kinds: mappings (key: value pairs, like a JSON object) and sequences (dashed lists, like a JSON array). A scalar is a single leaf value — a string, number, boolean, or null. Scalars are mostly unquoted, but quoting matters for values that look like something else: version: 1.0 parses as a float, while version: "1.0" stays a string, and answer: "yes" avoids the YAML 1.1 boolean coercion that turned yes into true.

For reuse within a single document, YAML supports anchors and aliases. Define a block with &defaults and reference it elsewhere with *defaults. This is invaluable for DRY config (a shared service template referenced by multiple environments), though it cannot cross document boundaries.

# Mapping, sequence, scalar, anchor, alias — all in one
defaults: &defaults
  retries: 3
  timeout: 30
services:
  web:
    <<: *defaults      # merges the anchored mapping
    port: 8080
  db:
    <<: *defaults
    port: 5432

YAML is a strict JSON superset

A primary goal of YAML 1.2 was to make YAML a strict superset of JSON: every valid JSON document is also a valid YAML document, parseable to the same data model. That is why this tool can convert between the two losslessly — JSON is just YAML written in "flow style," with explicit braces and brackets and double-quoted strings.

The reverse is not always true. YAML features that have no JSON equivalent — comments, anchors and aliases, multi-document streams separated by ---, and tags — cannot survive a round-trip to JSON. Converting such a file to JSON strips those constructs, which is fine for handing config to a JSON-only consumer but destructive if you plan to edit the result as YAML later.

Common mistakes & edge cases

Problem

"found character that cannot start any token" or a tab indentation error

Fix

A tab character was used for indentation. YAML forbids tabs in indented block context — re-indent with spaces only, and configure your editor to insert spaces on Tab.

Problem

yes / no / on / off become true / false

Fix

YAML 1.1 coerces those bare words to booleans. Quote them ("yes") or migrate to a YAML 1.2-compliant parser, which drops that coercion.

Problem

A key silently lands under the wrong parent

Fix

Indentation defines nesting in YAML. Check that the key aligns with its intended sibling keys, not one level deeper or shallower.

Problem

"version: 1.0" comes back as a number instead of a string

Fix

Unquoted scalars are type-inferred. Quote the value ("1.0") to force it to stay a string.

Frequently Asked Questions

Can this convert JSON to YAML?
Yes. Paste JSON and click "To YAML" to convert.
What YAML features are supported?
Standard YAML 1.2 features including multi-line strings, anchors and lists.

References & further reading

Related reading

Related Tools

View all tools