WCAG contrast checker for two HEX colours

Try WCAG Contrast Checker

WCAG Contrast Checker inputs

Loading calculator. If this message stays visible, enable JavaScript and reload.

The WCAG contrast checker calculates the contrast ratio between two six-digit HEX colours. Enter the foreground and background, run the check, then read the ratio and separate AA results for normal and large text. Black against white produces 21:1; identical colours produce 1:1.

This page checks a supplied pair of solid colours. It does not inspect a website, identify the font size or certify a page's accessibility. Use the result to examine a specific design decision, then check the actual text, background and interaction states in the interface where those colours will appear.

WCAG Contrast Checker instructions and examples

What does this WCAG contrast checker actually test?

The WCAG contrast checker tests the light-dark contrast of the two colour values entered in the form. Foreground and Background are the only inputs. After calculation, the result contains a numerical ratio and two lines labelled WCAG AA normal text and WCAG AA large text.

The checker does not load a URL or read another page's styles. It has no browser extension, screen eyedropper, image upload or automatic colour-extraction feature. Obtain the actual colour values from your design or inspected stylesheet before entering them.

The Color Contrast Checker is a related colour-pair tool. This page explains the same general contrast task with particular attention to interpreting the AA lines. It does not provide an additional whole-site audit.

A Pass applies to the stated numerical comparison, not every accessibility requirement. Keyboard access, text alternatives, focus behaviour, reading order and other interface properties remain separate questions.

Use the foreground value for the text colour and the background value for the surface immediately behind it. If a design uses a different surface elsewhere, calculate that pair separately rather than extending one result to the entire colour palette.

How do I enter a valid foreground and background?

Use six hexadecimal digits for each colour, such as #315CF5 or #FFFFFF. Hexadecimal digits run from 0 to 9 and A to F. Uppercase and lowercase letters are accepted; the leading hash is optional in this particular input parser.

  1. Identify the actual foreground colour.
  2. Identify the solid background immediately behind it.
  3. Enter both six-digit values.
  4. Choose Calculate / Run.
  5. Read the ratio and the relevant text-size result together.

The parser trims surrounding whitespace but does not support a three-digit shorthand such as #FFF. Colour names, rgb(), hsl() and eight-digit HEX with alpha are also outside this form's accepted notation.

The RGB to HEX tool can help when you have supported RGB channel values. The HEX to RGB tool provides the reverse channel representation. A change of notation does not by itself improve contrast.

Do not remove an alpha value and assume the remaining digits describe the final visible colour. Transparency depends on what is underneath. This checker has no opacity input and does not composite layers for you.

Check which design token is actually applied to the element. A token named “primary text” can point to different values in light and dark themes, and a component can override the page's usual background. Enter the resolved pair for the state under review. The calculator cannot know that a copied token name refers to another colour in a different theme or component.

How is the contrast ratio calculated?

The calculation converts each colour's red, green and blue channels into relative luminance, then compares the lighter and darker values. If those luminances are L1 and L2, with L1 the larger, the ratio is (L1 + 0.05) / (L2 + 0.05).

The inspected engine normalises each 8-bit channel, applies the standard piecewise sRGB linearisation and uses the luminance weights 0.2126, 0.7152 and 0.0722. It does not average the three original channel numbers or compare their HEX strings alphabetically.

The W3C WCAG 2.2 relative-luminance definition, checked in 2026, is the primary reference for this method. The result expresses relative luminance contrast rather than a general measure of how different two colour names sound.

Swapping foreground and background gives the same numerical ratio because the formula always places the lighter luminance first. Actual use still matters: text thickness, rendering and surrounding layout are not measured by that symmetry.

The result ranges from 1:1 for equal luminances to 21:1 for black and white. It is a ratio, not a percentage, rating out of ten or probability that every reader will find the text comfortable.

What do the normal-text and large-text AA lines mean?

The two lines compare the same calculated ratio with different thresholds. Normal-text AA uses at least 4.5:1. Large-text AA uses at least 3:1. A pair can pass the large-text line while failing the normal-text line.

W3C's Understanding Contrast Minimum, checked in 2026, explains these text requirements and their exceptions. Large-scale text is defined using at least 18-point text or at least 14-point bold text; it does not simply mean any text that looks prominent.

The form contains no font-size or font-weight field. It prints both comparisons and leaves you to determine which is appropriate for the actual text. A passing large-text line does not establish that the pair is suitable for smaller ordinary text in a real interface.

The implementation compares the unrounded internal ratio with the thresholds. The displayed value is rounded to at most eight decimal places. Do not round a failing result upward yourself to declare a pass.

The tool does not print AAA outcomes or test non-text components separately. A numeric threshold shared by another criterion does not mean that criterion has been fully checked here. Evaluate the actual element and applicable requirement in the page's context.

Which worked colour pairs can I use to check the result?

Start with black and white. Their luminances give (1 + 0.05) / (0 + 0.05) = 21, so both AA text lines pass. Reversing the two colours returns the same ratio.

ForegroundBackgroundRatio, approximatelyNormal AALarge AA
#000000#FFFFFF21:1PassPass
#123456#1234561:1FailFail
#FF0000#0000005.252:1PassPass
#777777#FFFFFF4.47808945:1FailPass
#767676#FFFFFF4.54222496:1PassPass

These independent reference cases were compared with the actual engine. The neighbouring grey examples show why a small numeric difference can change a threshold outcome. Their purpose is to explain the calculation, not to prescribe one universal brand palette.

