Skip to content
Latchkey

config-file-validator: Lint All Config Formats

validator -search-path ./config recursively validates the syntax of every config file (JSON, YAML, TOML, XML, INI, and more) and fails on any invalid one.

config-file-validator (the validator binary) is a single Go tool that syntax-checks many config formats at once, so a repo full of mixed config gets one gate.

What it does

config-file-validator walks a directory and validates each recognized config file for syntactic correctness. It supports JSON, YAML, TOML, XML, INI, HCL, CSV, Properties, and more, choosing the parser by extension. It reports each invalid file and exits non-zero if any fail.

Common usage

Terminal
# validate everything under a path
validator -search-path ./config

# validate the whole repo, exclude vendored dirs
validator -search-path . -exclude-dirs node_modules,vendor

# only certain file types
validator -search-path . -file-types json,yaml,toml

# machine-readable output for CI
validator -search-path . -reporter json

Options

FlagWhat it does
-search-path <dir>Directory to scan recursively
-exclude-dirs <list>Comma-separated directories to skip
-exclude-file-types <list>File types to skip
-file-types <list>Restrict to specific types
-reporter json|junit|standardOutput format
-depth <n>Limit recursion depth

In CI

Run validator -search-path . (with -exclude-dirs for node_modules/vendor) as a fast, format-agnostic gate; a single malformed YAML or TOML anywhere in the repo exits non-zero and fails the build. Use -reporter junit to surface results in the CI test view.

Common errors in CI

Output lists each file as passed or failed, ending with a summary and a non-zero exit if any failed. A failure line shows the parser error, e.g. yaml: line 12: mapping values are not allowed in this context or toml: line 3: expected key separator '='. command not found: validator means the binary is not installed. Note it validates syntax, not schema, so combine it with a schema tool for structural rules.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →