Palette Contrast

Calculate color contrast and compare it with a supplied minimum.

Description

Color contrast compares relative luminances of foreground and background.

Color contrast compares relative luminances of foreground and background. The result is a ratio, with a caller-selected minimum for the intended context.1, 2

Calculate color contrast and compare it with a supplied minimum.

When to use Palette Contrast

Use this tool to calculate color contrast and compare it with a supplied minimum.

Prepare the text, recorded observations, aligned figures or editorial criteria requested. Confirm what each label, count, timestamp or supplied flag represents before interpreting the result.

How to use Palette Contrast and understand its results

  1. Prepare the text, recorded observations, aligned figures or editorial criteria requested. Confirm what each label, count, timestamp or supplied flag represents before interpreting the result.
  2. Enter foregroundHex, backgroundHex, minimumContrastRatio using the field table and calculation rules, then run the tool.
  3. Read contrastRatio, meetsMinimum. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
foregroundHexForeground colorstringRequired
backgroundHexBackground colorstringRequired
minimumContrastRatioMinimum contrast rationumber; minimum: 1Required

Enter exact six-digit #RRGGBB strings and a minimum ratio≥1. Linearize normalized sRGB channels at 0.04045, using c/12.92 below that boundary and ((c+0.055)/1.055)^2.4 above. Weight channels 0.2126, 0.7152, 0.0722; return ratio and inclusive gate.

contrast=(max(L1,L2)+0.05)/(min(L1,L2)+0.05)

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
contrastRatioContrast rationumber; minimum: 1
meetsMinimumMeets supplied minimumboolean
json
{
  "input": {
    "foregroundHex": "#000000",
    "backgroundHex": "#ffffff",
    "minimumContrastRatio": 7
  },
  "output": {
    "contrastRatio": 21,
    "meetsMinimum": true
  }
}

Limitations and assumptions

No alpha blending, gradients, rendered text, font size or whole-page accessibility is evaluated.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors. A successfully returned false flag is an evaluated outcome; its meaning is explained above.

Alternative or Complementary methods

Use Choropleth Bin Classifier: Classify numeric map values with quantile or Jenks natural-break bins. For a complementary task, use Lower-Third Fit: Check lower-third line and total character limits.

Further background: Understanding Contrast (Minimum).

References

  1. Palette Contrast — tool.io

  2. Understanding Contrast (Minimum) — World Wide Web Consortium

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies