Search by

j13k / yaml-lint

j13k

A compact command line utility for checking YAML file syntax

Package info

github.com/j13k/yaml-lint

pkg:composer/j13k/yaml-lint

Statistics

Installs: 1 250 980

Dependents: 32

Suggesters: 0

Stars: 15

Open Issues: 4

1.1.10 2026-11-21 01:55 UTC

This package is auto-updated.

Last update: 2026-11-26 00:07:26 UTC


README

Latest Version on Packagist Docker Image Version CI Coverage Total Downloads Software License

A compact command line tool for checking YAML file syntax, using the parsing facility of the Symfony Yaml component.

  • Works with PHP 5.6 and later, and symfony/yaml 2 to 8.
  • Also available as a signed, standalone PHAR.
  • Reports errors with exit codes, for use in scripts and CI.

Requirements

  • With Composer: PHP 5.6 or later, and symfony/yaml 2 to 8. Composer installs the version of symfony/yaml that suits your project.
  • As a PHAR: PHP 8.2 or later, with the json and zlib extensions. The PHAR bundles symfony/yaml 7.4, the long-term support release.
  • As a Docker image: Docker only. The image includes PHP 8.6 and symfony/yaml 7.4, the long-term support release.

Note

Version 1.2.0 will drop support for symfony/yaml 2 to 4, which no longer receive security fixes, and require PHP 7.2.5 or later (#268). Projects on older versions will keep receiving 1.1.x.

Installation

Composer

Install yaml-lint as a development dependency of your project:

composer require --dev j13k/yaml-lint

Then run it as vendor/bin/yaml-lint.

To install it globally instead:

composer global require j13k/yaml-lint

Make sure Composer's global bin directory (composer global config bin-dir --absolute) is on your PATH.

If Composer reports a binary name conflict during installation, see Troubleshooting.

PHAR

A standalone yaml-lint.phar is attached to each release.

  • Install it with PHIVE, which also checks its signature: phive install yaml-lint
  • Or download it from the release, and verify its signature.

Docker

The j13k/yaml-lint image is published with each release, and needs no PHP or Composer. Mount the files to check at /workdir:

# Check a file in the current directory
docker run --rm -v "$PWD:/workdir:ro" j13k/yaml-lint config.yml

# Check YAML from standard input
cat config.yml | docker run --rm -i j13k/yaml-lint -

Tags follow the release versions: x.y.z for a specific release, x.y and x for the newest release in that minor or major version, and latest for the newest release.

The phpqa Docker image includes yaml-lint alongside other PHP static analysis tools. See the phpqa instructions for how to run it.

Usage

usage: yaml-lint [options] [input source]

  input source      Path to file(s), or "-" to read from standard input

  -q, --quiet       Restrict output to syntax errors
  -t, --parse-tags  Enable parsing of custom YAML tags (symfony/yaml 3+ only)
  -h, --help        Display this help
  -V, --version     Display application version

Check one or more files:

yaml-lint config.yml
yaml-lint config.yml services.yml

Check YAML from standard input:

cat config.yml | yaml-lint -

Check every non-vendor YAML file in a project, for example in CI:

find . -path ./vendor -prune -o \( -name '*.yml' -o -name '*.yaml' \) -print0 \
  | xargs -0 -n 1 vendor/bin/yaml-lint --quiet

-n 1 runs yaml-lint once per file, so every error is reported rather than only the first (see Exit codes). If any file fails, xargs exits with code 123.

Exit codes

Code Meaning
0 All input is valid YAML (or --help or --version was used)
1 A syntax error, a missing or unreadable file, a directory, or invalid options

Checking stops at the first file with an error.

Verifying the PHAR signature

Release PHARs are signed with GPG, using the key with this fingerprint:

528E 7737 B566 750F 7C00  D32A 38A1 82AB 4130 64D7
How to verify the signature
  1. Download yaml-lint.phar and yaml-lint.phar.asc from the releases page.

  2. Import the public key, either from the maintainer's GitHub account:

    curl -fsSL https://github.com/j13k.gpg | gpg --import

    Or from a keyserver:

    gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys 528E7737B566750F7C00D32A38A182AB413064D7
  3. Verify the signature:

    gpg --verify yaml-lint.phar.asc yaml-lint.phar

    Check that the output says Good signature and shows the fingerprint above. A warning that the key isn't certified with a trusted signature is normal unless you've signed the key yourself.

Troubleshooting

Composer reports a binary name conflict

symfony/yaml has its own yaml-lint binary. If it's installed first, Composer skips this package's binary and shows:

Skipped installation of bin bin/yaml-lint for package j13k/yaml-lint:
name conflicts with an existing file

vendor/bin/yaml-lint then runs symfony/yaml's linter. To run this package's yaml-lint, call it directly:

vendor/j13k/yaml-lint/bin/yaml-lint

Or replace symfony/yaml's link in vendor/bin with one to this package. -f overwrites the existing link:

ln -sf ../j13k/yaml-lint/bin/yaml-lint vendor/bin/yaml-lint

Composer may restore symfony/yaml's link on a later install or update, so this may need repeating.

See #181 for background.

Contributing

Contributions are welcome.

Versioning and changelog

Releases follow semantic versioning.

  • The release process sets out which changes go into patch, minor and major releases.
  • The changelog lists what has changed in each release.

Credits

yaml-lint contributors

Thanks also to the Symfony Yaml contributors.

License

Released under the MIT License.