Color Utilities

Hsl To Hex

Converts HSL color values to hexadecimal format with precise calculations. Use via MCP in Cursor or Windsurf for instant color conversions, or call GET /v1/color/hsl-to-hex directly. Input hsl(240, 100%, 50%) returns #0000FF. Handles full HSL range including edge cases like 0% saturation gracefully.

API Endpoint

GET /v1/color/hsl-to-hex

Code Examples

curl "https://tinyfn.io/v1/color/hsl-to-hex" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/color/hsl-to-hex', {
  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/hsl-to-hex',
    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 color tools:

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

Learn more about MCP setup →

FAQ

What HSL input formats does the converter accept?

Accepts standard HSL notation like hsl(240, 100%, 50%) and individual H/S/L parameters. Hue ranges 0-360°, saturation and lightness 0-100%.

How do I convert HSL colors in my AI coding assistant?

Enable TinyFn's MCP tools in Cursor, Claude Code, or Windsurf. Ask 'convert hsl(180, 50%, 75%) to hex' and get instant, accurate results without manual calculation.

Does HSL to hex conversion handle grayscale colors correctly?

Yes, properly converts grayscale (0% saturation) and extreme lightness values. hsl(0, 0%, 50%) correctly becomes #808080, not approximated values.

What's the difference between HSL and HSV color conversion?

HSL uses lightness (0% = black, 100% = white), while HSV uses brightness/value. Same hue/saturation values produce different colors in each system.

Can I batch convert multiple HSL colors to hex at once?

The endpoint processes single conversions. For batch operations, make multiple API calls or use the MCP tool repeatedly in your AI assistant workflow.

Try Hsl To Hex Now

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

Get Free API Key