Skip to content
cliplimeClipLime

Format and validate YAML

Paste YAML, get it re-indented and checked. Comments and values stay as you wrote them, and nothing leaves this tab.

Your text is processed in this tab and never uploaded

Options

On: key:, then an indented - item. Off: the dash lines up with the key.

Writes inline maps and lists as indented blocks.

Reorders every mapping. List order is never changed.

0 characters, 0 lines Your text stays in this tab.

Values are kept as written: 0755, 1e3, yes and 0x1F are not rewritten. Comments, anchors and block text are kept.

At a glance

What it does
Formats and validates YAML as you type, using YAML 1.2 syntax.
Layout options
2 or 4 space indent, list items under the key or level with it, long line wrapping, quote style, sorted keys, and block style for { } and [ ].
Values
Kept as written: 0755, 1e3, 0x1F, yes and 1.0 are not rewritten.
Kept
Comments, anchors and aliases, block text (| and >), and several documents in one file.
Errors
The line and column, the faulty line, and a likely cause such as a tab or a duplicate key.
Not checked
Schemas. It cannot tell you that a Kubernetes, CI or compose field is wrong.
Privacy
Runs in your browser tab. Your YAML is never uploaded.

How to do it

  1. 1

    Paste or load your YAML

    Paste into the left box, drop a .yaml or .yml file on it, or press Example.

  2. 2

    Choose a layout

    Pick the indent, whether list items sit under their key, how long lines wrap and which quotes to prefer. Turn on sorting if you want keys in order.

  3. 3

    Read the result

    The result updates as you type. A syntax error shows its line and column, the faulty line and a Go to line button.

  4. 4

    Copy or download

    Copy the result or download it as formatted.yaml.

What formatting does to a YAML file

The formatter reads the whole file, then writes it again with a consistent layout. The data stays the same. What changes:

  • Every level is indented by the same amount, with spaces. Lines that were indented in a mix of widths are made uniform.
  • Spacing is tidied: one space after a colon and one before a trailing comment.
  • Runs of blank lines become one blank line.
  • Inline collections get spaces inside the brackets, as in { a: 1 }. The Expand option writes them as indented lines instead.
  • A plain value that continues over several lines is joined into one line. It means the same.

What stays: comments, anchors (&name) and aliases (*name), block text written with | or >, tags, and the order of keys and list items. A file with several documents separated by --- stays several documents.

Why your values are not rewritten

YAML tools do not agree on what a plain value means. The text 0755 is the octal number 493 to a YAML 1.1 parser and the decimal number 755 to a YAML 1.2 parser. yes and NO are booleans in 1.1 and plain text in 1.2. 22:22 can be a base 60 number in 1.1.

A formatter that reads values as numbers and writes them back would turn 0755 into 755 and 1e3 into 1e+3, silently changing a config file that another tool reads. This one treats every plain value as text and writes the same text back, so a file mode, a version or a port mapping is never altered.

The YAML validator page lists the values in your file that different YAML versions read differently.

Common YAML mistakes

  • Tabs for indentation. YAML does not allow them. Use spaces.
  • Inconsistent indentation. Keys at the same level must start in the same column, and children must be indented more than their parent.
  • A colon and a space inside a value. title: Note: read this is an error. Put the value in quotes.
  • No space after the colon. key:value is valid YAML, but it is one text value, not a key with a value.
  • Duplicate keys. The same key twice in one mapping. Most loaders keep only the last.
  • A value that starts with a special character. Values that start with @, a backtick or % need quotes.
  • An alias with no anchor. *name must refer to a &name defined earlier.

Sorting, wrapping and quote style

Sort keys reorders every mapping A to Z. The order of mapping keys carries no meaning in the YAML specification, but some tools and people rely on it, so check before you sort a file that others read. List order is never changed. If sorting would put an alias before its anchor, the tool stops and tells you, because that would make the file invalid.

Long lines are never wrapped by default. Choose 80 or 120 to fold long text values at that width. The folded text means the same. Quotes can be kept as written, or normalised to double or single quotes where the value allows it.

Questions people ask

Does formatting keep my comments?

Yes. Comments are kept with the line or block they belong to. The space before a trailing comment is normalised to one space.

Why did my long line not wrap?

Wrapping is off by default, because folding changes how a file reads even though it means the same. Choose 80 or 120 under Long lines to fold long text.

Does it convert YAML to JSON?

No. It formats YAML as YAML. Mapping and list structure are kept, and values are written as the text you gave it.

Is tab indentation allowed?

No. The YAML specification forbids tabs for indentation. The tool reports the line and asks for spaces. Tabs inside a value are fine.

Can formatting change what my file means?

It should not. Structure, keys and values are kept. Some text is rewritten in an equivalent form: a value that continued over several lines is joined into one, an escape such as \u00e9 inside double quotes is written as the character, and quotes are normalised if you ask for it. Check the result before using it for something critical.

Is my YAML uploaded?

No. The YAML reader loads into your browser tab and runs there. Your text is never sent anywhere.