Skip to content

Contrast

For a page, a badge, or a social card. Start with Getting started. This route does not fetch a URL.

GET /v1/contrast compares two hex colours with the WCAG relative luminance formula. The answer is the ratio, such as 21:1 for black on white. Pass flags use the unrounded ratio.

  • Normal text AA is 4.5:1. AAA is 7:1.
  • Large text means 18pt, or 14pt bold. AA is 3:1. AAA is 4.5:1.

Hex is 3 or 6 digits, with or without a leading hash. Names, rgb(), and 8-digit alpha are refused.

Try it

https://fetch.li/v1/contrast?fg=111111&bg=00ff85

Parameters

Name Required Notes
fg yes Foreground hex
bg yes Background hex

Related

Style, demo, and spreadsheets.

Try it

GET https://fetch.li/v1/contrast


    
    
    
  

Answer

Response

response