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
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
rgba(45, 212, 191, 1.0)
Popular FiveM Vehicle Colors
Recent Colors
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
- Step 1:
Enter a hex value, with or without the leading hash, or switch direction and enter the RGB triple.
- Step 2:
Check the preview. Very dark tones are hard to tell apart in code but obvious next to each other.
- Step 3:
Copy the output for the side you are working on, Lua for native draws, CSS for the NUI.
- 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.
Related tools
FiveM Color Picker - RGB, HEX & Vehicle Colors
Interactive FiveM color picker with RGB, HEX, HSL values and predefined vehicle color palettes. Copy Lua code for SetVehicleColours.
FiveM HUD Color Palette Generator
Generate harmonious color palettes for FiveM HUDs. Complementary, analogous, triadic schemes. Export as CSS variables or Lua config with RGB color codes.
JSON to Lua Table Converter for FiveM
Convert JSON to Lua table syntax and Lua tables back to JSON. Handles nested objects, arrays, booleans, null to nil. Syntax highlighted output for FiveM developers.