⭐ ⭐ ⭐

xColors API

A free API for generating and converting colors

View on GitHub


xColors is a completely free service that provides the ability to get random colors and convert them into various color models (HEX, RGB and HSL are supported). All data comes in a convenient JSON format, so you can immediately use them for styling in CSS without additional validation.

Generating colors

🎲 Get random color

Get a JSON object that contains a random color in three HEX, RGB and HSL color models at once.

🎨 Get random color with a given hue

You can get random shades of the color you need. For example, using reserved names such as:

red pink puprle navy blue aqua green lime yellow orange

Instead of reserved words, you can use any number from the range [0, 359] - which corresponds to the HUE scale.

🔧 Parameters

The number parameter allows you to get an array containing the desired number of random colors.

The type parameter allows you to get either only a dark or light shade of color. This allows you to know in advance what font color to use against the background of the resulting color. Usually, the font color is white on dark colors, and black on light colors.

It works if you have specified the { hue / color } you need or use all - for an any color.

Converting —Āolors

You can freely convert colors between three color models. To do this, use the desired endpoint and use the value parameter to specify the color value of the color model, depending on the selected endpoint.

Convert HEX to RGB

Convert HEX to HSL

Convert RGB to HEX

Convert RGB to HSL

Convert HSL to HEX

Convert HSL to RGB