ForHosting KIT · Images

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
Use it from WebAPIEmailTelegramApp soon
If you enter
Hex
#3498db
You get
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.

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.

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).

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.

POSThttps://api.kit.forhosting.com/color/hex-rgb

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.

curl -X POST https://api.kit.forhosting.com/color/hex-rgb \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"hex":"#3498db"}'
{
  "hex": "#3498db"
}
{
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_hex_chars7
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

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.

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.

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.

Read the full KIT documentation →