Hex to RGB converter
Read any hex code as plain numbers: #3498db is red 52, green 152 and blue 219, because each pair of digits is a base-16 number, ready to paste as rgb(52, 152, 219). Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Hex
- #3498db
- Hex raw
- #3498db
- Hex6
- 3498db
- Resistance (Ω)
- 52
- G
- 152
A hex to RGB converter takes a color written as a hexadecimal code—three or six digits, with or without a leading hash—and splits it into the three integer channels every screen, canvas, and design token system still speaks natively: red, green, and blue, each from zero through two hundred fifty-five. Paste #3498db or the short form #abc; the tool expands shorthand when needed, normalizes to a lowercase six-digit hex, and returns r, g, b plus a ready-to-paste CSS rgb() string and step-by-step channel math.
What a hex color means and how RGB is derived
Hexadecimal color codes pack three eight-bit channels into a compact string that stylesheets, design tools, and brand guidelines have used for decades. In the six-digit form #RRGGBB, the first two characters encode red, the middle two encode green, and the last two encode blue, each pair interpreted as a base-sixteen integer from zero (00) through two hundred fifty-five (FF).
The three-digit shorthand #RGB is a CSS convenience that doubles each digit: #abc becomes #aabbcc, so a single nibble stands in for a full byte when a palette only needs coarse steps. The result is three integers you can feed into canvas fill styles, React inline styles, email HTML, or a contrast-ratio calculator without re-deriving the bit packing yourself. Classroom exercises and coding interviews often ask for this transform by hand; having a deterministic reference removes ambiguity about case, hash presence, and shorthand expansion.
Practical tips, limits, and related searches
Prefer sending the hex string your design tool exported, including the hash if you have it; both forms work, and the response always normalizes to lowercase six-digit hex so downstream diffs stay stable. Do not pass alpha forms such as #RRGGBBAA or #RGBA—this landing is intentionally limited to classic opaque RGB packing, and those lengths are rejected so you notice rather than silently dropping alpha.
Named CSS colors like rebeccapurple are out of scope; convert them with a named-color table first or use a broader multi-space tool when you need HSL, LAB, or CMYK as well. Prefer this capability when you already have a hex token and only need the three channel integers or a css rgb() string; if your pipeline must round-trip through HSL or print CMYK, use a multi-format converter instead.
What you can do with it
Design token handoff to engineers
Designers paste brand hex codes from Figma or a style guide and receive exact r, g, b integers and a CSS rgb() string for implementation tickets.
Inline style and canvas fill helpers
Convert user-supplied hex from a color picker into numeric channels for CanvasRenderingContext2D, SVG attributes, or framework style objects.
FAQ
What hex formats does the hex to RGB converter accept?
Three-digit (#RGB) and six-digit (#RRGGBB) hexadecimal colors, with or without a leading #. Letters may be upper or lower case. Alpha forms and named CSS colors are not accepted.
How is three-digit shorthand expanded?
Each digit is doubled: #abc becomes #aabbcc, then each pair is parsed as a base-16 integer from 0 to 255.
What do r, g, and b represent?
Red, green, and blue channel intensities as integers from 0 through 255.
Is the hex to RGB converter free?
The browser tool is free and runs locally.
What RGB values does #3498db give?
It gives red 52, green 152 and blue 219. The pairs 34, 98 and db are read as base-16 numbers, and the result is shown as rgb(52, 152, 219).
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/hex-rgb \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"hex":"#3498db"}'const res = await fetch("https://api.kit.forhosting.com/color/hex-rgb", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"hex": "#3498db"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/color/hex-rgb",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"hex": "#3498db"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/color/hex-rgb", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"hex":"#3498db"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"hex":"#3498db"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/color/hex-rgb", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"hex": "#3498db"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "color.hex_rgb",
"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
max_hex_chars | 7 |
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
Invalid codes—wrong length, non-hex characters, empty input, or a programming 0x prefix—fail with a clear invalid_input error instead of inventing a color.
How to call the API and what comes back
Valid examples include #3498db, 3498db, #ABC, and abc; surrounding whitespace is trimmed, letters may be upper or lower case, and the hash is optional. Send a JSON body with one required string field named hex—aliases color, value, text, input, and code are accepted by the same solver. On success the response returns hex as a normalized lowercase #rrggbb string, hex6 without the hash, integer fields r, g, and b together with red, green, and blue aliases, an rgb array of three numbers, a css string of the form rgb(r, g, b), booleans shorthand and had_hash describing the original form, a short English message, and a steps array that shows each parseInt channel line for debugging or teaching. Failed validation—missing field, empty string after the hash, length other than three or six, non-hex characters, spaces inside the body, a 0x programming prefix, or a bare number instead of a string—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.
Practical tips, limits, and related searches
Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts and form validation cheap while learners paste imperfect clipboard values.
Integration use cases
Unit tests for theme and palette fixtures
Generate known-good RGB triples from hex fixtures so visual regression and contrast-ratio tests assert stable channel values.
Technical questions
What happens on an invalid hex code?
The API returns invalid_input with a message describing the problem (empty input, wrong length, non-hex characters, 0x prefix, and so on). Failed validation is not charged.