Miscellaneous Utilities

Rgb To Hsl

Converts RGB color values to HSL (Hue, Saturation, Lightness) format with precise mathematical accuracy. Access via MCP in Cursor or Windsurf for color palette generation, or call GET /v1/misc/rgb-to-hsl directly. Input RGB(255, 128, 0) returns HSL(30°, 100%, 50%). Essential for design workflows requiring perceptual color adjustments.

API Endpoint

GET /v1/misc/rgb-to-hsl

Code Examples

curl "https://tinyfn.io/v1/misc/rgb-to-hsl" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/misc/rgb-to-hsl', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/misc/rgb-to-hsl',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's miscellaneous tools:

{
  "mcpServers": {
    "tinyfn-misc": {
      "url": "https://tinyfn.io/mcp/misc",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

What's the difference between RGB and HSL color spaces?

RGB uses red, green, blue additive values (0-255), while HSL represents hue (0-360°), saturation (0-100%), and lightness (0-100%) — making it more intuitive for human color perception and adjustments.

How do I convert RGB(255, 0, 128) to HSL using MCP?

Call the rgb-to-hsl tool with r=255, g=0, b=128. Returns HSL(318°, 100%, 50%) — a bright magenta with full saturation at medium lightness.

Can I pass RGB values as hex codes or percentages?

No, this tool expects integer RGB values from 0-255. Use separate hex-to-rgb conversion first, or calculate percentages to the 0-255 range.

Why use HSL instead of staying in RGB for color manipulation?

HSL makes it trivial to adjust brightness (lightness) or saturation independently, create color harmonies by shifting hue, and generate palettes that feel visually consistent.

Does the conversion handle edge cases like pure black or white?

Yes, RGB(0,0,0) converts to HSL(0°, 0%, 0%) and RGB(255,255,255) to HSL(0°, 0%, 100%). Hue becomes undefined (0°) when saturation is zero.

Try Rgb To Hsl Now

Get your free API key and start using Rgb To Hsl in seconds.

Get Free API Key