YAML Formatter & Validator
Developer Tools
Format and validate YAML online. Detect syntax errors, pretty-print with custom indent, and convert JSON to YAML - all in your browser.
How to use this tool
- Paste YAML or JSON into the input panel, or open/drop a local .yaml or .yml file.
- Choose "YAML to format" or "JSON to YAML"; switching modes keeps your input in place.
- Choose 2- or 4-space indentation and block or compact flow output; key sorting is optional.
- Review the result or switch to JSON to inspect the parsed structure.
- Copy the displayed text or download the formatted YAML file.
What is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data serialisation format used extensively for configuration files: Docker Compose, Kubernetes manifests, GitHub Actions workflows, Ansible playbooks, and many more. Its whitespace-based syntax is easy to read and write, but a misplaced indentation or stray character will break the file entirely.
Why use a YAML formatter?
A formatter catches syntax errors before they reach production, normalises indentation so that YAML from different sources looks consistent, and makes deeply nested structures easier to read. This tool also lets you switch to the JSON view to confirm exactly what your YAML parser will see after loading the file.
JSON to YAML conversion
Many APIs return JSON. When you need to put that data into a YAML configuration file, manual conversion is tedious and error-prone. Select JSON to YAML, paste your JSON, and get a clean YAML representation instantly. Changing the input mode leaves the current text intact; use Load sample when you want to replace it with the built-in example.
Common YAML pitfalls
YAML's implicit typing is the source of many subtle bugs:
- Boolean ambiguity: in YAML 1.1 (used by PyYAML and many older parsers),
bare words like
yes,no,on,off,true, andfalseare parsed as booleans. In YAML 1.2 (stricter, used by newer parsers), onlytrueandfalseare booleans. - The Norwegian problem:
NO(the ISO 3166-1 alpha-2 country code for Norway) parses asfalsein YAML 1.1. Similarly,country: NOin a config file will silently becomefalsein PyYAML. Always quote strings that happen to match YAML keywords:country: "NO". - Numeric confusion: bare values like
1.0,1e3, and0x1Fare parsed as numbers. Phone numbers and version strings should be quoted.
Multiline string syntax
YAML provides two block scalar styles for multiline strings, each with three chomping options:
- Literal block (
|): preserves newlines exactly as written. Useful for shell scripts, SQL, or any text where line breaks are meaningful. - Folded block (
>): folds newlines into spaces (like reflowing a paragraph). Single blank lines become newlines in the output.
Chomping indicators control trailing newlines:
-
|-or>-- strip: remove all trailing newlines. -
|or>- clip (default): keep exactly one trailing newline. -
|+or>+- keep: preserve all trailing newlines.
YAML anchors and aliases
YAML anchors and aliases let a document reuse content, reducing repetition in complex configurations. This section is a syntax primer: formatting parses and re-emits data with js-yaml, so it does not retain the original anchor, alias, or merge-key syntax.
-
&anchor-name- define an anchor on a value or mapping. -
*anchor-name- reference (alias) the anchored value. -
<<: *anchor-name- merge key: merge all key-value pairs from the anchored mapping into the current mapping (useful for shared defaults).
Example using merge keys in a Docker Compose-style config:
defaults: &defaults
restart: unless-stopped
logging:
driver: json-file
web:
<<: *defaults
image: nginx:alpine
ports:
- "80:80"
api:
<<: *defaults
image: node:20
ports:
- "3000:3000"
Formatting also removes comments because comments are not part of the parsed data model. If comments or the exact anchor structure matter, keep the original in a text editor and avoid replacing it with a formatter round-trip.
Open and save YAML files
Open a local .yaml or .yml file with the file picker, or drop one into
the input panel. Files up to 2 MB are read and parsed on your device. After reviewing the result,
choose Download YAML to save a formatted .yaml copy. The download
uses the opened file's name when available; pasted text downloads as
formatted.yaml.
Privacy
All processing runs in your browser using the open-source js-yaml library. Pasted values and opened files stay on your device; nothing is uploaded to a server. Downloaded output is created locally by your browser.
Frequently asked questions
What is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data serialisation format. It's widely used for configuration files (Docker Compose, Kubernetes, GitHub Actions) and data interchange.
Does my data leave my browser?
No. Pasted text and YAML files you open are parsed and formatted in your browser with js-yaml. Inputs and file names are not sent to a server; downloaded output is saved by your browser to your device.
Can I convert JSON to YAML?
Yes. Switch to "JSON to YAML" mode, paste valid JSON, and the tool will output the equivalent YAML with your chosen indentation.
Can I open and download YAML files?
Yes. Open or drop a local .yaml or .yml file up to 2 MB. The file is read in your browser, and Download YAML saves the formatted YAML locally.
Are YAML comments and anchors preserved?
No. Formatting parses and re-emits the document with js-yaml, so comments are removed and anchors, aliases, and merge keys are expanded. Use a text editor if their original syntax must be kept.
What YAML version does this support?
This tool uses js-yaml and formats a single YAML document at a time. Separate documents marked with --- before formatting. Its parser implements YAML 1.2 with broad compatibility for common YAML 1.1 configuration values.
Related tools
- JSON ↔ YAMLConvert in either direction when another tool or service requires JSON or YAML.
- JSON FormatterFormat or validate JSON data maintained beside a YAML configuration.
- XML FormatterReformat XML configuration or API documents with readable indentation.
- HTML FormatterClean up HTML templates from the same application project as your YAML settings.
- CSS FormatterFormat stylesheets from the front-end project that consumes these settings.
- JS FormatterReformat application code while reviewing the configuration that controls it.
- Text DiffCompare the original and formatted YAML before saving the changed document.