How to Use the Yaml Validator: Step-by-Step Tutorial
The Yaml Validator runs entirely in your browser โ no file is uploaded to any server, no account is required, and no data leaves your machine. This tutorial walks through every step of using the tool: loading a YAML file, reading the validation results, understanding each issue type, and fixing the most common YAML errors.
Follow along with the tool open: Open the Yaml Validator in a second tab, then work through each step below.
Open Yaml Validator โTable of Contents
Step 1 โ Open the Tool
Navigate to /developer-tools/yaml-validator/. The tool loads entirely in the browser. There are no cookies set, no account required, and no network requests made after the initial page load. You can verify this by checking the browser's Network tab in DevTools โ after the page loads, validating a file generates zero outbound requests.
The tool is accessible from the Developer Tools hub, the command palette (press Ctrl+K or โK and type "Yaml Validator"), or directly via the URL above.
Step 2 โ Load Your YAML File
There are two ways to get your YAML data into the validator:
Option A โ Drag and drop. Drag your .yaml or .yml file from your file manager and drop it anywhere on the page. A drop zone indicator appears when you drag a file over the browser window. Release to load. The file is read directly from disk by the browser's FileReader API and never leaves your machine.
Option B โ Paste text. Click the paste input area and paste your YAML content directly. This is ideal for validating YAML copied from a terminal, a CI configuration editor, a Kubernetes manifest, or any other source. There is no size limit on paste, though very large files may take a moment to process.
Supported file types include .yaml, .yml, and any text file containing YAML. Files with other extensions can be loaded via paste.
Step 3 โ Read the Validation Status
Once your file loads, the results panel appears immediately. The top of the panel shows the overall validation status:
- Valid. The file parsed without errors. The panel shows document structure details including root type, key count at the top level, nesting depth, and total document count if the file contains multiple YAML documents separated by
---. - Invalid. The file contains one or more errors that prevent it from parsing correctly. The error list shows the line number, column position, and a plain-English description of the problem.
- Valid with warnings. The file parsed successfully but contains issues that may cause problems at runtime โ typically duplicate keys or values subject to unexpected type coercion.
The status badge color gives you an immediate read: green for valid, red for invalid, amber for warnings.
Step 4 โ Review the Issues List
For files with errors or warnings, the issues list gives you the specifics you need to fix them. Each issue entry includes:
- Line number. The exact line where the problem was detected. For indentation errors, this is the line that was misindented. For syntax errors, it is the line where the parser failed.
- Issue type. A category label: Syntax Error, Indentation Error, Duplicate Key, Type Warning, or Structure Warning.
- Description. A plain-English explanation of what went wrong and, where applicable, what the parser expected instead.
- Severity. Error (blocks parsing) or Warning (parsing succeeded but runtime behavior may differ from intent).
Work through the issues list from top to bottom. Fix the first error before addressing subsequent ones โ YAML parsers are sensitive to cascading failures where one indentation mistake causes every subsequent line to be mis-classified.
Step 5 โ Understand Each Issue Type
Syntax Error. The YAML is structurally malformed โ a colon without a space, an unclosed flow sequence, a tab used as indentation, or an invalid escape sequence. Syntax errors always prevent parsing. The line number points directly to the offending character.
Indentation Error. A key or sequence item is indented at an unexpected level. YAML uses consistent spaces (never tabs) for nesting. An off-by-one indent can silently move a key into the wrong parent mapping. If you see this warning on a line that looks correctly indented, check whether you are mixing 2-space and 4-space indentation within the same file.
Duplicate Key. Two or more keys with the same name appear at the same level within a mapping. The YAML specification leaves duplicate key behavior undefined โ most parsers silently use the last value, discarding earlier ones. This is a warning rather than an error because the file parses, but data loss is likely. The validator reports both the line of the first occurrence and the line of the duplicate.
Type Warning. A scalar value is subject to automatic type coercion in YAML 1.1. Common examples: the bare string yes coerces to boolean true; 010 coerces to octal integer 8; null coerces to null. If you intended the value as a string, quote it: "yes", "010", "null".
Structure Warning. The document structure has potential issues โ an empty document following a --- separator, a missing document end marker before a subsequent document, or a root type that is a bare scalar instead of the mapping most applications expect.
Step 6 โ Fix and Re-Validate
Open your YAML file in your editor of choice. Fix the issues identified in Step 4, then reload the validator and paste or drop the corrected file. The quickest workflow:
- Note the first error's line number from the issues list.
- Jump to that line in your editor (Ctrl+G or โG in most editors).
- Apply the fix described in the issue detail.
- Save and re-validate.
- Repeat until the status shows Valid.
For files with many errors, address syntax errors first (they cascade), then indentation errors, then duplicate keys, then type warnings. A file that parses successfully with zero warnings is ready for deployment.
Worked Examples
Example 1: Tab character used as indentation
Input:
server:
host: localhost
port: 8080
The indented lines use a tab character, which YAML explicitly forbids as indentation. The validator reports a Syntax Error on line 2. The fix is to replace the tab with spaces โ two spaces is the community standard:
server:
host: localhost
port: 8080
Example 2: Boolean coercion on a country code
Input:
country: NO
language: EN
In YAML 1.1, NO is treated as boolean false. The validator reports a Type Warning. If the intent is the string "NO" (Norway's country code), quote it:
country: "NO"
language: EN
Example 3: Duplicate environment variable key
Input:
env:
DATABASE_URL: postgres://host1/db
API_KEY: abc123
DATABASE_URL: postgres://host2/db
The validator reports a Duplicate Key warning on line 4 (the second DATABASE_URL). Most parsers will silently use postgres://host2/db, discarding the first value. If this is intentional, remove the first entry. If not, rename or remove the duplicate.
Example 4: Off-by-one indentation moving a key to the wrong scope
Input:
deploy:
replicas: 3
strategy:
type: RollingUpdate
maxSurge: 1
The intent is for maxSurge to be a child of strategy, but it is indented at the same level as strategy โ making it a sibling of strategy and a child of deploy instead. The validator reports an Indentation Error. The fix:
deploy:
replicas: 3
strategy:
type: RollingUpdate
maxSurge: 1
Tips and Edge Cases
- Kubernetes manifests. Multi-document YAML files (multiple documents separated by
---) are fully supported. The validator reports results for each document individually and flags any malformed document separators or missing end markers. - Anchors and aliases. Files using YAML anchors (
&name) and aliases (*name) are supported. The validator resolves them during parsing. An undefined alias reference is reported as a Syntax Error. - Very large files. The tool processes files entirely in the browser using JavaScript. Files under 5 MB validate quickly. For very large YAML files (10 MB+), a command-line parser such as
python3 -c "import yaml; yaml.safe_load(open('file.yaml'))"may be faster. - YAML 1.1 vs 1.2. The validator uses a YAML 1.1-compatible parser (the version used by most tools including PyYAML, js-yaml, and Ruby's Psych). Type coercion warnings reflect YAML 1.1 rules. If your target system uses a strict YAML 1.2 parser, you may see fewer coercions in production than the warnings suggest.
- Privacy. The tool reads your file using the browser's FileReader API. The file bytes are processed in-memory by JavaScript running in your browser tab. No data is sent to any server. Suitable for CI configurations, secret files, Kubernetes manifests, and any sensitive configuration content.
- Re-validating after edits. The validator does not watch your file for changes. After editing, simply drop the updated file again or paste the corrected YAML into the input area. The previous results are replaced immediately.
