Skip to tool

YAML Formatter and Validator

Format and validate YAML, convert YAML to JSON, or paste JSON to get YAML. Errors show the line and column of the first problem.

Runs in your browser — your input is processed on this device and never uploaded.

Input

YAML to format and validate, or JSON to turn into YAML. Maximum 8 MiB. Duplicate keys are rejected. Comments and anchors are not preserved.

Result

Results appear here.

About this tool

On this page

What is a YAML formatter and validator?

YAML is a text format for nested maps, lists, strings and numbers. Config files use it because indentation is easier to type than JSON braces, but one wrong indent breaks the whole file. A YAML formatter parses the document, which validates it, and writes it back with consistent indentation.

This tool formats and validates YAML and shows the same data as JSON. Because JSON is valid YAML 1.2, you can also paste JSON here and copy the YAML version.

YAML formatter options

YAML or JSON
The document to format, up to 8 MiB.
Indent
Two spaces (the default) or four spaces, used for both the YAML and the JSON output.
Sort keys
Off by default, so mapping key order is kept. Turn it on to sort keys recursively when you want two files compared without order noise.
  • Duplicate mapping keys are rejected instead of silently keeping the last value.
  • Invalid YAML is refused with the line and column of the first problem. Each output is capped at 18 MiB.
  • Comments, original quoting and anchors are not preserved. The result is a parsed pretty-print, not a text beautifier.
  • One YAML document becomes one JSON value. Several documents separated by --- become a JSON array. An empty paste returns no YAML and JSON null.

Why pretty-print YAML instead of fixing indents by hand

A Kubernetes manifest with mixed tabs and spaces looks fine until the runtime rejects it. Hand-wrapped YAML hides nesting the same way minified JSON does: you cannot see which key owns a list, and a truncated paste looks valid until something downstream fails.

Format it with a stable indent and you can read the shape, copy a field, or drop the result into a diff. The JSON view is for tools that will not take YAML, and the YAML view is for configs you started as JSON.

Sorting keys is a separate job. Two maps that differ only in key order are equal to most programs and unequal in a text diff. Sorting makes the text match. It is not a cryptographic canonical form.

YAML formatter alternatives

JSON Formatter and Minifier is the better fit when you want JSON back out, and JSON Validator when you only need a yes or no on JSON. yq, Python's PyYAML and the format command in many editors do the same work locally. Use those when the file is already on disk or inside a pipeline.

Warning

Do not use the output as a comment-preserving rewrite of a Helm values file or any other file people annotate. Comments are dropped on purpose, and anchors are expanded.

Things to know about YAML formatting

YAML 1.1 treated on, yes and no as booleans, which surprised people who wrote flag: on and got true. YAML 1.2 does not do that, and this tool follows 1.2, so flag: on stays the string on.

The same rule works in reverse. Converting the JSON {"flag": "on"} writes flag: on without quotes, which is correct YAML 1.2. A YAML 1.1 reader such as PyYAML will read it as true, so quote those values by hand if one sits downstream.

Browse

Find similar tools by category or tag.