Calculates relative luminance (0-1 brightness value) for any color input using the WCAG standard formula. Access via MCP in Cursor, Windsurf, and other AI editors, or call GET /v1/color/luminance directly. Pass hex (#FF0000), RGB (255,0,0), or named colors (red) to get precise luminance values essential for contrast ratio calculations and accessibility compliance.
curl "https://tinyfn.io/v1/color/luminance" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/color/luminance', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/color/luminance',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's color tools:
{
"mcpServers": {
"tinyfn-color": {
"url": "https://tinyfn.io/mcp/color",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Relative luminance measures perceived brightness from 0 (black) to 1 (white) using the WCAG formula: 0.2126×R + 0.7152×G + 0.0722×B with gamma correction. It accounts for human eye sensitivity to different colors.
Accepts hex codes (#FF0000, #f00), RGB values (255,0,0 or rgb(255,0,0)), HSL format, and named colors (red, blue, etc.). Returns consistent decimal values regardless of input format.
Calculate contrast ratio using (L1 + 0.05) / (L2 + 0.05) where L1 is the lighter color's luminance. WCAG AA requires 4.5:1 for normal text, 3:1 for large text.
Yes, AI agents in Cursor or Windsurf can call this tool to check color combinations in code, automatically flag contrast issues, and suggest compliant alternatives during development.
Ensures WCAG-compliant calculations with proper gamma correction and sRGB handling. Eliminates common implementation errors in the complex luminance formula and supports multiple input formats.
Get your free API key and start using Get Luminance in seconds.
Get Free API Key