Conversion Utilities

Hex To Rgb

Converts hex color codes to RGB values with precise decimal output. Access via MCP in Cursor or Windsurf, or call GET /v1/convert/color/hex-to-rgb directly. Input "#FF5733" returns rgb(255, 87, 51). Handles both 3-digit and 6-digit hex formats, with or without the hash prefix.

API Endpoint

GET /v1/convert/color/hex-to-rgb

Code Examples

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

response = requests.get('https://tinyfn.io/v1/convert/color/hex-to-rgb',
    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 conversion tools:

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

Learn more about MCP setup →

FAQ

How do I convert hex colors to RGB using MCP in my IDE?

Use the hex-to-rgb tool in any MCP-enabled editor like Cursor or Cline. Pass the hex value (e.g., '#3498db') and get back RGB components as separate numbers or formatted string.

What hex color formats are supported?

Supports 3-digit (#RGB), 6-digit (#RRGGBB), and both with or without the hash prefix. Examples: 'F00', '#FF0000', 'ff0000' all work for red.

What's the exact output format for RGB values?

Returns RGB as decimal integers 0-255. Typically structured as {r: 255, g: 87, b: 51} or similar object format, not CSS rgb() strings.

Can I batch convert multiple hex colors at once?

The endpoint processes one hex color per request. For batch operations, make multiple API calls or use the MCP tool iteratively in your AI workflow.

How does this differ from CSS color conversion functions?

Provides deterministic server-side conversion with guaranteed precision, unlike browser-dependent CSS parsing. Essential for AI agents needing reliable color math without hallucination.

Try Hex To Rgb Now

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

Get Free API Key