The Color API

App · Images & Design · 7 actions

Identify, convert and scheme colors with The Color API, the free keyless color service. Give it a color in any format, hex, rgb, hsl, hsv or cmyk, and get back its name, every other format and the text color that reads best on it; convert one value into another format; generate a monochrome, analogic, complementary, triad or quad scheme from a seed color; check how readable one color is on another against the WCAG contrast levels; pick a random color that a seed makes repeatable; or identify a whole list of brand colors in one step.

Actions

ActionWhat it does
Check service statusCheck whether The Color API is answering, and how quickly.
Compare two colorsCompare two colors: how readable text in one is on the other, as the WCAG contrast ratio with a pass or fail at each level, and how far apart they look, as a color difference where about 2 is the least a person notices and 100 is black against white.
Convert a colorConvert one color into another format and get the converted value as a string ready to paste into a stylesheet, a design tool or a message, with its components beside it.
Generate a color schemeGenerate a color scheme from a seed color: shades of the one hue, its neighbors on the color wheel, its opposite, or three or four hues evenly spaced around it.
Get a random colorPick a color at random and identify it, for an accent, a label or a placeholder that should not be the same every time.
Identify a colorIdentify one color: its name from a dataset of some two thousand named colors, the same color in hex, rgb, hsl, hsv, cmyk and XYZ, whether it is dark, the text color that reads best on it, and a link to a swatch image.
Identify several colorsIdentify a list of colors in one step, up to 10 at a time, in the order given: a brand palette, the colors pulled out of a design file, the swatches in a spreadsheet column.

Check service status

Check whether The Color API is answering, and how quickly. This is the one action that reports a problem as a value instead of failing the step, so a workflow can decide what to do about it.

Inputs

None.

Outputs

messagetext
What was found, in one sentence.
onlinetrue/false
True when the service answered with a color.
reachabletrue/false
True when the service answered at all, even with an error.
response_time_msnumber
How long it took to answer, in milliseconds.
status_codenumber
The HTTP status it answered with; empty if none.
Example output
{
  "message": "The Color API is up and answering.",
  "online": true,
  "reachable": true,
  "response_time_ms": 88.4,
  "status_code": 200
}

Compare two colors

Compare two colors: how readable text in one is on the other, as the WCAG contrast ratio with a pass or fail at each level, and how far apart they look, as a color difference where about 2 is the least a person notices and 100 is black against white. Both colors come back fully identified, so a step can also tell whether they share a name or are the same color spelled two ways. The service has no route for any of this; both colors are identified and the rest is worked out here.

Inputs

Text or foreground colorcolortextRequired
The color, in any of these formats: a hex code such as #0047AB or 0047AB, rgb(0,71,171), hsl(215,100%,34%), hsv(215,100%,67%) or cmyk(100,58,0,33). Three bare numbers are read as rgb, three with a percent sign as hsl and four as cmyk. Wire in a value from an earlier step, or type one.
Background or other colorothertextRequired
The color, in any of these formats: a hex code such as #0047AB or 0047AB, rgb(0,71,171), hsl(215,100%,34%), hsv(215,100%,67%) or cmyk(100,58,0,33). Three bare numbers are read as rgb, three with a percent sign as hsl and four as cmyk. Wire in a value from an earlier step, or type one.

Outputs

