ForHosting KIT · Images

Convert RGB color to hex

Turn red, green and blue into one uppercase color code: 255, 128, 0 becomes #FF8000. The result always has the full six digits, so codes line up when you compare, store or paste them into CSS. 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
Resistance (Ω)
255
G
128
B
0
You get
Hex
#FF8000

Convert an RGB color into the six-digit hexadecimal format used by CSS, design systems, graphics tools, and many data files. Enter red, green, and blue as whole numbers from 0 through 255, and the converter returns one uppercase code in #RRGGBB form. The calculation is deterministic and does not estimate, clamp, or silently repair invalid values.

Understand how RGB becomes a hexadecimal color

An RGB color stores three independent light intensities: red, green, and blue. Each channel can contain one of 256 integer values, starting at 0 and ending at 255. A six-digit hexadecimal color represents exactly the same information with two base-16 digits per channel.

The first pair belongs to red, the second pair belongs to green, and the final pair belongs to blue. Decimal 0 becomes 00, decimal 255 becomes FF, and values between them are converted and padded to two characters when necessary. For example, an input of red 255, green 128, and blue 0 produces #FF8000.

The leading hash identifies the value as a color in CSS and many design tools, while the six following characters preserve all three eight-bit channels without losing precision. This converter always returns the complete six-digit form, even when a shorter CSS notation could describe the same color. That fixed format is easier to compare, store, test, and pass between systems because every successful response has the same length and channel order.

Letter digits are returned in uppercase, but uppercase and lowercase hexadecimal codes describe the same color in CSS.

Provide valid channel values and interpret errors

Send an object containing r, g, and b, with each field set to a whole number between 0 and 255 inclusive. All three fields are required because omitting a channel would leave the color incomplete. Zero is valid and means that the corresponding primary contributes no light; 255 is also valid and means full intensity.

Values such as 12.5 are rejected because an eight-bit RGB channel in this contract must be an integer. Negative numbers and values above 255 are rejected rather than clamped. Clamping can conceal a broken sensor reading, spreadsheet formula, user interface control, or upstream validation rule, so a visible error is safer for automated work.

When a request fails, inspect the named channel, correct its source value, and submit the complete triple again. Because the algorithm has no network access, random behavior, or clock dependency, the same valid r, g, and b values always produce the same result in browser use, scripts, tests, and production jobs.

Use the result in design and development workflows

The returned code can be placed directly in CSS properties such as color, background-color, border-color, and fill. It also fits common design-token formats, theme configuration files, chart palettes, email templates, and documentation that records brand colors. Designers can convert channel values copied from an image editor before adding a swatch to a component library.

Developers can transform RGB columns from a database or spreadsheet into standardized strings before exporting a theme. Data pipelines benefit from strict errors because an invalid channel stops the conversion instead of introducing a plausible but incorrect color. For occasional work, the browser interface provides a fast way to check a triple without writing code.

Keep the leading hash when placing the result in CSS or a field that expects web color notation. If another system requests only six raw characters, remove the hash after conversion while leaving the channel pairs unchanged. This capability converts RGB integers only; it does not calculate transparency, color profiles, perceptual differences, HSL, CMYK, or nearest named colors, so use dedicated tools when those transformations are required.

Prepare CSS colors

Convert RGB channel values from a design brief into fixed #RRGGBB codes for stylesheets and components.

Normalize design tokens

Turn separate red, green, and blue fields into one consistent hexadecimal value for theme files and token catalogs.

Validate imported palettes

Reject out-of-range spreadsheet or database channels while generating exact hex codes for every valid palette entry.

Does the result include the hash symbol?

Yes. The hex field uses the complete #RRGGBB form with a leading hash and six digits.

Are lowercase and uppercase hex codes different?

No. CSS treats hexadecimal letters case-insensitively; this converter returns uppercase letters for consistent output.

Why is the result never a short three-digit code?

Every result uses the complete six-digit form, even when a shorter CSS notation exists. A fixed length and channel order make codes easier to compare, store, test and pass between programs.

Can I type a decimal such as 12.5?

No. Each channel must be a whole number from 0 to 255, so 12.5 is rejected, as are negative values and anything above 255. Correct the named channel and enter all three values again.

Where can I use the hex code?

Paste it straight into CSS for text color, backgrounds, borders or fills, or into a design tool. Uppercase and lowercase letters describe the same color, so #FF8000 also works where #ff8000 is expected.

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/rgb-to-hex

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/rgb-to-hex \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"r":255,"g":128,"b":0}'
{
  "r": 255,
  "g": 128,
  "b": 0
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "color.rgb_to_hex",
  "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.

If any channel is missing, fractional, or outside the supported range, the request returns a clear input error. This makes the tool useful for quick manual checks as well as repeatable automated workflows where exact color values matter.

Provide valid channel values and interpret errors

Text values are not treated as numbers, which keeps the API contract predictable and prevents accidental coercion from changing ambiguous input. A successful response contains a single hex field, including the leading hash and exactly six hexadecimal digits.

Use the result in design and development workflows

Test suites can use the endpoint to build exact expected values for color controls and serialization code. For automation, each API request costs $0.002 and uses the same deterministic calculation.

Which RGB values are accepted?

Each of r, g, and b must be an integer from 0 through 255, including both endpoints.

What happens when a channel is outside the range?

The conversion fails with an invalid_input error. Values are never clamped or wrapped.

How much does an API conversion cost?

Each API request costs $0.002. The deterministic browser converter can be used for interactive checks.

Read the full KIT documentation →