use case

How to convert RGB to HEX

Convert an RGB colour value to a HEX code for use in HTML, CSS, or a design tool.

Browser colour pickers, CSS computed styles, and some APIs return colours in RGB format. Design tools, HTML attributes, and most CSS properties accept HEX. This guide shows how to convert any RGB value to a HEX code instantly.

Step-by-step guide

  1. Get the RGB values: Identify the red, green, and blue values (each 0–255). You can enter them as rgb(255, 102, 0) or as bare comma-separated numbers: 255, 102, 0.
  2. Paste and convert: Paste the RGB value into the converter. The HEX code appears in the output along with the HSL and HSV representations.
  3. Use the HEX code: Copy the hex field (e.g. #ff6600) and use it in your HTML color attribute, CSS rule, or paste it into Figma's colour picker.

Frequently asked questions

How do I convert RGB to HEX in Python?
hex_color = '#{:02x}{:02x}{:02x}'.format(255, 102, 0) — or use the REST API: import requests; r = requests.post('https://quickhelp.dev/api/color-converter', json={'color': 'rgb(255,102,0)'}); print(r.json()['hex'])
What if my RGB values are percentages (0%–100%)?
Convert to 0–255 first: multiply each percentage by 2.55 and round. For example, 40% → 40 * 2.55 = 102. CSS also accepts percentage RGB: rgb(100%, 40%, 0%), but this tool expects 0–255 integers.

Try it now

Use the Color Converter to complete this task — free, no sign-up, runs in your browser.

Open Color Converter

We use cookies to serve ads and measure traffic. Cookie policy · Privacy policy