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
- 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.
- Enter opaqueBackgroundRgb, callerMinimumContrastRatio using the field table and calculation rules, then run the tool.
- Read blackTextContrastRatio, whiteTextContrastRatio, selectedTextHex, selectedContrastRatio, meetsCallerContrastPolicy. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- 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 field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| opaqueBackgroundRgb | Opaque background rgb | list of number | Required |
| callerMinimumContrastRatio | Caller minimum contrast ratio | number | Required |
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 field | Meaning | Value type |
|---|---|---|
| blackTextContrastRatio | Black text contrast ratio | number |
| whiteTextContrastRatio | White text contrast ratio | number |
| selectedTextHex | Selected text hex | string |
| selectedContrastRatio | Selected contrast ratio | number |
| meetsCallerContrastPolicy | Meets caller contrast policy | boolean |
{
"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
-
Auto Black/White Text Picker — tool.io
-
Understanding WCAG 2.2 Contrast (Minimum) — World Wide Web Consortium
Similar or alternative tools
- YIQ Luma Value Calculator
YIQ luma combines encoded color channels with legacy weights. It differs from linear-light relative luminance.
- Dark-Mode Lightness Inversion Heuristic
A dark-theme heuristic can invert HSL lightness and constrain it to chosen bounds. Contrast needs a separate check.