ForHosting KIT · Images

Convert hex color to RGB values from 0 to 255

Get the three numbers inside a hex code: #4a90e2 splits into 4a, 90 and e2, which are red 74, green 144 and blue 226. Shorthand such as #3af is expanded to #33aaff first. 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
#4a90e2
You get
Resistance (Ω)
74
G
144
B
226

Convert a hexadecimal color code into the three numeric channels used by RGB displays, graphics tools, style systems, and application code. Enter a three-digit shorthand such as #3af or a full six-digit value such as #33aaff, with or without the leading hash. The converter validates the complete format, expands shorthand correctly, and returns red, green, and blue as integers from 0 through 255. Invalid lengths, unsupported alpha forms, spaces inside the code, and non-hexadecimal characters produce a clear input error instead of an approximate or misleading color.

How hexadecimal color channels become RGB numbers

A six-digit hexadecimal color stores three eight-bit channels in the order red, green, and blue. The first pair of digits represents red, the middle pair represents green, and the final pair represents blue. Each pair is a base-16 number between 00 and FF, which corresponds to a decimal value between 0 and 255.

For example, #4a90e2 separates into 4a, 90, and e2. Those pairs convert to 74, 144, and 226, so the resulting RGB values are red 74, green 144, and blue 226. Hexadecimal uses the digits zero through nine and the letters A through F, and letter case does not change the value.

This capability performs that mapping directly and deterministically. It does not estimate a nearby color, consult a named-color table, or alter the channels. The returned integers can therefore be used in CSS functions, canvas drawing operations, image-processing parameters, design-token pipelines, tests, or any other system that expects standard eight-bit RGB channel values.

Using three-digit shorthand and validating the input

Three-digit hex colors are shorthand, not lower-precision numbers that require interpolation. Each digit is repeated to create the corresponding pair: #3af expands to #33aaff, #fff expands to #ffffff, and #000 expands to #000000. After expansion, the same pair-by-pair conversion produces the RGB result.

You may include the conventional leading hash or omit it, but the remaining code must contain exactly three or six hexadecimal digits. The validator rejects four- and eight-digit forms because those include an alpha channel and this capability returns only red, green, and blue. It also rejects empty input, misplaced hash characters, programming-style 0x prefixes, embedded whitespace, punctuation, and letters beyond F.

Surrounding whitespace is trimmed for convenient copying, while whitespace inside the color remains invalid. These strict rules make failures visible at the boundary and prevent partial parsing.

Choosing this converter in design and development workflows

Use this capability when your source value is already a conventional opaque hex color and the next step needs numeric RGB channels. Because the algorithm has no network calls, randomness, stored state, or clock dependency, the same input always produces the same three integers. That makes it suitable for build scripts and repeatable test suites as well as interactive conversion.

This focused converter intentionally does not handle CSS color names, RGB-to-hex conversion, HSL, CMYK, LAB, gradients, profiles, or alpha transparency. Choose a broader color-space tool when those transformations are part of the job. For ordinary #RGB and #RRGGBB values, however, the narrow contract is useful: callers know exactly which formats are accepted and exactly which fields return.

Invalid inputs are reported as validation failures so they can be corrected upstream.

Convert design tokens for application code

Turn hex values from a style guide into numeric red, green, and blue channels for components, canvas drawing, or graphics libraries.

Validate color fields before storage

Reject malformed color codes and save predictable RGB integers instead of accepting partially parsed or ambiguous values.

Which hex formats are accepted?

Exactly three or six hexadecimal digits, with an optional leading #. Uppercase and lowercase letters are both accepted.

How is a three-digit code converted?

Each digit is repeated before conversion, so #3af becomes #33aaff and returns 51, 170, and 255.

Are alpha-channel hex colors supported?

No. Four- and eight-digit forms are rejected because this capability returns only red, green, and blue channels.

What are the RGB values of #4a90e2?

Red 74, green 144 and blue 226. The code splits into the pairs 4a, 90 and e2, and each pair is read as a base-16 number between 00 and FF.

Does upper or lower case change the result?

No. #4A90E2 and #4a90e2 give exactly the same values, because letter case does not change a hexadecimal digit. Only the digits 0 to 9 and the letters A to F are allowed.

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-to-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-to-rgb \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"hex":"#4a90e2"}'
{
  "hex": "#4a90e2"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "color.hex_to_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.

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.

Using three-digit shorthand and validating the input

If a form field or data feed contains a malformed value, the API returns an invalid-input error rather than silently accepting a prefix or inventing missing digits.

Choosing this converter in design and development workflows

Browser use is available without an API charge, while automated successful requests use the published base price of $0.002.

Create stable test fixtures

Generate deterministic channel values for visual regression, theme, accessibility, and image-processing tests.

What happens when the format is invalid?

The request fails with an invalid_input error explaining that the value must contain exactly three or six hexadecimal digits.

How much does an API conversion cost?

Each successful API request costs $0.002. The browser converter can be used without an API charge.

Read the full KIT documentation →