RGB / HEX / HSL Color Converter
Convert colors between HEX, RGB, RGBA, HSL, and HSB/HSV. Type in any field or use the color picker โ all formats update instantly. Click any value to copy it.
Developer Tools
What This Tool Does
Converts between HEX, RGB, HSL, and HSV color formats instantly in your browser, with a live color preview swatch. Supports copy-to-clipboard for each format.
Who This Is For
- Frontend developers translating design tokens between CSS color formats
- UI designers checking color values across different design tools that use different formats
- Web developers matching brand colors from a style guide to their CSS variables
- Anyone who knows a color in one format and needs it in another without searching conversion formulas
Example: Input: A HEX color code like #3B82F6 → Output: RGB: rgb(59, 130, 246) ยท HSL: hsl(217, 91%, 60%) ยท HSV: hsv(217ยฐ, 76%, 96%) โ all at once with a live preview swatch
How to Convert Colors
- Select the input format: HEX, RGB, HSL, or another supported format.
- Enter your color value. The live preview updates instantly.
- All equivalent values in every supported format appear simultaneously.
- Click any value to copy it.
The converter handles shorthand hex and full hex formats. For the decimal equivalent of any hex code, the Number Base Converter shows binary and decimal alongside hex. The converter handles shorthand hex (#FFF), 8-digit hex with alpha (#FF5733FF), and RGB/RGBA/HSL/HSLA values with or without the rgba()/hsla() wrapper.
Color Format Reference
| Format | Syntax | Example | Notes |
|---|---|---|---|
| HEX | #RRGGBB | #FF5733 | Most common in web/CSS. Shorthand: #F57 |
| HEX+alpha | #RRGGBBAA | #FF573380 | Last two digits = opacity |
| RGB | rgb(r, g, b) | rgb(255, 87, 51) | Each value 0โ255 |
| RGBA | rgba(r, g, b, a) | rgba(255, 87, 51, 0.5) | Alpha 0=transparent, 1=opaque |
| HSL | hsl(h, s%, l%) | hsl(14, 100%, 60%) | H: 0โ360ยฐ, S/L: 0โ100% |
| HSLA | hsla(h, s%, l%, a) | hsla(14, 100%, 60%, 0.5) | HSL with transparency |
| oklch | oklch(l% c h) | oklch(66% 0.22 30) | Perceptually uniform (2023+) |
When to Use Each Color Format
- HEX โ use in CSS for solid colors. Short, universally supported, copy-paste friendly. The default choice for most CSS color values.
- RGB/RGBA โ use when you need to manipulate color values programmatically, or when you need transparency (
rgba). Easy to understand intuitively (red + green + blue). - HSL โ use in design systems and dynamic color generation. HSL is much easier to reason about than RGB: adjust the lightness to make a color lighter/darker, adjust saturation to make it more/less vivid.
- oklch โ the modern recommendation for design systems (supported in all browsers since 2023). Perceptually uniform โ equal changes in L always appear equally bright regardless of hue, unlike HSL.
Using HSL for Design Systems
HSL is uniquely useful for generating color variations programmatically. A brand color at hsl(220, 80%, 55%) can produce a full scale:
:root {
--brand: hsl(220, 80%, 55%);
--brand-light: hsl(220, 80%, 75%);
--brand-dark: hsl(220, 80%, 35%);
--brand-muted: hsl(220, 30%, 55%);
}Adjusting only the lightness or saturation keeps the hue consistent โ critical for a coherent palette. This pattern is far more maintainable than hardcoding separate HEX values for each variant.
Color Design Workflow
Color format conversion connects to the full design toolchain:
- Pick colors visually and get all format values at once
- Generate a color palette from your converted color
- Create a create a CSS gradient using the converted color values using the converted color values
- Minify your CSS after adding the converted color values
Related Tools
- Working with a palette defined in CSV? Convert to JSON for programmatic color processing. โ convert color data from a CSV palette file
- Building a design system? Export your color definitions as CSV for the design team. โ export color palette data to a spreadsheet
- Writing a color style guide? Document it in Markdown and convert to HTML for publishing. โ document color usage in a style guide
- Passing color values in URL parameters? URL-encode the hash (#) character in hex colors. โ URL-encode hex color values
- Migrating color handling from VB.NET to C#? Convert the System.Drawing.Color syntax. โ convert VB.NET color code to C#
Related Guides
CSS Color Formats: When to Use HEX, RGB, HSL, or Named Colors
A practical guide to choosing the right color format for different CSS use cases.
TutorialBuilding a Design System with CSS Custom Properties and HSL
How to use HSL color values to create consistent, themeable color palettes.
GuideJSON vs XML vs CSV: Which Data Format Should You Use?
Color values often appear in JSON configuration files and design tokens.
Frequently Asked Questions
#FF5733 is the same as rgb(255, 87, 51). FF = 255, 57 = 87, 33 = 51 in decimal.hsl(120, 100%, 50%) is clearly "pure green at full saturation". The equivalent HEX #00FF00 requires decoding. Use HSL for design systems, CSS custom properties, and any code where you want colors to be self-documenting.rgb(r, g, b) values. In JavaScript, you can then extract the numbers: const [r,g,b] = "rgb(255,87,51)".match(/\d+/g).map(Number). For dynamic manipulation, consider using the CSS Custom Properties (variables) approach instead.#FF000080 is 50% transparent red. Use rgba() or hsla() in CSS, or 8-digit hex.