RGB to Hex Converter
Turn red, green and blue values (0–255) into a hex color code and a CSS rgb() string.
How it works
hex pair = channel in base 16, zero-padded to two digits
Each RGB channel is one byte, 0–255, which converts to exactly two hex digits: divide by 16 for the first digit, take the remainder for the second (10–15 become a–f). Values below 16 need a leading zero — dropping it is the classic bug that turns rgb(0, 128, 0) into a five-character non-color. The floats line is the same color scaled to 0–1, the form shaders and many design tools use.
Worked example
rgb(255, 128, 0): 255 = ff, 128 = 8×16 + 0 = 80, 0 = 00 — assembled as #FF8000.
Frequently asked questions
What if my value is 300 or −20?
That isn’t a displayable channel — the byte range is 0–255. This converter flags out-of-range input instead of guessing; clamp to the nearest bound (255 or 0) if that is what you mean.
Are uppercase and lowercase hex different colors?
No — #FF8000 and #ff8000 are identical. Pick a case convention for your codebase and stick to it; most linters default to lowercase.
How do I add transparency?
Append a fourth pair for alpha (#FF800080 is ~50% opacity) or use rgba(255, 128, 0, 0.5). Both are supported in all modern browsers.
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.