Free color API

A free JSON API for colors and palettes — no sign-up, no API key, CORS enabled. It runs on the same open-source swatchly-color engine as this site, on Cloudflare's edge.

Base URL

https://swatchly.xyz/api/v1

Endpoints

MethodPathWhat it returns
GET/color/{hex}Every format, name, contrast, shades, tints, harmonies and color-blindness simulation for one color.Try it →
GET/convert?color=Convert any notation — HEX, rgb(), hsl(), hsb(), cmyk(), lab(), lch(), oklch() or a CSS name.Try it →
GET/palette/{hexes}Palette info and accessible pairs. Add ?format= for CSS, SCSS, Tailwind, JSON, CSV, XML, SVG, ASE or PDF.Try it →
GET/generateGenerate a palette. Options: count, method, colors (lock with 'x' placeholders), seed.Try it →
GET/contrast?fg=&bg=WCAG 2.2 ratio with AA/AAA verdicts, plus APCA Lc.Try it →
GET/randomRandom colors. Options: count (1–50), style (any, pastel, vivid, dark, light, muted), seed.Try it →
GET/name?color=The closest name for a color, with similar names.Try it →
GET/names?q=Search ~5,000 color names.Try it →
GET/palettesCurated palettes. Options: tag, page, per_page.Try it →
GET/gradient?from=&to=Evenly spaced steps between two colors (OKLab).Try it →
GET/color-of-the-yearEvery Pantone Color of the Year since 2000 with approximate HEX and a palette for each.Try it →
GET/iphone-colorsRecent iPhone lineups and their finishes with approximate HEX.Try it →

curl

curl https://swatchly.xyz/api/v1/color/264653

curl "https://swatchly.xyz/api/v1/palette/1b264f-3e5c76-a3c4f3?format=tailwind-v4"

JavaScript

const res = await fetch("https://swatchly.xyz/api/v1/contrast?fg=1b264f&bg=f4e9cd");
const { ratio, wcag } = await res.json();
console.log(ratio, wcag.aa_normal); // 12.1 true

Fair use

The API is free for personal and commercial use. Responses for the same input are cached at the edge, so please cache on your side too and avoid hammering random endpoints. Colors are returned as uppercase HEX with a leading #. Errors return JSON with an error message and HTTP 400 or 404.