Color Utilities

Name To Hex

Converts CSS color names like "red" or "steelblue" to hex codes. Use via MCP in Cursor or Windsurf for instant color conversion, or call GET /v1/color/name-to-hex?name=crimson. Returns precise hex values like #DC143C for all 147 standard CSS colors. No guesswork — deterministic mapping from W3C specifications.

API Endpoint

GET /v1/color/name-to-hex

Code Examples

curl "https://tinyfn.io/v1/color/name-to-hex" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/color/name-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/name-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 CSS color names does this tool support?

All 147 standard CSS color names from the W3C specification, including basic colors like 'red', 'blue', extended colors like 'steelblue', 'mediumorchid', and system colors.

How do I convert a color name to hex using MCP in Cursor?

Just ask your AI assistant to convert a color name. The MCP tool will automatically call the conversion function and return the exact hex code.

What happens if I pass an invalid color name?

The tool returns an error for unrecognized names. Only official CSS color names are supported — 'lightred' won't work, but 'lightcoral' will.

Does this handle case sensitivity for color names?

CSS color names are case-insensitive by specification, so 'RED', 'red', and 'Red' all return the same hex value #FF0000.

Can I get RGB values instead of hex codes?

This tool specifically returns hex format. Use TinyFn's separate hex-to-rgb converter if you need RGB values from the hex output.

Try Name To Hex Now

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

Get Free API Key