colorobject
The text or foreground color, identified.
contrast_rationumber
The WCAG contrast ratio, to two decimal places: 1 for the same color up to 21 for black on white.
darkertext
The hex code of the darker color.
delta_enumber
How different they look (CIE76 color difference): 0 for identical, about 2 for the least a person notices, about 100 for black against white.
gradetext
The best WCAG level the pair reaches for text: AAA, AA, AA-large (large text only) or fail.
identicaltrue/false
True when both are the same color (one hex code).
lightertext
The hex code of the lighter color.
otherobject
The background or other color, identified.
same_nametrue/false
True when both have the same nearest name.
wcagobject
Whether the pair passes each WCAG 2 contrast level.
Example output
{
  "color": {
    "closest_named_hex": "#0047AB",
    "cmyk": {
      "c": 100,
      "k": 33,
      "m": 58,
      "value": "cmyk(100, 58, 0, 33)",
      "y": 0
    },
    "exact_match_name": true,
    "hex": "#0047AB",
    "hex_clean": "0047AB",
    "hsl": {
      "h": 215,
      "l": 34,
      "s": 100,
      "value": "hsl(215, 100%, 34%)"
    },
    "hsv": {
      "h": 215,
      "s": 100,
      "v": 67,
      "value": "hsv(215, 100%, 67%)"
    },
    "image_url": "https://www.thecolorapi.com/id?format=svg&hex=0047AB",
    "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=0047AB",
    "is_dark": true,
    "name": "Cobalt",
    "name_distance": 0,
    "rgb": {
      "b": 171,
      "g": 71,
      "r": 0,
      "value": "rgb(0, 71, 171)"
    },
    "text_color": "#FFFFFF",
    "xyz": {
      "value": "XYZ(22, 25, 67)",
      "x": 22,
      "y": 25,
      "z": 67
    }
  },
  "contrast_ratio": 8.44,
  "darker": "#0047AB",
  "delta_e": 91.9,
  "grade": "AAA",
  "identical": false,
  "lighter": "#FFFFFF",
  "other": {
    "closest_named_hex": "#FFFFFF",
    "cmyk": {
      "c": 0,
      "k": 0,
      "m": 0,
      "value": "cmyk(0, 0, 0, 0)",
      "y": 0
    },
    "exact_match_name": true,
    "hex": "#FFFFFF",
    "hex_clean": "FFFFFF",
    "hsl": {
      "h": 0,
      "l": 100,
      "s": 0,
      "value": "hsl(0, 0%, 100%)"
    },
    "hsv": {
      "h": 0,
      "s": 0,
      "v": 100,
      "value": "hsv(0, 0%, 100%)"
    },
    "image_url": "https://www.thecolorapi.com/id?format=svg&hex=FFFFFF",
    "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=FFFFFF",
    "is_dark": false,
    "name": "White",
    "name_distance": 0,
    "rgb": {
      "b": 255,
      "g": 255,
      "r": 255,
      "value": "rgb(255, 255, 255)"
    },
    "text_color": "#000000",
    "xyz": {
      "value": "XYZ(95, 100, 108.883)",
      "x": 95,
      "y": 100,
      "z": 109
    }
  },
  "same_name": false,
  "wcag": {
    "aa_large_text": true,
    "aa_normal_text": true,
    "aaa_large_text": true,
    "aaa_normal_text": true
  }
}

Convert a color

Convert one color into another format and get the converted value as a string ready to paste into a stylesheet, a design tool or a message, with its components beside it. Any of hex, rgb, hsl, hsv and cmyk converts to any other; the hex code and the name come back too, whatever the target.

Inputs

ColorcolortextRequired
The color, in any of these formats: a hex code such as #0047AB or 0047AB, rgb(0,71,171), hsl(215,100%,34%), hsv(215,100%,67%) or cmyk(100,58,0,33). Three bare numbers are read as rgb, three with a percent sign as hsl and four as cmyk. Wire in a value from an earlier step, or type one.
Convert tototextRequired
The format to convert the color into.One of: hex, rgb, hsl, hsv, cmyk.
Color formatcolor_formattext
Which format the color is written in. Leave empty to work it out from the value, which is right for anything but a bare hsv triple: 215,100%,67% reads as hsl unless this says HSV.One of: hex, rgb, hsl, hsv, cmyk.

Outputs

componentsobject
The converted color's parts, holding only the keys of the target format: r, g and b for rgb; h, s and l for hsl; h, s and v for hsv; c, m, y and k for cmyk; hex for hex.
hextext
The color's hex code, whatever the target.
inputtext
The color as it was given, trimmed.
input_formattext
The format the color was read as: hex, rgb, hsl, hsv or cmyk.
nametext
The name of the nearest named color.
totext
The format converted to: hex, rgb, hsl, hsv or cmyk.
valuetext
The converted color as text, ready to paste, such as hsl(215, 100%, 34%) or #0047AB.
Example output
{
  "components": {
    "h": 215,
    "l": 34,
    "s": 100
  },
  "hex": "#0047AB",
  "input": "#0047AB",
  "input_format": "hex",
  "name": "Cobalt",
  "to": "hsl",
  "value": "hsl(215, 100%, 34%)"
}

Generate a color scheme

Generate a color scheme from a seed color: shades of the one hue, its neighbors on the color wheel, its opposite, or three or four hues evenly spaced around it. Every color in the scheme comes back fully identified, with its name and every format, and the hex codes as a plain list for a step that only wants those. Ask for 1 to 50 colors; the service's own default is 5, and a triad always has at least 3 and a quad at least 4.

Inputs

