ccr

ccr

WCAG color contrast ratio checker for the command line.

A command-line tool for checking WCAG color contrast ratios. Install nothing — just run:

npx @siluat/color-contrast-cli '#708090' '#ffffff'
Contrast ratio: 3.94:1
Normal text: Fail ✗
Large text:  AA ✓

Why ccr?

CI/CD Ready

Gate your pipeline with --level AA exit codes. Pipe --json output to other tools for automated reporting.

Color Suggestion

When contrast fails, --suggest finds the closest accessible color. Adjusts only OkLCH lightness to preserve the original hue and saturation.

Batch Audit

Audit an entire design system palette at once with --batch. Supports comments, blank lines, and mixed color formats.

10 Color Formats

#hex, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch(), and named colors — broad CSS Color Level 4 coverage.

Quick Start

Install globally
npm install -g @siluat/color-contrast-cli
Check a color pair
ccr '#333' '#fff'
Get a fix for failing contrast
ccr '#999' '#fff' --suggest --level AA
Audit a palette file
ccr --batch < palette.txt

Read the Getting Started guide for more details, or jump to the CLI Reference for the full option list.

Library

The computation engine is also available as a standalone JavaScript/TypeScript library — @siluat/color-contrast — for programmatic use.

On this page