Which YAML linter catches what
There is no single YAML linter that covers everything. yamllint checks style, actionlint understands GitHub Actions, kubeconform and check-jsonschema check structure against a schema, and helm lint checks that a chart renders. We ran all five on the same files, plus our own browser validator, and quote what each one printed.
Five tools, four kinds of checks
"Linter" covers different jobs. Syntax: does it parse. Style: indentation, trailing spaces, duplicate keys. Schema: are the fields and types right for this kind of file. Semantics: does it make sense to the program that reads it, such as an expression that refers to a matrix key that does not exist.
| Tool | Checks | Files | Install | Runs in |
|---|---|---|---|---|
| yamllint | Syntax, style, a few type rules | Any YAML | pip install yamllint | CLI, CI, pre-commit |
| actionlint | Syntax, schema, semantics, shell scripts | GitHub Actions workflows | Go binary or rhysd/actionlint image | CLI, CI, pre-commit |
| kubeconform | Syntax, schema | Kubernetes manifests | Go binary or ghcr.io/yannh/kubeconform image | CLI, CI |
| helm lint | Chart structure, template rendering | Helm charts | Part of the helm CLI | CLI, CI |
| check-jsonschema | Syntax, schema | Any YAML or JSON with a schema | pip install check-jsonschema | CLI, CI, pre-commit |
| yamlvalidator.dev | Syntax, schema, type-coercion warnings | Any YAML, 11 built-in schemas | Nothing (web page) or a Chrome extension | Browser |
yamllint
The general-purpose YAML linter. It knows nothing about Kubernetes or GitHub Actions; it checks the file as YAML: syntax errors, indentation, trailing spaces, line length, duplicate keys, and YAML 1.1 booleans such as yes and NO. Every rule can be turned off or tuned in a .yamllint file.
- Checks
- Syntax, style, duplicate keys, truthy values
- Install
pip install yamllint- Runs in
- CLI, CI, pre-commit hook
- Best for
- House style across every YAML file in a repo
What it printed
$ yamllint style.yaml
1:1 warning missing document start "---" (document-start)
1:11 error trailing spaces (trailing-spaces)
4:4 error too many spaces after hyphen (hyphens)
6:1 error duplication of key "dup" in mapping (key-duplicates)
7:1 warning truthy value should be one of [false, true] (truthy)
Worth knowing
- The default config warns about a missing
---on every file and flags theon:key of every GitHub Actions workflow as a truthy value, although GitHub reads that key as the stringon. Most teams adjust these two rules first. - Two type rules are off by default:
octal-values(catches01234) andfloat-valueswithforbid-scientific-notation(catches1234e56). - No rule catches
3.10losing its zero or22:22turning into a number.
actionlint
A linter written only for GitHub Actions workflow files, and it goes much deeper than a schema. It checks runner labels, ${{ }} expressions and their types, inputs of popular actions, untrusted input used in scripts, and it runs shellcheck on run: blocks when shellcheck is installed (the Docker image includes it).
- Checks
- Syntax, schema, expressions, action inputs, shell scripts
- Install
- Single Go binary, or
docker run rhysd/actionlint - Runs in
- CLI, CI, pre-commit hook
- Best for
- Anything under
.github/workflows
What it printed
$ actionlint ci.yml
ci.yml:4:14: label "ubuntu-latst" is unknown. available labels are ... [runner-label]
ci.yml:10:24: "github.event.pull_request.title" is potentially untrusted.
avoid using it directly in inline scripts. ... [expression]
ci.yml:11:23: property "foo" is not defined in object type {} [expression]
b.yml:13:11: input "pyton-cache" is not defined in action "actions/setup-python@v5". ... [action]
b.yml:14:9: shellcheck reported issue in this script: SC2086:info:1:6:
Double quote to prevent globbing and word splitting [shellcheck]
Worth knowing
- It said nothing about
python-version: 3.10, which asks setup-python for Python 3.1. Values passed to an action throughwith:are not type-checked. - It ignores every other kind of YAML file, by design.
kubeconform
Validates Kubernetes manifests against JSON Schemas for each Kubernetes resource kind. It handles multi-document files and reports every field with the wrong type. With -strict it also rejects fields that do not exist, which catches typos like lables.
- Checks
- Syntax, schema (types, unknown fields with
-strict) - Install
- Go binary, or
ghcr.io/yannh/kubeconformimage - Runs in
- CLI, CI
- Best for
- Kubernetes manifests and rendered Helm output
What it printed
$ kubeconform -strict -summary typo.yaml
typo.yaml - ConfigMap cfg is invalid: ... - at '/data/enabled': got boolean,
want null or string - at '/metadata': additional properties 'lables' not allowed
Summary: 2 resources found in 1 file - Valid: 0, Invalid: 1, Errors: 0, Skipped: 1
Worth knowing
- Custom resources need their own schemas. Without one, a
ServiceMonitorfails withcould not find schema, or is skipped with-ignore-missing-schemas. - Schemas are downloaded at run time unless you point
-schema-locationat a local copy. - A schema checks types, not intent:
imagePullPolicy: Sometimespassed, because the schema only says it is a string.
helm lint
Built into the Helm CLI. It loads the chart, parses Chart.yaml and values.yaml, renders every template, and reports what breaks: a values.yaml that does not parse, a template that reads a value that is not there.
- Checks
- Chart metadata, values syntax, template rendering
- Install
- Comes with
helm - Runs in
- CLI, CI
- Best for
- Making sure a chart renders before you package it
What it printed
$ helm lint ./chart
[INFO] Chart.yaml: icon is recommended
[ERROR] templates/: demo/templates/bad.yaml:1:10
executing "demo/templates/bad.yaml" at <.Values.missing.deep>:
nil pointer evaluating interface {}.deep
Worth knowing
- It does not validate the rendered manifests against Kubernetes schemas. Pipe
helm templateinto kubeconform for that. - It passed a chart whose
values.yamlhadtag: 1234e56. The rendered image becamenginx:1.234e+59, even with--strict.
check-jsonschema
Validates any YAML or JSON file against a JSON Schema: one you write, one from a URL, or one of its bundled schemas for files like GitLab CI, Docker Compose, Renovate and GitHub workflows. If a format has a schema and no dedicated linter, this is the tool.
- Checks
- Syntax, schema
- Install
pip install check-jsonschema- Runs in
- CLI, CI, pre-commit hooks for many bundled schemas
- Best for
- Your own config formats, and CI files without a dedicated linter
What it printed
$ check-jsonschema --builtin-schema vendor.github-workflows c.yml
Schema validation errors were encountered.
c.yml::$.jobs.test: {...} is not valid under any of the given schemas
Best Match:
$.jobs.test: 'uses' is a required property
Best Deep Match:
$.jobs.test['timeout-minutes']: 'soon' is not of type 'number'
Worth knowing
- A schema error inside a
oneOfcomes back as a "best match" guess, as above. The real problem was the second line. - It reads files as YAML 1.2, so
NOand22:22stay strings. That is correct for YAML 1.2, but it will not warn you when the program reading the file uses a YAML 1.1 parser. - Schemas do not know what you meant: the misspelled runner label
ubuntu-latstpassed the workflow schema.
yamlvalidator.dev and the extension
This site, so read this section with that in mind. It is not a CI tool and does not try to be. It is for the minute the YAML is in front of you: a snippet from a pull request, a file on GitHub, a manifest someone pasted in chat. Paste it, and it checks syntax, auto-detects one of 11 schemas (Kubernetes, Docker Compose, GitHub Actions, GitLab CI and others), and warns on values that are likely to change type. Everything runs in the page; the YAML is not uploaded.
- Checks
- Syntax, schema, type-coercion warnings with a one-click quote fix
- Install
- Nothing, or the Chrome extension
- Runs in
- Browser
- Best for
- YAML you are reading, not YAML in your repo's pipeline
What it printed
Kubernetes deployment with replicas: "3" and value: NO
Validation Error
Kubernetes v1.29: /spec/replicas must be integer
⚠ 'NO' is read as a boolean by YAML 1.1 parsers (PyYAML, many CI tools)
— the "Norway problem". Quote it as "NO" to keep it a string.
GitHub Actions workflow with timeout-minutes: soon
Validation Error
GitHub Actions workflow: /jobs/test/timeout-minutes must be number; ...
↳ Expected a number
⚠ '3.10' is parsed as a number (trailing zero lost). Quote it for a version string.
How it differs from yamllint on the same values
- It does not warn on the top-level
on:key of a GitHub Actions workflow, since GitHub reads it as a string. Anonoroffvalue, or anon:key anywhere else, still gets a warning. - It warns on
3.10and22:22, which no yamllint rule covers.
Where the CLI tools are better
- No command line, so nothing to run in CI or a pre-commit hook. Use the tools above for that.
- No style rules: indentation width, line length and trailing spaces are not checked.
- Its GitHub Actions check is a schema, not actionlint: the
ubuntu-latsttypo passed. - Kubernetes is checked against one version (v1.29), and custom resources are not covered.
Who catches the Norway problem?
These values parse without error and quietly change type. We put the same seven into a plain YAML file, a ConfigMap, a workflow's env: and a chart's values.yaml, and ran each tool on the version it understands.
The test file
country: NO
python-version: 3.10
start: 22:22
zip: 01234
commit: 1234e56
sha: 8675309
password:
| Value | yamllint | actionlint | kubeconform | helm lint | check-jsonschema (string schema) |
yamlvalidator.dev |
|---|---|---|---|---|---|---|
| NO | truthy | passed | got boolean | passed, renders "false" | passed (string in 1.2) | Norway problem |
| 3.10 | passed | passed | got number | passed, renders "3.1" | 3.1 is not of type 'string' | trailing zero lost |
| 22:22 | passed | passed | passed (string) | passed | passed (string in 1.2) | base-60 number |
| 01234 | octal-values (opt-in) | passed | got number | passed, renders "668" | 1234 is not of type 'string' | leading zero |
| 1234e56 | float-values (opt-in) | passed | got number | passed, renders "1.234e+59" | 1.234e+59 is not of type 'string' | looks like a commit hash |
| 8675309 | passed | passed | got number | passed, renders "8.675309e+06" | 8675309 is not of type 'string' | looks like a commit hash |
| (empty) | passed | passed | passed (null allowed) | passed | None is not of type 'string' | passed, by design |
Reading the table
- kubeconform and check-jsonschema do not know about these traps. They catch a value only when the schema says the field is a string, and kubeconform's parser reads
NOas a boolean while check-jsonschema's does not. - helm lint passed every value. The rendered ConfigMap shows what the cluster would get.
- Nothing in the table catches
password:unless a schema says it must be a string. An empty value is sometimes what you mean, which is why our validator stays quiet on it. - actionlint was given the same values in
env:andwith:and reported nothing.
Which YAML linter should I use?
Usually more than one. They overlap less than their names suggest.
- GitHub Actions workflowsactionlint. Nothing else here checks expressions, runner labels or action inputs.
- Kubernetes manifestskubeconform with
-strict, plus schemas for your custom resources. - Helm chartshelm lint, then
helm templatepiped into kubeconform. Lint alone does not check the rendered output. - Consistent style in every YAML fileyamllint, with
octal-valuesandfloat-valuesturned on. - Your own config format, or GitLab CI and Compose filescheck-jsonschema with your schema or a bundled one.
- YAML you are looking at right nowA file on GitHub, a snippet in a review, something not on your disk: yamlvalidator.dev or the extension. Then add the right CLI tool to CI so it stays fixed.