Color Converter
Pick a color or paste a value and convert instantly between HEX, RGB, and HSL, with a live swatch and a copy button for each format. Useful for matching brand colors across CSS, design tools, and SVG, or for turning a HEX code pulled from a screenshot into the RGB or HSL values your stylesheet needs.
#6366f1rgb(99, 102, 241)hsl(239, 84%, 67%)Add this tool to your own site with one line of HTML. Free forever — just keep the small credit link.
How to use Color Converter
- Pick a color from the visual picker, or type any value — HEX (#3b82f6), rgb(59, 130, 246), or hsl(217, 91%, 60%).
- The moment you change one field, every other format recalculates and updates in place.
- Read the HEX, RGB, and HSL values side-by-side to compare representations of the same color.
- Click any value to copy it straight to your clipboard, ready to paste into CSS or a design tool.
- Nudge the HSL lightness or saturation to build lighter and darker variants of the same hue.
Understanding HEX, RGB, HSL, and HSV
Every color you see on screen is the same physical thing — a mix of red, green, and blue light. The four notations below are just different ways of writing that mix down. Knowing how they relate makes it far easier to read a value, tweak it, and move it between CSS, design tools, and code.
HEX: RGB in base-16
A HEX code such as #3b82f6 packs three channels into six hexadecimal digits — two for red, two for green, two for blue. Each pair ranges from 00 (0) to ff (255). It is the most compact notation and the default in most design handoffs, but the digits are hard to reason about by eye because base-16 is not intuitive.
RGB: the raw channels
RGB writes the same three channels as plain decimal numbers from 0 to 255:
#3b82f6 → rgb(59, 130, 246)This is the same color, just easier to read. RGB is handy when you are computing colors in code, since you can manipulate each channel as an ordinary integer before formatting it back to HEX.
HSL: hue, saturation, lightness
HSL re-maps the RGB cube onto a cylinder that matches how people think about color. Hue is an angle from 0 to 360 degrees (0 = red, 120 = green, 240 = blue), saturation is how vivid the color is, and lightness runs from black to white:
#3b82f6 → hsl(217, 91%, 60%)To build a darker shade of the same color, drop the lightness; to mute it, drop the saturation — all without touching the hue. That predictability is why HSL is the go-to format for generating color scales and hover states.
HSV vs HSL
HSV (also called HSB) shares the hue and saturation axes but replaces lightness with value. In HSL, 100% lightness is always white; in HSV, 100% value is the brightest version of the hue itself. Color pickers in tools like Photoshop and Figma are usually HSV, which is why dragging to the top-right corner gives you a fully saturated color rather than white.
A worked example: turning one brand color into a usable palette
Say a design hands you a single brand blue, #3b82f6, and you need a hover state, a disabled state, and a tinted background from it. Convert to HSL first, because that is the format where the math is intuitive:
#3b82f6 → hsl(217, 91%, 60%) base
hover (darker) → hsl(217, 91%, 52%) → #156bf4
disabled (muted) → hsl(217, 30%, 60%) → #7a92b8
tint (lighter) → hsl(217, 91%, 95%) → #e7f0feEvery variant keeps the hue locked at 217, so the family stays recognisably the same blue. The hover state only drops lightness by 8 points; the disabled state pulls saturation down to grey it out without changing how light it is; the tint pushes lightness near the top for a subtle background. Once the HSL values look right, copy each one back as HEX for your stylesheet — exactly the round-trip this converter does in place. Trying to do the same edits directly in HEX would mean recomputing all three channels by hand for every step.
Rounding and precision
HEX and RGB are both 8-bit integers per channel, so they convert back and forth perfectly. HSL uses integer degrees and percentages, so a round-trip through HSL can shift a channel by one unit. When exact reproduction matters, keep HEX or RGB as the canonical value and treat HSL as an editing convenience.
Related dev tools
- Random Color Generator — generate fresh colors with HEX, RGB, and HSL.
- Random Gradient Generator — build CSS linear and radial gradients.
- CSS Minifier — shrink the stylesheet your colors live in.
- JSON Formatter — tidy up design tokens and theme config files.
Frequently asked questions
What format should I use for CSS?
How does HEX map to RGB?
Why does my HEX shorthand look different?
How is HSL calculated from RGB?
What is the difference between HSL and HSV?
Does this support alpha (transparency)?
Are these conversions lossless?
Related tools
More tools you might find useful in the same flow.
Base64 Encoder
Base64 encoder and decoder online: convert text to Base64 or decode Base64 strings back to readable text. UTF-8 safe, instant, and free to use with no signup.
JSON Formatter
Free JSON formatter, validator, and minifier with line/column error reporting. Sensitive payloads stay on your device — nothing is sent to a server.
JWT Decoder
Free JWT decoder for inspecting header, payload, and expiry. Tokens never leave your browser — safe for production tokens containing secrets or PII.
URL Encoder
URL encoder and decoder online — percent-encode URLs, query strings, and parameters or decode them back to plain text. Instant results, right in your browser.
Built by Muhammad Tahir · About