HEX to RGB Converter

Bidirectional color converter for FiveM development. Convert between HEX, RGB, HSL with ready-to-use Lua and CSS code.

Color Preview

#2DD4BF

Code Output

SetVehicleCustomPrimaryColour(vehicle, 45, 212, 191)
color: rgb(45, 212, 191);
background: #2dd4bf;
-- NUI callback color
local hexColor = "#2dd4bf"
local r, g, b = 45, 212, 191
100%
rgba(45, 212, 191, 1.0)

Popular FiveM Vehicle Colors

Recent Colors

No colors yet. Start converting to build history.

What this tool is for

The NUI side of a FiveM script speaks CSS and therefore hex, the Lua side speaks RGB triples. Every colour that appears in both places has to be converted, and doing it in your head is where typos come from. This converter works in both directions and hands you the Lua line, the CSS rule and the rgba form with alpha at the same time.

How to use it

  1. Step 1:

    Enter a hex value, with or without the leading hash, or switch direction and enter the RGB triple.

  2. Step 2:

    Check the preview. Very dark tones are hard to tell apart in code but obvious next to each other.

  3. Step 3:

    Copy the output for the side you are working on, Lua for native draws, CSS for the NUI.

  4. Step 4:

    Use the rgba form when the element should be translucent, for example a HUD background.

Frequently asked questions

Why does the same colour look different in the HUD than in the browser?

The HUD sits over a moving game image and passes through the game tone mapping. Colours that read fine on a white editor background lose contrast over a night scene. Always check against actual gameplay.

What about three digit hex codes?

Short form like fff is expanded by doubling each digit, so fff is ffffff. That works in CSS, but Lua has no such shorthand, which is why the tool always outputs the full triple.

How is alpha handled on each side?

CSS takes alpha from 0 to 1, native draw calls take it from 0 to 255. Passing a CSS alpha of 0.5 into a native call gives you zero, which is a fully invisible element and a common bug.

Are HSL values useful here?

Yes, for variants of one colour. Keep hue and saturation, change lightness, and you get a hover state or a disabled state that matches instead of a second colour picked by eye.