A lightweight, high-precision Visual Studio Code extension to verify color contrast ratios directly from your stylesheets. Ensure your UI matches the international web accessibility standards without leaving your editor.
This extension streamlines web development workflows by allowing fast validation of text-to-background contrast while coding, avoiding the friction of switching to external browser tools.
This extension was built to solve specific workflow gaps:
-
Format-Agnostic: This extension natively parses HEX, RGB, and HSL — in both legacy comma and modern space syntax — without requiring manual conversion.
-
On-Demand & Non-Intrusive: Instead of scanning entire files and cluttering your editor with warning squiggles, it runs only when you request it, keeping your workspace clean.
-
Granular Compliance Matrix: Rather than giving a single raw number or a generic pass/fail, it instantly breaks down your selection into the 4 official WCAG criteria so you know exactly where your contrast stands.
-
Multi-Format Parsing: Seamlessly reads colors written in HEX, RGB, and HSL formats — including 8-digit hex with alpha (
#RRGGBBAA). -
Legacy and Modern CSS Syntax: Both the comma form (
rgb(0, 0, 0),hsl(120, 50%, 50%)) and the CSS Color 4 space form (rgb(0 0 0 / 50%),hsl(120deg 50% 50% / 0.5)) are recognised. -
WCAG 2.1 Compliance: Computes exact relative luminance to calculate strict contrast ratios.
-
Granular 4-Level Report: Outputs a detailed compliance breakdown in a dedicated Output Channel:
AA Normal Text(Minimum 4.5:1)AAA Normal Text(Minimum 7.0:1)AA Large Text(Minimum 3.0:1)AAA Large Text(Minimum 4.5:1)
-
Bidirectional Validation: Works perfectly whether you select the text color or the background color first.
The extension is engineered with performance and reliability in mind, utilizing strict JSDoc typing to ensure type safety without adding runtime overhead.
-
Color Normalization: The
parseColorToRGBmodule translates varied CSS formats into a unified RGB numerical space ($0-255$ ). - Luminance Calculation: Applies the W3C coefficients to determine the exact brightness perceived by the human eye.
-
Contrast Ratio Matrix: Evaluates the luminance ratio and returns direct visual feedback (
[🎉 PASS]/[❌ FAIL]) into the VS Code interface.
No external dependencies or configuration required.
- Select any two color strings in your file (HEX, RGB, or HSL).
- Right-click on the selection.
- Click on
Check Accessibility Contrastin the context menu. - Check the results instantly in the Output panel (under the
Contrast Checkertab).
You can also run it from the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) asContrast Checker: Check Accessibility Contrast.
💡 Tip for Multiple Selections: To select two separate color strings, hold
Alt(Windows/Linux) orOption(macOS) while making your selections with the mouse.
This extension is compatible with other VS Code-based editors, such as Cursor, VSCodium, Windsurf, or Trae.
If you downloaded the .vsix file directly from the Releases page, you can install it manually using any of these methods:
- Open VS Code.
- Go to the Extensions view (
Ctrl+Shift+X/Cmd+Shift+X). - Drag and drop the downloaded
.vsixfile into the extensions sidebar.
Click the three dots (...) in the top-right corner of the Extensions panel and select Install from VSIX...
Run the following command in your terminal:
code --install-extension contrast-checker-0.1.1.vsix
This extension currently operates on a zero-config basis to keep your workspace fast and lightweight.
-
Modern CSS functions like
color-mix()or CSS variables (var(--main-color)) are currently not parsed. -
Tailwind CSS: The extension successfully parses raw color formats inside arbitrary values (e.g.,
text-[#3b82f6]), but it does not currently resolve standard Tailwind class names (e.g.,text-blue-500). -
Object-Based Languages: The extension performs static text analysis. It will detect color strings (e.g.,
[#FF0000]), but cannot detect dynamic object instantiations like[new Color(255, 0, 0)](Java).
Given the massive adoption of Tailwind CSS and modern CSS architectures, the next planned releases will focus on:
-
Tailwind Class Resolver: Integrating
resolveConfigto automatically map standard classes (likebg-slate-100) to their HEX values by reading the localtailwind.config.js. -
CSS Custom Properties Support: Resolving CSS variables by scanning the document's
:rootdeclarations.
- Fixed multiple selections: Alt/Option-clicking two separate colors now reports both instead of failing with
Found 1 valid color(s). - The 3.0:1 line of the report is labelled
AA Large Text, matching the other three criteria.
Full history in the CHANGELOG.
This project is licensed under the MIT License - see the LICENSE file for details.
Developed with ❤️ for an accessible web.

