YAML Formatter & Validator

Paste YAML to validate, beautify or minify it, or convert YAML ↔ JSON. Invalid input shows the exact parser error and line; multi-document files (---) are supported. Everything runs in your browser — nothing is uploaded.

Input
Output

How the YAML formatter works

The tool parses your text into an in-memory data structure with the open-source js-yaml library, then re-serialises it in the format and layout you asked for. Because parsing happens first, an invalid file is rejected up front and the parser’s error message — with the line and column where it failed — is shown, so the same tool validates, formats and converts. All of it runs client-side, so nothing is uploaded.

Beautify re-emits valid YAML in readable block style with your chosen indent; Minify switches to compact flow style (braces and brackets, like JSON on one line) that is still valid YAML; YAML → JSON and JSON → YAML convert between the two while preserving the values, types and structure exactly.

Beautify, minify, validate, convert

ActionWhat it does
BeautifyRe-indents and normalises valid YAML with your chosen 2- or 4-space indent, in readable block style.
MinifyCollapses the data into compact flow style (like JSON on one line) — smaller, still valid YAML.
YAML → JSONParses the YAML and outputs equivalent, pretty-printed JSON. Multiple documents become a JSON array.
JSON → YAMLParses JSON and outputs equivalent YAML in clean block style.
ValidateEvery action validates first — invalid input shows the exact parser error and line, so it doubles as a linter.

YAML vs JSON

YAML and JSON describe the same kinds of data — mappings, sequences, strings, numbers, booleans and null. YAML is a superset of JSON, so every JSON file is already valid YAML; the difference is the surface syntax and a few conveniences:

FeatureYAMLJSON
CommentsYes — lines starting with #No native comment syntax
SyntaxIndentation-based, minimal punctuationBraces, brackets, quotes and commas
Quotes on stringsUsually optionalAlways required (double quotes)
Multi-documentYes — separated by ---One value per document
Data modelSuperset of JSON (every JSON file is valid YAML)Strict subset of YAML
Typical useConfig files (Kubernetes, Docker Compose, CI, Ansible)APIs, data interchange, storage

YAML syntax quick reference

SyntaxMeaning
key: valueA mapping (key/value pair). The space after the colon is required.
- itemA sequence (list) item. Items at the same indent form one list.
nested:\n key: valueNesting by indentation — two spaces per level is conventional (never tabs).
"a string"Quoted string. Quotes are only needed when the value would otherwise be misread.
# commentA comment — ignored by parsers (and dropped when YAML is re-serialised).
---A document separator, so one file can hold several YAML documents.
| and >Block scalars: | keeps newlines (literal), > folds them into spaces.
&anchor / *aliasDefine a node once with &, reuse it with * to avoid repetition.

Common uses

  • Fix indentation in a Kubernetes, Docker Compose, GitHub Actions or Ansible file before committing it.
  • Validate a config file and find the exact line a parser is choking on.
  • Convert an API’s JSON response into readable YAML, or a YAML config into JSON for a tool that only accepts JSON.
  • Normalise hand-edited YAML so diffs stay small and consistent across a team.
  • Minify a config to embed it on one line (for example inside another YAML or a shell variable).

A note on comments

YAML comments (# like this) are not part of the parsed data, so — as with every library-based YAML formatter — they are not carried through the parse-and-re-serialise round trip. Keep a copy of the original if you need the comments; use this tool to validate, reshape or convert the data itself.

Privacy

Formatting, validation and conversion all happen locally in your browser. Your YAML never leaves your device, nothing is logged and there are no network requests — safe for config files that contain hostnames, secrets or other sensitive values. It keeps working offline once loaded.

Frequently asked questions

What does a YAML formatter do?
It reads your YAML, checks that it is valid, and re-writes it in a clean, consistent layout. Beautify re-indents everything to your chosen 2- or 4-space width in readable block style; Minify collapses it into compact flow style (like JSON on a single line) that is still valid YAML. Because both first parse the document, an invalid file is caught immediately and the exact parser error is shown — so the tool also works as a YAML validator and linter.
How do I convert YAML to JSON (or JSON to YAML)?
Paste your data and click “YAML → JSON” or “JSON → YAML”. The tool parses the source into an in-memory data structure and re-serialises it in the target format, so the values, types and structure are preserved exactly. YAML is a superset of JSON, so every JSON file is already valid YAML; converting the other way just uses YAML’s cleaner, indentation-based layout. If your YAML has several documents separated by ---, converting to JSON produces a JSON array of those documents.
Why did my comments disappear after formatting?
YAML comments (lines starting with #) are metadata for humans — they are not part of the parsed data. A formatter works by parsing the document into its data structure and then re-serialising it, and that round trip does not carry comments through. This is standard behaviour for every YAML library-based formatter, including this one. If you need to keep comments, edit the file by hand or use an editor plugin that preserves them; use this tool to validate, reshape or convert the data itself.
What are the most common YAML mistakes it catches?
The usual culprits are: using tabs instead of spaces for indentation (YAML forbids tabs), inconsistent indentation between sibling keys, forgetting the space after a colon (key:value instead of key: value), unclosed quotes or flow brackets, and mixing a mapping and a list at the same level. When any of these make the document unparseable, the tool shows the parser’s error message and the line and column where it gave up, so you can jump straight to the problem.
Does it support multi-document YAML files?
Yes. YAML files can contain several documents separated by a --- line (common in Kubernetes manifests). The formatter parses all of them: Beautify and Minify re-emit each document with the --- separators intact, and “YAML → JSON” returns a JSON array with one element per document. A single-document file is handled as a plain object, not wrapped in an array.
Is my YAML uploaded anywhere?
No. All parsing, formatting and conversion happen in your browser with the open-source js-yaml library — your data never leaves your device, nothing is logged and there are no network requests. It keeps working offline once the page has loaded, which makes it safe for configuration files that contain hostnames, secrets or other sensitive values.

Related tools

Explore more tools

Browse all 68 tools →