Color Utilities

Is Valid Hex

Validates hex color strings with precise formatting rules. Use via MCP in Cursor or Windsurf, or call GET /v1/color/is-valid-hex with your color string. Returns true/false for formats like #FF0000, #abc, or abc. Perfect for form validation or AI agents processing user-submitted colors without guessing.

API Endpoint

GET /v1/color/is-valid-hex

Code Examples

curl "https://tinyfn.io/v1/color/is-valid-hex" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/color/is-valid-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/is-valid-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 hex color formats does the validator accept?

Accepts 3-digit (#abc), 6-digit (#FF0000), and versions without the hash prefix (abc, FF0000). Case insensitive for A-F characters.

How do I validate hex colors in an MCP-enabled editor?

Call the is-valid-hex tool directly in Cursor, Windsurf, or other MCP editors. Pass the color string as a parameter and get instant true/false validation.

Does it validate CSS color keywords like 'red' or 'blue'?

No, only validates hexadecimal color notation. Use a separate CSS color validator for named colors or rgb() values.

What happens with invalid characters in the hex string?

Returns false for any non-hexadecimal characters (G-Z) or incorrect length. Strict validation prevents malformed colors from passing through.

Can I batch validate multiple hex colors at once?

No, validates one color per request. For batch validation, make separate API calls or use the MCP tool iteratively in your AI workflow.

Try Is Valid Hex Now

Get your free API key and start using Is Valid Hex in seconds.

Get Free API Key