Hex to RGB Converter
Convert hex color codes to RGB and RGB to hex. Preview colors, get HSL values and copy with one click.
What is Hex to RGB Conversion?
Hex to RGB conversion is the process of translating a hexadecimal color code (used in web design and CSS) into its equivalent Red, Green and Blue component values. A hex color code like #FF5733 represents a combination of red (FF = 255), green (57 = 87) and blue (33 = 51) intensity values. Web designers, developers and graphic artists frequently need to convert between these formats for different tools and platforms.
How to Use This Converter
Enter a hex color code (with or without the # symbol) in the Hex to RGB mode, or enter individual R, G and B values (0 to 255) in the RGB to Hex mode. The converter works in real time as you type. You will see an instant color preview swatch, and the equivalent values in Hex, RGB and HSL formats. Click the Copy button next to any format to copy it to your clipboard for use in your projects.
Conversion Formula
To convert hex to RGB, each pair of hex digits is converted to its decimal equivalent:
R = parseInt(hex[1..2], 16)
G = parseInt(hex[3..4], 16)
B = parseInt(hex[5..6], 16)
Shorthand hex codes like #FFF are expanded to #FFFFFF by doubling each digit. To convert RGB to hex, each decimal value is converted to a two-digit hexadecimal string and concatenated with a # prefix.
Frequently Asked Questions
What is a hex color code?
A hex color code is a six-character string (preceded by #) that represents a color using hexadecimal values for red, green and blue channels. For example, #000000 is black and #FFFFFF is white.
What is the difference between RGB and HSL?
RGB defines colors by their red, green and blue light components. HSL defines colors by Hue (0-360 degrees), Saturation (0-100%) and Lightness (0-100%). HSL is often more intuitive for adjusting color shades and tints.
Can I enter shorthand hex codes like #FFF?
Yes. This converter automatically expands shorthand three-character hex codes. For example, #FFF becomes #FFFFFF and #F00 becomes #FF0000.
Related tools
Explore all tools
Find exact age in years, months and days
Check Body Mass Index and weight range
Monthly EMI for home, car or personal loan
Estimate future value of SIP investment
Fixed Deposit maturity and interest
Recurring Deposit maturity and interest
Add or remove GST from any amount
Find X% of Y, percentage change and more
Estimate next period and fertile window
Estimate due date from last period
Find days between two dates
Find booking date for train tickets
Calculate compound interest with flexible compounding
Public Provident Fund maturity and interest
Calculate gratuity based on salary and tenure
Find HRA exemption for tax saving
CTC to in-hand salary breakdown
Calculate tax under Old and New regime
Calculate simple interest on any amount
Compound annual growth rate
Find discount amount and final price
Calculate profit or loss percentage
Return on Investment calculator
Basal Metabolic Rate and daily calories
Calculate area of any shape
Calculate speed, distance or time
Calculate fuel cost for any trip
Find mean, median and mode
Calculate tip and split the bill
Convert numbers to words for cheques
Calculate electricity usage cost
Convert length, weight, temperature
Add or subtract hours and minutes
Calculate future value after inflation
Find break-even point for business
Find base price from GST-included amount
One-time investment future value
Systematic withdrawal plan calculator
Calculate new salary after hike
Check how much home loan you can get
Calculate car loan EMI and total cost
Convert CGPA to percentage easily
Find marks needed to pass or score target
Find ideal body weight by height
Estimate body fat percentage
Daily water requirement by weight
Count working days between dates
Days remaining until a future date
Convert hex color codes to RGB
Generate random numbers in any range
Solve quadratic equations instantly
Find age difference between two people
Calculate total work hours and pay