Hex, RGB, HSL

Color Converter API

Convert between hex, RGB, and HSL color formats with a single GET request. Includes automatic brightness detection for text contrast decisions.

What You Get Back

Hex

Standard #RRGGBB hex notation

RGB

Individual R, G, B values (0-255)

HSL

Hue, saturation, lightness values

Brightness

isLight boolean for contrast decisions

Code Examples

cURL

curl "https://api-snap.com/api/color?color=6366f1" \
  -H "Authorization: Bearer snp_your_key"
# {"hex":"#6366f1","rgb":{"r":99,"g":102,"b":241},"hsl":{"h":239,"s":84,"l":67},"isLight":false}

JavaScript

const res = await fetch(
  "https://api-snap.com/api/color?color=rgb(255,107,107)",
  { headers: { Authorization: "Bearer snp_your_key" } }
);
const { hex, hsl, isLight } = await res.json();

Python

import requests

r = requests.get(
    "https://api-snap.com/api/color",
    params={"color": "#22c55e"},
    headers={"Authorization": "Bearer snp_your_key"},
)
data = r.json()
print(f"RGB: {data['rgb']}, Light: {data['isLight']}")

Common Use Cases

Dynamic theming

Convert user-selected colors between formats for CSS custom properties

Accessible contrast

Use isLight to automatically choose black or white text on colored backgrounds

Design tools

Show hex, RGB, and HSL representations in color pickers and design apps

Data visualization

Convert between color spaces for chart libraries and gradient generation

Start Converting Colors

Hex, RGB, HSL — all formats, one API call.

Get Your Free API Key