Seed colorcolortextRequired
The color, in any of these formats: a hex code such as #0047AB or 0047AB, rgb(0,71,171), hsl(215,100%,34%), hsv(215,100%,67%) or cmyk(100,58,0,33). Three bare numbers are read as rgb, three with a percent sign as hsl and four as cmyk. Wire in a value from an earlier step, or type one.
Schememodetext
How the scheme is built from the seed. Monochrome keeps the hue and varies the lightness; analogic takes the neighboring hues; complement takes the opposite hue; triad and quad space three or four hues evenly. Defaults to monochrome.One of: monochrome, monochrome-dark (Monochrome, darker), monochrome-light (Monochrome, lighter), analogic (Analogic (neighboring hues)), complement (Complement (the opposite hue)), analogic-complement (Analogic complement), triad (Triad (three hues evenly spaced)), quad (Quad (four hues evenly spaced)).
Number of colorscountnumber
How many colors to generate, from 1 to 50. Defaults to 5. A scheme of several hues needs at least one color for each, so a smaller number is raised to that: 2 for a complement, an analogic complement or a darker or lighter monochrome, 3 for a triad and 4 for a quad.From 1 to 50.
Color formatcolor_formattext
Which format the color is written in. Leave empty to work it out from the value, which is right for anything but a bare hsv triple: 215,100%,67% reads as hsl unless this says HSV.One of: hex, rgb, hsl, hsv, cmyk.

Outputs

color_countnumber
How many colors the scheme came back with.
colorslist
The colors of the scheme, each identified.
countnumber
How many colors the service was asked to generate: the requested count, raised to the fewest this mode makes.
hex_valueslist
The hex code of each color in the scheme, in order.
image_urltext
A link to an SVG strip of the scheme's colors with their names.
image_url_baretext
A link to an SVG strip of the scheme's colors with no text.
inputtext
The color as it was given, trimmed.
input_formattext
The format the color was read as: hex, rgb, hsl, hsv or cmyk.
modetext
The scheme mode used, such as triad.
requested_countnumber
How many colors the step asked for, kept to 1 to 50.
seedobject
The seed color, identified.
Example output
{
  "color_count": 2,
  "colors": [
    {
      "closest_named_hex": "#08E8DE",
      "cmyk": {
        "c": 93,
        "k": 18,
        "m": 0,
        "value": "cmyk(93, 0, 0, 18)",
        "y": 0
      },
      "exact_match_name": false,
      "hex": "#0ED1D1",
      "hex_clean": "0ED1D1",
      "hsl": {
        "h": 180,
        "l": 44,
        "s": 87,
        "value": "hsl(180, 87%, 44%)"
      },
      "hsv": {
        "h": 180,
        "s": 93,
        "v": 82,
        "value": "hsv(180, 93%, 82%)"
      },
      "image_url": "https://www.thecolorapi.com/id?format=svg&hex=0ED1D1",
      "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=0ED1D1",
      "is_dark": false,
      "name": "Bright Turquoise",
      "name_distance": 1416,
      "rgb": {
        "b": 209,
        "g": 209,
        "r": 14,
        "value": "rgb(14, 209, 209)"
      },
      "text_color": "#000000",
      "xyz": {
        "value": "XYZ(46, 66, 88)",
        "x": 46,
        "y": 66,
        "z": 88
      }
    },
    {
      "closest_named_hex": "#FF0000",
      "cmyk": {
        "c": 0,
        "k": 3,
        "m": 97,
        "value": "cmyk(0, 97, 97, 3)",
        "y": 97
      },
      "exact_match_name": false,
      "hex": "#F70808",
      "hex_clean": "F70808",
      "hsl": {
        "h": 0,
        "l": 50,
        "s": 94,
        "value": "hsl(0, 94%, 50%)"
      },
      "hsv": {
        "h": 0,
        "s": 97,
        "v": 97,
        "value": "hsv(0, 97%, 97%)"
      },
      "image_url": "https://www.thecolorapi.com/id?format=svg&hex=F70808",
      "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=F70808",
      "is_dark": false,
      "name": "Red",
      "name_distance": 704,
      "rgb": {
        "b": 8,
        "g": 8,
        "r": 247,
        "value": "rgb(247, 8, 8)"
      },
      "text_color": "#000000",
      "xyz": {
        "value": "XYZ(42, 23, 5)",
        "x": 42,
        "y": 23,
        "z": 5
      }
    }
  ],
  "count": 2,
  "hex_values": [
    "#0ED1D1",
    "#F70808"
  ],
  "image_url": "https://www.thecolorapi.com/scheme?format=svg&hex=FF0000&mode=complement&count=2",
  "image_url_bare": "https://www.thecolorapi.com/scheme?format=svg&named=false&hex=FF0000&mode=complement&count=2",
  "input": "#FF0000",
  "input_format": "hex",
  "mode": "complement",
  "requested_count": 2,
  "seed": {
    "closest_named_hex": "#FF0000",
    "cmyk": {
      "c": 0,
      "k": 0,
      "m": 100,
      "value": "cmyk(0, 100, 100, 0)",
      "y": 100
    },
    "exact_match_name": true,
    "hex": "#FF0000",
    "hex_clean": "FF0000",
    "hsl": {
      "h": 0,
      "l": 50,
      "s": 100,
      "value": "hsl(0, 100%, 50%)"
    },
    "hsv": {
      "h": 0,
      "s": 100,
      "v": 100,
      "value": "hsv(0, 100%, 100%)"
    },
    "image_url": "https://www.thecolorapi.com/id?format=svg&hex=FF0000",
    "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=FF0000",
    "is_dark": false,
    "name": "Red",
    "name_distance": 0,
    "rgb": {
      "b": 0,
      "g": 0,
      "r": 255,
      "value": "rgb(255, 0, 0)"
    },
    "text_color": "#000000",
    "xyz": {
      "value": "XYZ(41, 21, 2)",
      "x": 41,
      "y": 21,
      "z": 2
    }
  }
}

