Free tool

YAML formatter, check it, tidy it, convert it.

Paste YAML or open a file. It is checked as you type, and a mistake shows its line and column in plain words. Format it with 2 or 4 spaces, sort the keys, or squeeze it into flow style. Comments, anchors, aliases and several documents in one file are kept, and numbers stay exactly as you wrote them. Turn it into JSON, turn JSON into YAML, or browse it as a tree with paths. Nothing is uploaded.

Input
Result

The formatted YAML shows here.

Paste on the left, open a file, or press Example.

Options

Keys

  • Cmd Enter Format
  • Cmd Shift Enter Flow style
  • Cmd S Download
  • Cmd Shift C Copy
  • / Search

Your YAML is read in your browser. It is never uploaded or saved, so keys and passwords in config files stay with you. Only your settings are remembered on this device.

How it works

Check, format, convert.

01 / Check

Errors with a place

The text is read as you type. A mistake is shown with its line and column, a plain explanation, and the lines around it.

02 / Format

Same meaning, tidy layout

Indent, line width, key order and brackets change. Comments, anchors, aliases, quotes and numbers stay as you wrote them.

03 / Convert

JSON, flow or a tree

See the same data as JSON, as one line of flow style, or as a tree with the path of every key.

Guide

How to format and validate YAML, without losing comments.

A YAML formatter rewrites a YAML file with steady indentation and spacing, and tells you if the file is not valid YAML. This one keeps your comments, anchors, aliases, tags and quote marks, shows the line and column of every mistake, and can turn the same data into JSON, or JSON into YAML. It reads YAML 1.2 by default and has a switch for the older 1.1 rules.

How to use it

  1. Paste YAML into Input, press Open file, drop a file on the box, or press Example.
  2. Read the line under the boxes. It says Valid YAML with the number of documents, keys and levels, or Not valid YAML with a line and column.
  3. Choose Indent (2 or 4 spaces) and Line width, and tick or untick the options on the right.
  4. Pick the view above the result: YAML, JSON or Tree. In the YAML view, Flow (minified) puts every list and mapping in [ ] and { } on one line.
  5. Press Download or Copy.

What stays and what changes

Stays as you wrote itCan change
Comments and blank lines (while Keep comments and Keep blank lines are ticked)The spaces before a comment shrink to one
Anchors (&name), aliases (*name), merge keys (<<) and tags such as !RefSpaces inside [ ] and { }, as the option says
Each string's quote marks, and numbers such as 0755, 1.50, +5 and 0x1FIndentation, and whether lists sit under their key
The order of keys, and several documents separated by ---Long plain strings wrap at the line width, and folded > text is re-flowed

Wrapping changes how the text is laid out, not the value: YAML reads the wrapped line back as one line. Choose No wrapping if you would rather it never wraps.

Worked examples

A number that must not change. In a Kubernetes file, value: 0755 is printed as 0755. The JSON view reads it by YAML 1.2, where it is the number 755. With YAML version 1.1 it is an octal number, 7 × 64 + 5 × 8 + 5 = 493.

The key called on. In a GitHub Actions workflow, on: is the key that holds the triggers. Under YAML 1.2 it is the text on, and the JSON view shows "on". Older YAML 1.1 readers, such as PyYAML, turn it into true.

Four real files. A Docker Compose file, a GitHub Actions workflow, a Kubernetes manifest with two documents and an OpenAPI file were formatted with every combination of indent 2 or 4, line width 80, 120 or none, lists indented or not, brackets padded or not, and as written, block or flow style. That is 72 results for each file, and reading each result back gave the same data as the original every time. The JSON view of all four matched what ruamel.yaml's YAML 1.2 reader gives. PyYAML differed on two of them, on and 0755.

Flow style. The 874 byte compose file becomes one line of 688 bytes, the 946 byte OpenAPI file one line of 764 bytes. Comments are dropped in flow style, since a comment cannot sit inside a single line.

Matching a list style. The Kubernetes sample writes - name: at the same column as its key. With Indent lists under their key ticked, 17 of its 43 lines change. Untick it and none do. The compose file and the OpenAPI file indent their lists, so the tick matches them.

Where the rules come from. The YAML 1.2 rules for true, false, null and numbers are in the YAML 1.2.2 specification, section 10.3 (core schema): only true and false are booleans, and an octal number is written 0o17. The YAML 1.1 rules are on its boolean and integer pages: y, yes, on and their opposites are booleans, and a leading 0 means octal. All were read on 19 Oct 2026.

Mistakes it finds

  • Tabs. YAML forbids a tab in the indentation. The error offers Replace tabs with spaces.
  • A repeated key. Two keys with the same name in one mapping are an error here, with the line of the second one.
  • A wrong indent, or a missing ] or }. The line and column point at the first place the reader got lost, which is sometimes the line after the real slip.
  • An alias with no anchor above it. *name must come after &name.

Sorting keys

Sort keys A to Z orders every mapping, with numbers in natural order (item2 before item10) and the merge key first. An anchor must stay above the aliases that use it, so a mapping that holds an anchor is left in its own order when the file also has aliases, and the line under the boxes says how many were left.

Limits

Custom tags such as !Ref and !Sub are kept in the YAML and left out of the JSON, since JSON has no tags. A key that is itself a list is written as a string in JSON. JSON with comments or trailing commas is not valid YAML or JSON, so use the JSON formatter, which can repair it. To format XML, see the XML formatter, and to compare two versions of a file, use the diff checker.

Questions

Good to know.

Is my YAML uploaded?

No. It is read and written in this tab and never leaves your computer, so keys and passwords in a config file stay with you. Only your option settings are remembered, never the text.

Does formatting remove my comments?

No. Comments stay where they were. They are removed only if you untick Keep comments, and always in flow style.

Can formatting change what my file means?

It changes layout, not data. Numbers keep the text you wrote, strings keep their quotes, and a wrapped line is read back as one line. The one choice that can matter is the YAML version in the JSON view, because 1.1 and 1.2 read words like yes and on differently.

How do I turn JSON into YAML?

Paste the JSON and look at the YAML view. JSON is valid YAML, so it is read as it is and written in block style, one item per line. Big whole numbers keep all their digits.

How do I turn YAML into JSON?

Press JSON above the result. Several documents in one file become one JSON list, and merge keys (<<) are expanded.

Why does it say a tab is not allowed?

YAML does not allow tabs for indentation, only spaces. Press Replace tabs with spaces in the error, then check the indent, since the depth of a line decides which key it belongs to.

What are anchors and aliases?

An anchor (&name) labels a value and an alias (*name) reuses it later, so you write it once. Docker Compose files use them with the merge key << to share settings.

What is the difference between YAML 1.1 and 1.2?

They read some plain words differently. In 1.1, yes, no, on and off are booleans and 0755 is an octal number. In 1.2 they are text and a plain number. Most tools today follow 1.2, and some older ones follow 1.1.