Contrast Ratio Calculator
Check WCAG contrast between two hex colors.
Loading tool...
Private by design
Your inputs stay in the browser session for this tool run.
Client-side utilities
Contrast Ratio Calculator runs as a browser utility: Check WCAG contrast between two hex colors.
Same-page workflow
Useful for quick checks while coding — no paste into an unknown third-party API.
Free to use
Use Contrast Ratio Calculator without creating an account or installing software.
Before you rely on the result
Local helper for one task. Read the output before you commit it.
Spot an error? Tell us.
About Contrast Ratio Calculator
What this tool does
Checking color contrast is an essential part of web design and development, ensuring that text is legible for every user. The Contrast Ratio Calculator allows designers and developers to check the WCAG contrast between two hex colors quickly. By evaluating the luminance of both the background and foreground colors, this utility determines whether a specific combination meets established accessibility standards for readability.
Using the calculator helps prevent common usability issues caused by low-contrast text, such as light gray text on a white background. It provides clear numerical results that indicate compliance with accessibility guidelines. Because processing occurs entirely in the browser, developers can evaluate palettes securely without installing specialized software or creating an account.
How to use it
Follow these steps to check the contrast ratio between two colors:
- Enter the background color. Type or paste the valid hex code into the Background Hex Color input field.
- Enter the foreground color. Type or paste the valid hex code into the Foreground Hex Color input field.
- Review the results. View the generated contrast ratio output on the page and use the Copy button if needed.
You can modify either hex code at any time to test alternative color combinations.
How it works
The tool takes two standard hexadecimal color inputs representing the background and foreground elements of a user interface. It converts these hex values into relative luminance measurements according to standard colorimetric formulas defined by the World Wide Web Consortium. By comparing the luminance values of the lighter and darker colors, the utility calculates the mathematical contrast ratio between them.
The resulting ratio reflects how distinct the foreground text appears against the background container. The calculation runs entirely client-side using JavaScript, ensuring your color data remains private and is never uploaded to an external server. While the utility computes the precise ratio efficiently, it relies on accurate six-digit or three-digit hex code inputs to deliver correct mathematical outcomes.
A worked example
Suppose the input is Background: #FFFFFF, Foreground: #000000. The user enters the background hex code for white and the foreground hex code for black into the respective input fields.
The browser evaluates the luminance values of both hex codes locally and calculates their optical difference. The result is 21:1. A contrast ratio of 21:1 represents the maximum possible contrast between black and white, easily passing all readability requirements.
What you get
- Hex Color Inputs. Easily input background and foreground colors using standard hex code notation.
- On-Page Results. View the calculated contrast ratio directly on the page without navigating away.
- Copy Button. Quickly copy the resulting contrast details to your clipboard with a single click.
- Browser-Based Processing. All calculations run locally in your browser, keeping your color testing private.
- No Account Required. Access the utility immediately without signing up, logging in, or creating a profile.
Who it helps
- Web Developers. Verify that text and background color combinations implemented in CSS meet standard accessibility guidelines.
- UI/UX Designers. Test color palettes during the design phase to ensure chosen brand colors are legible for all users.
- Accessibility Specialists. Audit web pages and digital interfaces for compliance with WCAG contrast requirements.
- Content Creators. Check text and background contrast on graphics and digital publications to ensure readability.
- Front-End Engineers. Quickly validate dynamic theme colors during component development directly in the browser.
Contrast Ratio Calculator FAQs
A color contrast ratio measures the difference in light luminance between two colors, typically expressed as a ratio ranging from 1:1 up to 21:1. Higher numbers indicate greater visual distinction between the foreground and background elements, which is critical for legibility.
The inputs accept standard hexadecimal color codes, commonly used in web design. You can enter standard six-digit hex codes preceded by a hash symbol or shorthand three-digit codes depending on your color palette.
No, all processing happens entirely within your web browser using client-side scripts. Your color values are never sent to or stored on any external server, ensuring complete privacy during your workflow.
No account, registration, or login is required to use this utility. You can access and use the calculator freely directly in your browser whenever you need to check color combinations.
You can use the built-in Copy button to copy the resulting data to your clipboard, allowing you to paste it easily into your documentation, design notes, or code comments.




