RGB to color temperature
Put a kelvin figure on a screen color: RGB 255, 200, 150 comes out at about 3634.1681 K. The estimate uses CIE chromaticity and McCamy’s classic formula, handy when no light meter is at hand. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Resistance (Ω)
- 255
- G
- 200
- B
- 150
- Kelvin
- 3,634.1681
- Cct
- 3,634.1681
- Creativity
- 3,634.1681
- X
- 0.3965345657
This RGB to color temperature calculator takes three sRGB channel intensities—red, green, and blue—each as an integer from zero through two hundred fifty-five, and estimates the correlated color temperature (CCT) in kelvin using a deterministic path through CIE XYZ, chromaticity coordinates, and McCamy's classic cubic approximation. Photographers, lighting designers, UI engineers, and students use this mapping when a screen color must be compared to a blackbody or daylight temperature band, when a palette note needs a single kelvin tag, or when homework asks for CCT from an RGB triple without a spectrophotometer. The engine inverse-compands each channel, multiplies by the D65 sRGB-to-XYZ matrix, forms x and y chromaticity, then evaluates McCamy's polynomial—never calling the network, sampling randomness, or depending on the clock.
What a kelvin value from RGB tells you
In the eight-bit sRGB model used by CSS and most web graphics, each of red, green, and blue is an integer channel from zero through two hundred fifty-five. Correlated color temperature asks a different question: roughly how warm or cool a stimulus looks along a blackbody-like scale measured in kelvin. This tool does not reverse-engineer a unique spectral power distribution—many spectra can share similar chromaticity—but it estimates CCT from the color's CIE 1931 chromaticity using McCamy's published cubic formula, which is widely used as a fast closed-form approximation.
Conversion first scales each channel by dividing by two hundred fifty-five, then undoes sRGB gamma so the values become linear light. Those linear channels pass through a fixed three-by-three matrix into CIE XYZ under illuminant D65. Chromaticity follows as x equals X over the sum of X, Y, and Z, and y equals Y over that same sum.
McCamy then forms n equals (x minus zero point three three two zero) divided by (zero point one eight five eight minus y), and CCT equals four hundred forty-nine n cubed plus three thousand five hundred twenty-five n squared plus six thousand eight hundred twenty-three point three n plus five thousand five hundred twenty point three three, in kelvin. There is no path that accepts percentages or floating-point channels as input, and no silent clamp of two hundred fifty-six down to two hundred fifty-five.
How r, g, and b are read and how Kelvin stays reproducible
Outer whitespace on string channels is trimmed; an optional leading plus is allowed only when the remaining characters are decimal digits that parse to an integer in range. A bare JavaScript number is accepted only when it is a finite integer inside zero through two hundred fifty-five; values such as one hundred twenty-eight point five fail validation rather than being rounded, and negative or two-hundred-fifty-six-plus values fail with a message that names the channel and states that it must stay inside zero through two hundred fifty-five.
Warm orange-heavy triples typically produce lower kelvin values near domestic tungsten ranges; cooler blue-heavy triples produce higher kelvin near daylight ranges. Remember that McCamy is an approximation optimized for a practical chromaticity neighborhood; extreme out-of-locus colors can yield extreme or less meaningful temperatures even when arithmetic succeeds, so treat the number as a deterministic estimate rather than a laboratory measurement.
Where RGB-to-Kelvin conversion fits in design, lighting, and software
Lighting designers meet this mapping when a mock-up uses screen RGB swatches and a production brief expects approximate kelvin tags for warm, neutral, or cool scenes, when two UI states should be labeled with relative warmth, or when a lookbook documents both hex and a rough CCT note side by side.
Photographers and video engineers use it when a reference color from a chart or frame grab needs a quick CCT estimate for whiteboard notes, when comparing graded looks that claim daylight versus tungsten balance, or when teaching white-balance concepts without specialized meters. Students see it in computer-graphics and color-science courses that introduce chromaticity after sRGB and XYZ, in digital photography classes that move between RGB pickers and kelvin sliders, and in interview warm-ups that ask for a mental convert of a short triple into a temperature band.
Pair it with Kelvin-to-RGB tools when you need the reverse direction, and with other free deterministic converters when you are building a small lab for design-system hygiene.
What you can do with it
Warm–cool palette tags
Label brand RGB triples with approximate kelvin CCT for lighting notes, mood boards, and design tokens.
Homework and teaching demos
Check student RGB-to-chromaticity-to-CCT work and live-demo McCamy without opaque calculator apps.
FAQ
What does the RGB to color temperature converter cost?
It is free in your browser on this page.
What range is allowed for r, g, and b?
Each channel must be an integer from 0 to 255 inclusive.
Why is pure black rejected?
Black has zero XYZ sum, so chromaticity x and y are undefined.
Is this the same as Kelvin-to-RGB color temperature tools?
No. This page estimates CCT from RGB (RGB → kelvin). Tools that map a kelvin number to an RGB color solve the inverse direction with a different approximation (for example Tanner Helland).
How accurate is a color temperature worked out from RGB?
It is an estimate. Many different light spectra share the same chromaticity, so the result is a correlated color temperature from McCamy’s formula, not a measurement of the actual light source.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/color/rgb-kelvin \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"r":255,"g":200,"b":150}'const res = await fetch("https://api.kit.forhosting.com/color/rgb-kelvin", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"r": 255,
"g": 200,
"b": 150
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/color/rgb-kelvin",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"r": 255,
"g": 200,
"b": 150
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/color/rgb-kelvin", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"r":255,"g":200,"b":150}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"r":255,"g":200,"b":150}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/color/rgb-kelvin", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"r": 255,
"g": 200,
"b": 150
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "color.rgb_kelvin",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
min_channel | 0 |
max_channel | 255 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Channels outside zero through two hundred fifty-five and pure black (undefined chromaticity) are rejected with a clear invalid_input error rather than silently clamped or invented.
What RGB-to-Kelvin CCT means and what the response contains
The response returns the validated integers r, g, and b; kelvin, cct, and temperature as the same rounded CCT value; chromaticity x and y; intermediate X Y Z; McCamy parameter n; an rgb function string; method set to mccamy; and a short formula reminder. The engine either builds a stable kelvin estimate for three legal non-black channels or rejects the request with invalid_input. Rejected cases include a missing r, g, or b field, empty strings after trimming, non-integer numbers, non-numeric text, Infinity or NaN, any channel strictly below zero or above two hundred fifty-five, and pure black where the XYZ sum is zero so chromaticity—and therefore CCT—is undefined.
How r, g, and b are read and how Kelvin stays reproducible
The preferred fields are r for red, g for green, and b for blue, but aliases red and capital R for red, green and capital G for green, and blue and capital B for blue are accepted so spreadsheets, query strings, and typed forms can reuse the same contract without renaming columns. After validation, conversion uses only closed-form arithmetic on the linear channels, D65 XYZ, chromaticity, and McCamy's coefficients, then rounds floating components to fixed decimal widths so JSON goldens and CI assertions stay stable across platforms. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing inverse gamma, chromaticity, and the cubic CCT polynomial yourself.
Where RGB-to-Kelvin conversion fits in design, lighting, and software
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split—free interactive exploration and a priced, identical API—matches the rest of the KIT tier-A catalog and lets you move from a classroom demo or design review to an automated pipeline without changing the mathematical result.
Integration use cases
Deterministic test fixtures
Generate reproducible McCamy CCT results for unit tests, property checks, and CI assertions on color helpers.
Technical questions
Which formula estimates the Kelvin value?
McCamy's approximation: convert sRGB to CIE XYZ (D65), form chromaticity x and y, compute n = (x − 0.3320) / (0.1858 − y), then CCT = 449n³ + 3525n² + 6823.3n + 5520.33 kelvin.