Get a random color

Pick a color at random and identify it, for an accent, a label or a placeholder that should not be the same every time. Add a seed to make the pick repeatable: the same seed always gives the same color, so naming a customer, a project or a date here gives each its own color that a later run finds again.

Inputs

Seedseedtext
Any text you like. The same seed always gives the same color, and a different seed almost always gives a different one. Leave empty for a fresh random color on every run.

Outputs

colorobject
The color picked, identified.
seedtext
The seed the color was picked by; empty if none.
Example output
{
  "color": {
    "closest_named_hex": "#1DACD6",
    "cmyk": {
      "c": 84,
      "k": 12,
      "m": 21,
      "value": "cmyk(84, 21, 0, 12)",
      "y": 0
    },
    "exact_match_name": false,
    "hex": "#24B1E0",
    "hex_clean": "24B1E0",
    "hsl": {
      "h": 195,
      "l": 51,
      "s": 75,
      "value": "hsl(195, 75%, 51%)"
    },
    "hsv": {
      "h": 195,
      "s": 84,
      "v": 88,
      "value": "hsv(195, 84%, 88%)"
    },
    "image_url": "https://www.thecolorapi.com/id?format=svg&hex=24B1E0",
    "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=24B1E0",
    "is_dark": false,
    "name": "Cerulean",
    "name_distance": 356,
    "rgb": {
      "b": 224,
      "g": 177,
      "r": 36,
      "value": "rgb(36, 177, 224)"
    },
    "text_color": "#000000",
    "xyz": {
      "value": "XYZ(46, 59, 92)",
      "x": 46,
      "y": 59,
      "z": 92
    }
  },
  "seed": null
}

Identify a color

Identify one color: its name from a dataset of some two thousand named colors, the same color in hex, rgb, hsl, hsv, cmyk and XYZ, whether it is dark, the text color that reads best on it, and a link to a swatch image. Give it the color in any of those formats. A malformed color is refused here with a message, because the service itself would quietly identify it as black.

Inputs

ColorcolortextRequired
The color, in any of these formats: a hex code such as #0047AB or 0047AB, rgb(0,71,171), hsl(215,100%,34%), hsv(215,100%,67%) or cmyk(100,58,0,33). Three bare numbers are read as rgb, three with a percent sign as hsl and four as cmyk. Wire in a value from an earlier step, or type one.
Color formatcolor_formattext
Which format the color is written in. Leave empty to work it out from the value, which is right for anything but a bare hsv triple: 215,100%,67% reads as hsl unless this says HSV.One of: hex, rgb, hsl, hsv, cmyk.

Outputs

