Hex to RGB Converter
Convert between HEX, RGB, HSL and the platform formats iOS and Android expect.
- HEX#6366F1
- RGBrgb(99, 102, 241)
- RGBArgba(99, 102, 241, 1)
- HSLhsl(239, 1%, 1%)
- SwiftUIColor(red: 0.388, green: 0.400, blue: 0.945)
- Android XML<color name="brand">#FF6366F1</color>
- ComposeColor(0xFF6366F1)
Enter a colour in any format and get it back in all of them at once — HEX, RGB, RGBA, HSL, plus the literals SwiftUI and Android XML want.
Saves the small daily tax of hand-converting a designer's HEX into the form your platform actually compiles.
What HEX and RGB actually encode
Both describe the same thing: how much red, green and blue light to mix. HEX is just those three numbers written in base 16, two digits each, which is why #FF0000 and rgb(255, 0, 0) are identical. Neither format tells you anything useful about how the colour relates to its neighbours — that is what HSL is for.
Why HSL is worth learning
HSL separates hue, saturation and lightness, which means you can build a whole tonal ramp by moving one number. That is exactly what a mobile theme needs — a set of surfaces at consistent lightness steps rather than a pile of unrelated hex codes. It also makes dark mode a systematic transformation instead of a second round of guessing.
Alpha behaves differently across platforms
CSS takes alpha as a 0–1 float at the end of rgba(). Android XML puts it first, as two hex digits at the front of an eight-digit value. Getting the order wrong produces a wildly wrong colour rather than a subtle one, which at least makes the mistake easy to spot.
How to use the hex to rgb converter
- Paste or pick your colour — HEX, rgb() and hsl() inputs are all accepted.
- Read every format at once, including the SwiftUI and Jetpack Compose literals.
- For Android XML, note the alpha digits come first: #FFRRGGBB, not #RRGGBBAA.
- Use the HSL value as your starting point if you need to build a tonal ramp from this colour.
- Copy all formats in one go to paste into whichever platform file you are in.
Use it with
- Color Picker from Image — Drop in a screenshot or photo and pull out every colour in it, ready to paste into your app's theme.
- Contrast Checker — Test any foreground and background pair against WCAG AA and AAA, at both body and large text sizes.
- Gradient Generator — Build linear and radial CSS gradients with as many stops as you need, and copy the code.
Frequently asked questions
- How do I convert a HEX colour to RGB by hand?
- Split the six digits into three pairs and convert each from base 16 to base 10. #6366F1 becomes 63→99, 66→102, F1→241, or rgb(99, 102, 241). This tool does it instantly, along with HSL and the platform formats.
- What is the Android colour format with eight digits?
- #AARRGGBB — the alpha channel comes first, unlike CSS where alpha goes last. #80FF0000 is red at 50% opacity. Getting the order backwards produces a very obviously wrong colour.
- How do I use a HEX colour in SwiftUI?
- SwiftUI's Color initialiser takes red, green and blue as 0–1 doubles rather than 0–255 integers, so each channel is divided by 255. The converter outputs the ready-made Color(red:green:blue:) literal.
Related tools
- Color Picker from ImageDrop in a screenshot or photo and pull out every colour in it, ready to paste into your app's theme.
- Contrast CheckerTest any foreground and background pair against WCAG AA and AAA, at both body and large text sizes.
- Colour Blindness SimulatorSee your screens the way users with each type of colour vision deficiency see them.