Auto Black/White Text Picker

Select higher WCAG-style relative-luminance black/white text contrast on actual opaque sRGB background, with deterministic black tie; caller threshold is not full typography, alpha/compositing, WCAG conformance or APCA analysis.

Description

Opaque background relative luminance determines black and white text contrast.

Opaque background relative luminance determines black and white text contrast. The larger ratio is an objective choice within these two candidates.1, 2

Enter normalized opaque sRGB and positive caller contrast threshold≤21. Decode channels and use linear weights 0.2126/0.7152/0.0722. Return both ratios, selected HEX/ratio and inclusive gate; exact ties select black.

When to use Auto Black/White Text Picker

Use Auto Black/White Text Picker when you need to evaluate the supplied records under the calculation and evidence rules below. No alpha compositing, typography assessment, complete WCAG conformance or APCA analysis is supplied.

Prepare colors in the stated color space and scale. Use encoded RGB fractions, linear RGB, Lab, xy, byte values or ink percentages exactly as requested; supply caller tolerances and reference conditions.

How to use Auto Black/White Text Picker and understand its results

  1. Prepare colors in the stated color space and scale. Use encoded RGB fractions, linear RGB, Lab, xy, byte values or ink percentages exactly as requested; supply caller tolerances and reference conditions.
  2. Enter opaqueBackgroundRgb, callerMinimumContrastRatio using the field table and calculation rules, then run the tool.
  3. Read blackTextContrastRatio, whiteTextContrastRatio, selectedTextHex, selectedContrastRatio, meetsCallerContrastPolicy. 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
opaqueBackgroundRgbOpaque background rgblist of numberRequired
callerMinimumContrastRatioCaller minimum contrast rationumberRequired

Enter normalized opaque sRGB and positive caller contrast threshold≤21. Decode channels and use linear weights 0.2126/0.7152/0.0722. Return both ratios, selected HEX/ratio and inclusive gate; exact ties select black.

black=(L+0.05)/0.05; white=1.05/(L+0.05)

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

Output fieldMeaningValue type
blackTextContrastRatioBlack text contrast rationumber
whiteTextContrastRatioWhite text contrast rationumber
selectedTextHexSelected text hexstring
selectedContrastRatioSelected contrast rationumber
meetsCallerContrastPolicyMeets caller contrast policyboolean
json
{
  "input": {
    "opaqueBackgroundRgb": [
      0,
      0,
      0
    ],
    "callerMinimumContrastRatio": 4.5
  },
  "output": {
    "blackTextContrastRatio": 1,
    "whiteTextContrastRatio": 21,
    "selectedTextHex": "#FFFFFF",
    "selectedContrastRatio": 21,
    "meetsCallerContrastPolicy": true
  }
}

Limitations and assumptions

No alpha compositing, typography assessment, complete WCAG conformance or APCA analysis is supplied.

Numeric inputs, where present, must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Numeric lists are limited to 10,000 entries; string lists to 128 strings of at most 128 characters each. The rules above may impose smaller limits. 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 YIQ Luma Value Calculator: YIQ luma combines encoded color channels with legacy weights. It differs from linear-light relative luminance. For a complementary task, use Dark-Mode Lightness Inversion Heuristic: A dark-theme heuristic can invert HSL lightness and constrain it to chosen bounds. Contrast needs a separate check.

Further background: Understanding WCAG 2.2 Contrast (Minimum).

References

  1. Auto Black/White Text Picker — tool.io

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

Similar or alternative tools

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