styl

May 25, 2026 · View on GitHub

Linter, validator, and formatter for MapLibre GL / Mapbox GL style JSON.
Catch spec violations, enforce best practices, and keep style files consistent — in CI or locally.

styl overview

CI Rust License: MIT MapLibre Spec v8


Why styl?

GL style JSON files grow fast. A single typo in a source reference silently breaks tiles. An invisible layer left in production wastes render time. Legacy filter syntax slips through code review unnoticed.

styl is the cargo clippy for your map styles — runs in milliseconds, integrates with CI, and tells you exactly what is wrong and why.

$ styl check style.json

warning[W002] layers[9].layout.visibility: layer "Building" is permanently invisible
  --> style.json
  hint: remove the layer or set visibility to "visible" if it should be shown

warning[W011] layers[3].filter: layer "Landuse" uses deprecated legacy filter syntax
  --> style.json
  hint: migrate to expression-based filters: https://maplibre.org/maplibre-style-spec/expressions/

error[E003] sources.roads: vector source missing required field "url" or "tiles"
  --> style.json

Features

FeatureDescription
ValidatorSpec violations: missing fields, invalid values, broken source refs (E-codes)
LinterBest-practice warnings: duplicate IDs, invisible layers, legacy filters, perf anti-patterns (W-codes)
FormatterCanonical key ordering with --check mode for CI enforcement
Multiple output formatsHuman-readable, JSON (for tooling), GitHub Actions annotations
Config filePer-project .stylrc — per-rule severity overrides, indent settings
Stdin supportcat style.json | styl check --stdin — pipe-friendly

Installation

Homebrew (macOS / Linux)

brew tap navidnabavi/tap
brew install styl

One-line installer

curl -fsSL https://raw.githubusercontent.com/navidnabavi/styl/main/install.sh | bash

Detects your OS and architecture, downloads the correct binary, installs to /usr/local/bin.

Cargo (requires Rust)

cargo install --git https://github.com/navidnabavi/styl

Build from source

git clone https://github.com/navidnabavi/styl
cd styl
cargo build --release
# binary at: target/release/styl

Usage

styl check style.json                     # validate + lint (most common)
styl validate style.json                  # spec violations only (E-codes)
styl lint style.json                      # best-practice warnings only (W-codes)
styl fmt style.json                       # format in-place
styl fmt --check style.json               # CI: exit 1 if formatting would change
styl check --format json style.json       # machine-readable output
styl check --format github style.json     # GitHub Actions annotations
cat style.json | styl check --stdin       # read from stdin

Exit Codes

CodeMeaning
0Clean — no diagnostics
1Diagnostics found (errors or warnings)
2Tool error (bad JSON, I/O failure)

CI Integration

GitHub Action (Recommended):

- uses: navidnabavi/styl@v0.0.4
  with:
    style_file: style.json

Advanced usage:

- uses: navidnabavi/styl@latest
  with:
    style_file: style.json
    command: check       # check (default), validate, lint, fmt
    format: github       # github (default), human, json, html
    version: v0.0.4      # pin styl version (optional)

Pre-commit hook:

styl fmt --check style.json && styl check style.json

Configuration

Drop a .stylrc at your project root:

[rules]
W002 = "error"   # invisible layers → hard error
W003 = "off"     # unused layers → silence
W011 = "warn"    # legacy filters → warn (default)

[format]
indent = 4

styl walks up the directory tree to find it automatically.


Documentation

DocumentDescription
CLI ReferenceAll subcommands and flags
ValidatorsE-code spec violations
Linter RulesW-code best-practice warnings
ExpressionsSupported expression operators
FormatterKey ordering and --check mode
Configuration.stylrc reference
Layer PropertiesValid paint/layout props per layer type

Supported Specs


Contributing

See CONTRIBUTING.md. New validators and linter rules are welcome — the architecture makes adding them straightforward.

cargo build && cargo test && cargo clippy -- -D warnings && cargo fmt --check

All four must pass before opening a PR.


License

MIT