Identical colours are also a useful input check. They should not produce readable colour contrast merely because the input codes are valid. If both fields contain the same value, a 1:1 result is expected.

Keep full original colour values when repeating a check. Replacing a colour with a nearby sampled pixel or an estimated visual match changes the pair being tested.

The red example also demonstrates why a colour cannot pass by itself. With red #FF0000 on white, the independently checked ratio is about 3.99847677:1: large-text AA passes and normal-text AA fails. The same red on black gives 5.252:1 and passes both displayed comparisons. The foreground has stayed the same, while the intended background has changed the result. Keep the two-value relationship intact when recommending a revision.

How should I choose a better pair after a failed check?

Change a colour in the actual design, then test the revised pair. Greater separation in relative luminance can improve the ratio. Merely choosing a different hue does not guarantee an improvement.

For text on a light surface, a darker text value is one possible revision. For text on a dark surface, a lighter foreground may help. Test the resulting exact values instead of relying on the colour's name or appearance in a small swatch.

The Random Color Generator can provide a colour candidate, but its output is not a pre-approved accessible pairing. Bring the candidate and intended background into the contrast checker before using them together.

Keep separate checks for normal, hover, focus, selected and error states when those states change the relevant colours. A successful default-state pair says nothing about a different pair used after a user interacts with the control.

After choosing a numerical passing pair, review the real typography and interface. Thin letterforms and rendering can still affect readability. The checker does not automatically edit CSS, generate a replacement palette or preview those states on your website.

Why are gradients, transparency and screenshots harder to assess?

A single solid background code cannot describe a gradient, photograph or translucent stack of layers. Text can cross several different colours, producing different local contrast conditions within one line.

This form does not calculate the final visible colour of overlapping transparent layers. Entering only the opaque RGB portion of an alpha colour can therefore test a pair that is not actually displayed.

When inspecting a real interface, identify the rendered colour relationship through an appropriate design or browser inspection workflow. Check the relevant backgrounds and states rather than assuming one convenient sample represents all of them.

The calculator does not analyse an uploaded screenshot or detect text boundaries. A colour sampled from an anti-aliased edge can also differ from the underlying text colour. The screenshot and the stylesheet answer different questions.

A full accessibility review combines colour checks with the rest of the content and interaction. The output here remains a useful pairwise calculation, but it is not a screenshot audit, colour-vision simulation or guarantee that a design satisfies every applicable standard.

How can I keep a useful record of a contrast decision?

Record the two colour values, the element and state they belong to, the calculated ratio and the text-size context. A ratio copied without the colours is difficult to reproduce when a palette changes later.

Copy result can retain the displayed result text. Save as baseline provides a temporary comparison during the current page session, and Download CSV exports a result record. Keep the design context and original codes separately if they are needed for a review.

Reset fields clears the current result and comparison. The page does not maintain a permanent colour-audit history or automatically detect later stylesheet changes. Recalculate when either colour changes.

The inspected operation processes the entered strings in the browser. No website URL or screenshot is submitted by this form. Website delivery and analytics practices are described separately in the MoneyOr privacy policy.

When sharing a finding, state exactly what passed or failed: the chosen pair against the normal-text or large-text AA threshold. Avoid turning that focused result into a claim that a complete website has been certified accessible.

For a component review, make one row for each relevant pair and state. Include a useful identifier such as “search-field placeholder, default, light theme” rather than only “grey text”. That description helps another reviewer find the element again. If the component is later reused on a different surface, its old result is a record of the previous pair, not evidence for the new placement. Recheck the pair after a theme update, a changed surface or a revised text style, and keep the new result labelled.

Frequently asked questions

Does a Pass certify WCAG compliance for my website?

No. It reports a numerical comparison for the two supplied colours. It does not inspect page content, keyboard operation, text alternatives, focus states or all other accessibility requirements. A website-wide claim needs an appropriately scoped review of the actual site.

Can I enter #FFF instead of #FFFFFF?

No. This parser requires six hexadecimal digits, with an optional leading hash. Expand shorthand to the full supported representation before calculating. Colour names, RGB function syntax and alpha-inclusive eight-digit codes are also rejected by this form.

Why does one pair pass large text but fail normal text?

The large-text AA threshold is lower than the normal-text AA threshold. The form shows both comparisons for the same ratio. Determine the real font size and weight before deciding which comparison applies to the text you are evaluating.

Will exchanging the two colours improve the ratio?

No. The formula identifies the lighter and darker luminances automatically, so exchanging the input fields produces the same numerical ratio. Reversing the visual design can affect its presentation, but it does not change this pairwise calculation.

Does the checker test AAA contrast?

The current result prints AA normal-text and AA large-text comparisons only. It does not label an AAA outcome. Do not reinterpret the displayed Pass as an AAA statement or a full assessment of a separate accessibility criterion.

Can I use it to inspect every colour on a page?

No. It checks one manually supplied pair at a time. There is no URL scanner, browser extension or automatic DOM inspection in this form. Record and check the actual pairs needed for the elements and states under review.

Is a ratio of 4.478 acceptable if I round it to 4.5?

No. The actual value is below the 4.5 normal-text AA threshold. The tool uses the internal unrounded number for its comparison. Keep the computed result rather than rounding a failing value upward to claim a different outcome.

Can I check colours on mobile without registering?

Yes. The form does not require a MoneyOr account. Enter the two supported codes and calculate in the browser. The same input rules and numerical thresholds apply; the tool does not require installing an extension to perform this check.

Sources and method notes