Home › Developer Tools › YAML Validator & Formatter

YAML Validator & Formatter

Paste YAML to check it instantly: errors are shown with their line and column and the faulty line is highlighted. Then pretty-print it, minify it, sort keys or convert it to JSON. Everything runs in your browser.

Last updated:

Loading the YAML engine…

Formatting re-writes the data, so comments are not kept in the result. Validation never changes your input.

Advertisement
Advertisement

How to use the YAML Validator & Formatter

  1. Paste YAML into the editor or press Upload to open a .yaml, .yml or .json file.
  2. Read the status bar: it says Valid YAML, or shows the line and column of the first error, with the line highlighted in red.
  3. Press Format YAML to pretty-print with your indent and optional sorted keys, or Minify for compact flow style.
  4. Convert with YAML → JSON, or paste JSON and press JSON → YAML.
  5. Copy or download the result from the right-hand box.

The most common YAML errors and how to fix them

Error messageTypical causeFix
bad indentation of a mapping entryA key is indented by a different number of spaces than its siblingsAlign keys at the same level to exactly the same column
end of the stream or a document separator is expectedText after a value on the same level, often a missing colon or an extra space before a keyCheck the line above the reported one for a missing :
duplicated mapping keyThe same key appears twice in one mapping; most parsers silently keep only the lastRemove or rename one of the keys
tab characters must not be used in indentationThe file was indented with tabsReplace tabs with spaces (2 per level is common)
unexpected end of the stream within a double quoted scalarAn opening quote without a closing quoteClose the quote, or escape inner quotes
incomplete explicit mapping pair; a key node is missedA value starting with ?, :, {, [, &, *, !, |, >, @ or % without quotesQuote the value, for example pattern: "*.log"

YAML syntax cheat sheet

FeatureYAMLJSON equivalent
Mappingname: app{"name": "app"}
Sequence- a
- b
["a", "b"]
Flow style{a: 1, b: [x, y]}{"a": 1, "b": ["x", "y"]}
Literal block (keeps line breaks)script: |
  line 1
  line 2
"line 1\nline 2\n"
Folded block (joins lines)text: >
  one
  two
"one two\n"
Anchor and aliasbase: &b {x: 1}
copy: *b
The aliased value is repeated
Null~, null or an empty valuenull
Comment# noteNot supported in JSON
Several documents--- between documentsAn array of documents

Tips for configuration files

  • Quote ambiguous values. Version numbers like 1.10 become the number 1.1, and times like 22:30 may be read as numbers by YAML 1.1 parsers. Write "1.10" and "22:30".
  • Keep indentation consistent. Pick 2 spaces per level and configure your editor to insert spaces when you press Tab.
  • Watch list items under a key. In Kubernetes, Docker Compose and GitHub Actions, both key: followed by - item at the same column and indented by two spaces are valid, but mixing the two styles in one file makes mistakes easy.
  • Validate before you deploy. A syntax check here catches structural errors; tools such as kubectl apply --dry-run=client or docker compose config then check the content against their own schema.

Frequently asked questions

What does the validator check?

It parses the text with js-yaml, a YAML 1.2 parser, and reports syntax errors such as bad indentation, tabs used for indentation, unclosed quotes or brackets, duplicate keys in a mapping and invalid anchors or aliases. It checks that the YAML is well-formed; it does not check it against a schema such as a Kubernetes or GitHub Actions specification.

Why are my comments gone after formatting?

Formatting works by reading the YAML into data and writing it out again, and comments are not part of the data. Use the formatted output when you want a clean, normalised file, and keep the original if the comments matter. Validation never changes your text.

Can I use tabs in YAML?

No. The YAML specification forbids tab characters for indentation; use spaces. Tabs inside quoted strings or after a value are fine. The validator points to the exact line when a tab is used for indentation.

How do I validate a file with several documents?

Separate the documents with a line containing three dashes (---), as in Kubernetes manifests. The validator reads every document, the status bar shows how many it found, and YAML → JSON returns them as a JSON array.

What is the difference between YAML and JSON?

JSON is a strict subset of YAML 1.2 in practice, so most JSON files are also valid YAML. YAML adds comments, indentation-based structure, anchors and aliases for reuse, multi-line strings and several documents per file, which is why it is popular for configuration.

Why did 'no' or 'on' turn into true or false?

Older YAML 1.1 parsers treated yes, no, on and off as booleans (the 'Norway problem', where the country code NO becomes false). js-yaml follows YAML 1.2, where only true and false are booleans, but other tools may differ, so quote such values to be safe.

Is my YAML uploaded?

No. Parsing happens in your browser. The js-yaml library is downloaded once from a public CDN, and your data stays on your device.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.XML FormatterBeautify, validate and minify XML with a collapsible tree view.XML to JSONConvert XML to JSON with validation.CSV to JSONConvert CSV data to JSON with live preview.Cron Expression GeneratorBuild crontab schedules visually, read them in plain English and see the next run times.JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.HTML FormatterBeautify and indent HTML code with a live preview.CSS FormatterBeautify CSS with indent controls and optional property sorting.ZIP File CreatorCompress files and folders into a ZIP.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.JSON MinifierMinify and validate JSON, sort keys and see exactly how many bytes you save.Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.IPv6 Expander & CompressorExpand IPv6 addresses to full form or compress them per RFC 5952, one or many at once.GraphQL FormatterPretty-print and indent GraphQL queries, mutations and schemas, or minify them, instantly.CSS ValidatorValidate CSS: syntax errors, unknown properties and invalid values by line, plus auto-fix.Gzip Compress / DecompressGzip or deflate text and files, get Base64 output, and decompress Base64 or .gz files.IBAN ValidatorCheck an IBAN's mod-97 checksum, country and length, and see its bank code and account parts.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.JSON Schema ValidatorValidate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with clickable error paths.Markdown FormatterBeautify Markdown with Prettier: list markers, prose wrap, aligned tables and live preview.PHP FormatterBeautify PHP code with Prettier PHP: PSR-12 style, indent and brace options, syntax errors.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.C# FormatterBeautify C# code online: Allman or K&R braces, indent size and line width, clang-format option.HTML ValidatorCheck HTML for errors and warnings with line numbers, locally or with the W3C Nu checker.Java FormatterBeautify Java code online: indent size, brace style and line width, with clang-format option.JavaScript ObfuscatorObfuscate JavaScript with string encoding, renaming and control-flow flattening presets.Phone Number FormatterFormat and validate lists of phone numbers to E.164, international or national style.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.Responsive Design CheckerPreview any website at phone, tablet, laptop and desktop sizes side by side, with rotate and zoom.Browser Compatibility CheckerSearch CSS, JavaScript and HTML features and see which browser versions support them.Core Web Vitals CheckerCheck real-user LCP, INP and CLS for any URL or site and see if it passes Core Web Vitals.Heading Structure CheckerPaste HTML to see its H1-H6 outline and catch missing H1s, multiple H1s and skipped levels.Website Hosting CheckerFind out who hosts a website: hosting provider, IP addresses, ASN, network owner and location.Routing Number ValidatorCheck a US ABA routing number's checksum and format and see its Federal Reserve district.Spam Word CheckerScan an email subject and body for spam trigger words, excess caps, exclamation marks and risky links.Check Digit CalculatorCalculate or validate check digits for UPC, EAN, GTIN, SSCC, ISBN, ISSN and mod 11 codes.Luhn Algorithm CheckerValidate numbers with the Luhn mod 10 check or calculate the missing check digit, step by step.XSD ValidatorValidate XML against an XSD schema in your browser and see each error with its line number.Strftime Format BuilderBuild Python and C strftime format strings by clicking tokens, with a live preview and reference.
See all 41 Code Formatters & Validators →