yamlruff
A fast YAML linter and fixer, written in Rust.
- ⚡️ Fast: about 28× faster than existing YAML linters and 13× faster than existing YAML fixers (measured on real-world files).
- 🔧 Lint and fix in one tool:
yamlruff lintreports,yamlruff fixrepairs, with one shared configuration. - 🛡️ Safe fixes: every fix is checked to leave the loaded data unchanged; files with syntax errors are never touched.
- 📏 23 built-in rules: whitespace, indentation, flow collections, comments, quoting, keys and anchors.
- 🐍 Installable via pip or uv, as a prebuilt binary: no Python dependencies, no Rust toolchain.
- 🛠️
pyproject.tomlsupport: configure under[tool.yamlruff], or in a.yamlrufffile. - 🧩 Shareable configs with
extends, per-ruleignore, and inline# yamlruff disablecomments. - 🤖 CI-friendly:
--checkfor fixes,-f githubannotations, and clear exit codes.
yamlruff is an independent project, not affiliated with Astral or the ruff project.
Table of Contents
- Getting Started
- Installation
- Usage
- Configuration
- Rules
- Fixing
- Continuous integration
- Contributing
- Support
- License
Getting Started
With uv, no install needed:
uvx yamlruff lint . # find problems
uvx yamlruff fix --diff . # preview the fixes
uvx yamlruff fix . # apply them
Or with pip:
pip install yamlruff
yamlruff lint . # find problems
yamlruff fix --diff . # preview the fixes
yamlruff fix . # apply them
For example, given service.yml:
name: web
enabled: yes
ports: [ 80,443 ]
yamlruff lint service.yml reports the missing ---, the extra spaces after the colon, the
yes, the spaces inside the brackets and the missing space after the comma. yamlruff fix
repairs the layout problems right away and leaves the yes for --unsafe-fixes, because
rewriting it to true changes what some YAML loaders read.
Installation
uv tool install yamlruff # or: pipx install yamlruff / pip install yamlruff
Run it once without installing with uvx yamlruff …. Check the install with
yamlruff --version.
Prebuilt wheels exist for macOS (Intel and Apple Silicon) and Linux (glibc and musl; x86_64 and aarch64). On other platforms pip builds from the source distribution and needs Rust.
Usage
yamlruff lint [PATHS]... # report problems ('-' reads stdin; default '.')
yamlruff fix [PATHS]... # rewrite files, then report what is left
yamlruff rule [ID] # list the rules, or document one
| Command / option | Effect |
|---|---|
lint -f standard|parsable|colored|github|auto |
Output format |
lint -s, --strict |
Exit non-zero on warnings as well as errors |
lint --no-warnings |
Show errors only |
lint --list-files |
Show which files would be checked, then exit |
fix --diff |
Show the changes, write nothing |
fix --check |
Write nothing; exit 1 if any file would change |
fix --unsafe-fixes |
Also apply fixes that may change what other loaders read |
fix --unfixable ID |
Never apply the fixes of this rule |
-c FILE, -d 'YAML' |
Use a config file, or config given inline |
Configuration
yamlruff reads .yamlruff (or .yamlruff.yaml / .yamlruff.yml) from the current directory
and then upward, or a [tool.yamlruff] table in pyproject.toml. Without either, it uses the
default preset; extends: relaxed is more lenient.
# .yamlruff
extends: default
rules:
line-length: {max: 120}
truthy: {check-keys: false} # keep `on:` as a key in GitHub Actions
indentation: {spaces: 2, indent-sequences: true}
trailing-spaces: disable
ignore: |
dbt_packages/
target/
# pyproject.toml
[tool.yamlruff.rules]
line-length = { max = 120 }
Other top-level keys: yaml-files (which files count as YAML), ignore-from-file,
respect-gitignore (default true: files matched by a .gitignore, such as dbt's target/ and
dbt_packages/, are skipped; set false to lint them), locale, and the fix: section described under
Fixing. Turn rules off inside a file with comments:
# yamlruff disable-line rule:line-length
# yamlruff disable rule:truthy
# yamlruff enable rule:truthy
# yamlruff disable-file
Rules
23 rules; yamlruff rule <id> shows the options, defaults and what the fix does.
| Rule | Checks | Default | Fix |
|---|---|---|---|
anchors |
Report undeclared aliases, duplicated anchors and unused anchors | error | safe |
braces |
Control the spaces inside and the number of items of flow mappings {...}, or forbid them |
error | safe |
brackets |
Control the spaces inside and the number of items of flow sequences [...], or forbid them |
error | safe |
colons |
Control the spaces before and after : in mappings |
error | safe |
commas |
Control the spaces before and after , in flow collections |
error | safe |
comments |
Require a space after # and spaces before an inline comment (a #! shebang on the first line can be allowed) |
warning | safe |
comments-indentation |
Require comments to be indented like the content around them | warning | safe |
document-end |
Require or forbid the document end marker ... |
off | safe |
document-start |
Require or forbid the document start marker --- |
warning | safe |
empty-lines |
Limit the number of consecutive blank lines, and at the start and end of the file | error | safe |
empty-values |
Forbid empty values in block mappings, flow mappings and block sequences | off | safe |
float-values |
Forbid NaN, infinity, scientific notation and decimals without a leading numeral | off | safe |
hyphens |
Limit the spaces after - in block sequences |
error | safe |
indentation |
Control the indentation of blocks, and of sequences inside mappings | error | safe |
key-duplicates |
Forbid duplicated keys in a mapping (and optionally repeated << merge keys) |
error | unsafe |
key-ordering |
Require the keys of a mapping to be in alphabetical order (see locale) |
off | safe |
line-length |
Limit the length of lines | error | safe |
new-line-at-end-of-file |
Require a newline at the end of the file | error | safe |
new-lines |
Require a given type of line break (unix, dos or platform) |
error | safe |
octal-values |
Forbid implicit (0755) and explicit (0o755) octal numbers |
off | unsafe |
quoted-strings |
Require or forbid quotes around strings, and choose the quote type | off | safe |
trailing-spaces |
Forbid spaces at the end of lines | error | safe |
truthy |
Forbid values such as yes and on that are booleans for some YAML versions |
warning | unsafe |
Fix: safe changes layout only; unsafe needs --unsafe-fixes. A few cases within a rule
(for example .nan in float-values, or undeclared aliases) have no fix and only report. Rules that report as error fail the run, warning rules only with --strict.
Fixing
yamlruff fix applies the fix that belongs to each problem, using the rule's own options, so
after a fix lint has nothing left to report that could have been fixed automatically.
After every round it checks that the document still loads to the same data, and drops any fix
that would change it. Some problems have no safe automatic fix (a duplicated key with different
values, a line that cannot be wrapped) and stay in the report.
Pure style choices that no rule expresses go in a fix: section:
fix:
sequence-style: flow # keep | flow | block
none-representation: empty # keep | empty | null | '~' | Null | NULL
whitelines: 1 # blank lines between content
comments-whitelines: 1 # blank lines before a comment
section-whitelines: 1 # blank lines around top-level sections
join-multiline: false # put multi-line scalars on one line when they fit
simplify-block-headers: false
unsafe-fixes: false
unfixable: [] # rule ids whose fixes are never applied
Continuous integration
yamlruff lint --strict . # fail the build on any problem
yamlruff fix --check . # fail if formatting would change anything
yamlruff lint -f github . # annotate the pull request in GitHub Actions
Exit codes for lint: 0 clean, 1 errors, 2 warnings only (with --strict).
Contributing
Bug reports, ideas and pull requests are welcome. See CONTRIBUTING.md for how to build, test and release.
Support
Open an issue on the repository with the
yamlruff --version, the command you ran, and a minimal YAML file that shows the problem.
License
This repository is licensed under the GPL-3.0-or-later License.
Metadata
Release files for yamlruff 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| yamlruff-0.0.4.tar.gz | 517.3 kB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| yamlruff-0.0.4-py3-none-musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64 | Details |
| yamlruff-0.0.4-py3-none-musllinux_1_2_aarch64.whl | Python 3 | none | Linux musl 1.2+ ARM64 | Details |
| yamlruff-0.0.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| yamlruff-0.0.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| yamlruff-0.0.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | Python 3 | none | macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64 | Details |
Total release size: 8.8 MB
Release files / yamlruff-0.0.4.tar.gz
| Download URL | yamlruff-0.0.4.tar.gz |
|---|---|
| Size | 517.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c0eef18adc0b89a65800e6ade168e6c105957a97f180a0fccd7a49900ddf1e0
|
|
BLAKE2b-256 checksum How to use checksums |
6c376236b04ce9e09c5908d9225b9d22c6f8c60515c9291f6b4c093d0ff7cdda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / yamlruff-0.0.4-py3-none-musllinux_1_2_x86_64.whl
| Download URL | yamlruff-0.0.4-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
36b56fb60a9defcb8454bc13f78126711d90d98a363dd5cec70d814f2c0865b8
|
|
BLAKE2b-256 checksum How to use checksums |
4e48ddf216c1e97cd55970da76745c9d7bdef847a861578a6585aef8ac74fbcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / yamlruff-0.0.4-py3-none-musllinux_1_2_aarch64.whl
| Download URL | yamlruff-0.0.4-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
91783c6badfc641ee5e1fe62c77f63308f33101a1094906df4eb6aa8a6874123
|
|
BLAKE2b-256 checksum How to use checksums |
e5dc7ff3d9756716706fa4c91f18b6acbe14714a3f4f434efeba7123e23094fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / yamlruff-0.0.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | yamlruff-0.0.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
bbd53d1b2962bce08cda3a345bad4ce20301e2dc46ede92813ed0a61da8a5eaa
|
|
BLAKE2b-256 checksum How to use checksums |
b6fd7a9e776a759013836c811fc895062baad01db71c5b154011874347f054ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / yamlruff-0.0.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | yamlruff-0.0.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
d33bea3aa4c18fdfd69812b3fc4fc0443bf60eef9b340a89e5bddadfa8124317
|
|
BLAKE2b-256 checksum How to use checksums |
0b32159e0705e21fea94656125f4561fbeca716d8b1a7647d21f4ae3f11bc5f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / yamlruff-0.0.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | yamlruff-0.0.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 2.6 MB |
| Tags | Python 3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b224a4fdb6cc165c77e1cdee1b6e4b9370c512b0beeda1f3580eb90c21602f83
|
|
BLAKE2b-256 checksum How to use checksums |
4c906322b21bf05c663e5db09e5b257ec1ce37dbf971f7f17faed715eb64ed9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Security for yamlruff 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.