colorobject
The color, identified.
inputtext
The color as it was given, trimmed.
input_formattext
The format the color was read as: hex, rgb, hsl, hsv or cmyk.
Example output
{
  "color": {
    "closest_named_hex": "#0047AB",
    "cmyk": {
      "c": 100,
      "k": 33,
      "m": 58,
      "value": "cmyk(100, 58, 0, 33)",
      "y": 0
    },
    "exact_match_name": true,
    "hex": "#0047AB",
    "hex_clean": "0047AB",
    "hsl": {
      "h": 215,
      "l": 34,
      "s": 100,
      "value": "hsl(215, 100%, 34%)"
    },
    "hsv": {
      "h": 215,
      "s": 100,
      "v": 67,
      "value": "hsv(215, 100%, 67%)"
    },
    "image_url": "https://www.thecolorapi.com/id?format=svg&hex=0047AB",
    "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=0047AB",
    "is_dark": true,
    "name": "Cobalt",
    "name_distance": 0,
    "rgb": {
      "b": 171,
      "g": 71,
      "r": 0,
      "value": "rgb(0, 71, 171)"
    },
    "text_color": "#FFFFFF",
    "xyz": {
      "value": "XYZ(22, 25, 67)",
      "x": 22,
      "y": 25,
      "z": 67
    }
  },
  "input": "#0047AB",
  "input_format": "hex"
}

Identify several colors

Identify a list of colors in one step, up to 10 at a time, in the order given: a brand palette, the colors pulled out of a design file, the swatches in a spreadsheet column. Each is looked up as Identify a color does, one request each, and the names and hex codes come back as plain lists beside the full records. Every entry is checked before the first request is made, so a bad one fails the step without spending requests on the good ones ahead of it.

Inputs

ColorscolorslistRequired
The colors to identify, one per entry, each in any format The Color API reads. Wire a list in from an earlier step, or type them one per line.
Color formatcolor_formattext
Which format the color is written in. Leave empty to work it out from the value, which is right for anything but a bare hsv triple: 215,100%,67% reads as hsl unless this says HSV.One of: hex, rgb, hsl, hsv, cmyk.

Outputs

color_countnumber
How many colors were identified.
colorslist
Each color, identified, in the order given.
hex_valueslist
The hex code of each color, in the order given.
inputslist
The colors as they were given, trimmed, in order.
nameslist
The name of each color's nearest named color, in the order given.
Example output
{
  "color_count": 2,
  "colors": [
    {
      "closest_named_hex": "#0047AB",
      "cmyk": {
        "c": 100,
        "k": 33,
        "m": 58,
        "value": "cmyk(100, 58, 0, 33)",
        "y": 0
      },
      "exact_match_name": true,
      "hex": "#0047AB",
      "hex_clean": "0047AB",
      "hsl": {
        "h": 215,
        "l": 34,
        "s": 100,
        "value": "hsl(215, 100%, 34%)"
      },
      "hsv": {
        "h": 215,
        "s": 100,
        "v": 67,
        "value": "hsv(215, 100%, 67%)"
      },
      "image_url": "https://www.thecolorapi.com/id?format=svg&hex=0047AB",
      "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=0047AB",
      "is_dark": true,
      "name": "Cobalt",
      "name_distance": 0,
      "rgb": {
        "b": 171,
        "g": 71,
        "r": 0,
        "value": "rgb(0, 71, 171)"
      },
      "text_color": "#FFFFFF",
      "xyz": {
        "value": "XYZ(22, 25, 67)",
        "x": 22,
        "y": 25,
        "z": 67
      }
    },
    {
      "closest_named_hex": "#1DACD6",
      "cmyk": {
        "c": 84,
        "k": 12,
        "m": 21,
        "value": "cmyk(84, 21, 0, 12)",
        "y": 0
      },
      "exact_match_name": false,
      "hex": "#24B1E0",
      "hex_clean": "24B1E0",
      "hsl": {
        "h": 195,
        "l": 51,
        "s": 75,
        "value": "hsl(195, 75%, 51%)"
      },
      "hsv": {
        "h": 195,
        "s": 84,
        "v": 88,
        "value": "hsv(195, 84%, 88%)"
      },
      "image_url": "https://www.thecolorapi.com/id?format=svg&hex=24B1E0",
      "image_url_bare": "https://www.thecolorapi.com/id?format=svg&named=false&hex=24B1E0",
      "is_dark": false,
      "name": "Cerulean",
      "name_distance": 356,
      "rgb": {
        "b": 224,
        "g": 177,
        "r": 36,
        "value": "rgb(36, 177, 224)"
      },
      "text_color": "#000000",
      "xyz": {
        "value": "XYZ(46, 59, 92)",
        "x": 46,
        "y": 59,
        "z": 92
      }
    }
  ],
  "hex_values": [
    "#0047AB",
    "#24B1E0"
  ],
  "inputs": [
    "#0047AB",
    "rgb(36,177,224)"
  ],
  "names": [
    "Cobalt",
    "Cerulean"
  ]
}

On this page