xColors API
Free colour API with no key: generate random colours returned simultaneously as hex, RGB and HSL, or convert between the three formats. Tested example included.
Endpoint tested and returned HTTP 200 on 2026-08-21
What is the xColors API?
xColors generates random colours and converts between formats with no API key. A random request returns the same colour in three notations at once — hex, RGB and HSL — so you do not have to convert anything yourself.
The design decision worth noticing here is that one request returns all three notations rather than making you pick. CSS wants hex in one place, `rgb()` in another and `hsl()` when you are adjusting lightness programmatically, so returning all three eliminates a conversion step that is easy to get subtly wrong with rounding.
Beyond the random endpoint there are conversion routes between hex, RGB and HSL, and parameters that constrain generation — `type=light` or `type=dark` bias the output, and a hue range narrows it to a family. That makes it usable for generating a coherent set rather than a scatter of unrelated colours. It is a small open-source project running on a modest host, so cache what you generate rather than calling it per render.
Quick facts
- Base URL
https://x-colors.yurace.pro/api- Authentication
- No API key and no account.
- Rate limit
- No published limit. It is a small open-source project — keep volumes considerate.
- Pricing
- Free and open source.
- CORS
- Enabled — callable directly from browser JavaScript
- Official docs
- Read the docs
How to use the xColors API
Every request below was executed against the live API on 2026-08-21, and the response shown is the real body it returned — not an illustration.
1. Generate a random colour in three formats
GET https://x-colors.yurace.pro/api/random
curl 'https://x-colors.yurace.pro/api/random'const res = await fetch("https://x-colors.yurace.pro/api/random");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
res = requests.get("https://x-colors.yurace.pro/api/random", timeout=20)
res.raise_for_status()
print(res.json()){
"hex": "#F66BFF",
"rgb": "rgb(246, 107, 255)",
"hsl": "hsl(296, 100%, 71%)"
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | query | Optional | Bias generation towards `light`, `dark` or a specific hue family. light |
number | query | Optional | How many colours to generate in one request. 5 |
/hex-to-rgb | path | Optional | Conversion route. Sibling routes cover the other format pairings. |
/random-pastel | path | Optional | Generate pastel colours specifically. |
Response fields
hexstring- Hex notation with the leading hash, uppercase — for example `#F66BFF`.
rgbstring- A ready-to-use CSS `rgb(r, g, b)` string, not a component object.
hslstring- A ready-to-use CSS `hsl(h, s%, l%)` string. Useful when you want to shift lightness programmatically.
What you can build with the xColors API
- Generate placeholder colours for a design system prototype
- Convert a hex value to HSL without writing the maths
- Build a colour picker with a randomise button
- Produce a coherent light or dark palette using the type parameter
Common errors and how to fix them
Cannot read the red channel
`rgb` is a formatted CSS string, not an object with components.
Fix: Parse the numbers out of the string, or convert from `hex` yourself if you need components.
Colours are unusable together
Random generation makes no attempt at harmony.
Fix: Use `type` to constrain lightness or hue, or generate several and filter for contrast.
Slow or unavailable
Small open-source project on modest hosting.
Fix: Cache results and do not put it on a render path. The library can also be self-hosted.
xColors API — frequently asked questions
Is the xColors API free?
Yes, free with no key. It is an open-source project, so you can also run your own instance.
Why does it return three formats?
Because CSS needs different notations in different places, and converting between them by hand introduces rounding mistakes. Returning hex, RGB and HSL together removes that step.
Can I control the kind of colour generated?
Yes. The `type` parameter biases towards light or dark or a hue family, and there are dedicated routes for pastels.
Can it convert an existing colour?
Yes, through conversion routes covering the hex, RGB and HSL pairings, so it works as a converter as well as a generator.
Tools that pair with this API
CSS Color Format Converter
Turn one colour into every modern CSS syntax at once: hex, rgb, hsl, hwb, lab, lch, oklab, oklch and display-p3, each with its own copy button.
Random Color Generator
Generate a random color palette in one click. Lock the swatches you like, re-roll the rest, and copy the result as a HEX list or ready CSS variables.
Color Mixer
Mix two colors together with an adjustable ratio slider and get the blended HEX and RGB instantly. Free online color blender with a live swatch preview.
xColors is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-21; always check the official documentation before relying on this API in production, as terms and limits can change.