Tools

HTML Color Codes: Picker & Converter

Pick, convert and copy HTML color codes: use the color picker or type HEX, RGB, HSL or a color name; get HEX, RGB, HSL, HSB and CMYK values, shades, color harmonies and the contrast on white and black. Copy any of 40 common HTML colors in one click. For web design and social media; free, no sign-up.

Runs in your browser; colors are never stored. Readable?Check the contrast
Type HEX, rgb(), hsl(), hsb(), cmyk() or a CSS color name.
Common HTML colorsClick to select and copy
Click to select

Result

Selected color
#31C48D≈ mediumseagreen
HEX
RGB
HSL
HSB
CMYK
Text contrast (WCAG)Click a card for the full check
Written by
  • Digital Marketing Expert
  • Google Partner
  • Full Stack Developer
Last updated
Based on
5 sources

How to use the HTML Color Codes: Picker & Converter

  1. Enter a color

    Click the swatch to open the picker. You can also type a HEX, rgb(), hsl(), hsb() or cmyk() value, or a CSS color name such as teal.

  2. Grab it from the screen or the palette

    In supporting browsers, Pick from screen samples any point on your screen. Click one of the 40 palette colors to select it and copy its HEX code.

  3. Copy the codes

    Each row on the right has a copy button. The HEX, RGB, HSL, HSB or CMYK value arrives ready for CSS or your design app.

  4. Derive shades and harmonies

    The Shades tab shows four lighter and four darker versions. The Harmonies tab shows complementary, analogous and triadic partners. Click any tile to make it the new base color.

  5. Check the contrast

    The two cards at the bottom give the WCAG contrast ratio on white and on black. Click a card to open the Color Contrast Checker with the same color.

HTML color codes conversion formulas

The tool first turns your input into R, G and B channels from 0 to 255. It then calculates every other format from those three numbers.

HEX → RGBR = base 16 value of RR (00-FF = 0-255); GG gives G and BB gives B. In shorthand each digit doubles: #F60 = #FF6600
RGB → HSLr, g, b = channel ÷ 255; L = (max + min) ÷ 2; S = (max - min) ÷ (1 - |2L - 1|); H = angle in 60° sectors based on the largest channel
RGB → HSBB = max; S = (max - min) ÷ max; H is the same angle as in HSL
RGB → CMYKK = 1 - max; C = (1 - r - K) ÷ (1 - K); M and Y the same way with g and b
Lighter and darker shadesNew channel = channel + (target - channel) × share; with white 0.72 / 0.54 / 0.36 / 0.18, with black 0.16 / 0.32 / 0.48 / 0.64
HarmoniesHue + 180° (complementary), hue ± 30° (analogous), hue + 120° and + 240° (triadic); saturation and lightness unchanged
Contrast ratio(L lighter + 0.05) ÷ (L darker + 0.05); L is the WCAG relative luminance

The tool rounds HSL, HSB and CMYK percentages to whole numbers. So a rounded value typed back in can shift the HEX code by one step. For example, dodgerblue (#1E90FF) shows as hsl(210, 100%, 56%), and typing that value returns #1F8FFF.

Sample color conversions

Type these inputs into the tool and the panel shows exactly the same values.

InputHEXRGBHSLHSBCMYKCSS name
#31C48D#31C48Drgb(49, 196, 141)hsl(158, 60%, 48%)158°, 75%, 77%75%, 0%, 28%, 23%≈ mediumseagreen
rgb(220, 20, 60)#DC143Crgb(220, 20, 60)hsl(348, 83%, 47%)348°, 91%, 86%0%, 91%, 73%, 14%crimson
hsl(210, 100%, 56%)#1F8FFFrgb(31, 143, 255)hsl(210, 100%, 56%)210°, 88%, 100%88%, 44%, 0%, 0%≈ dodgerblue
#F60#FF6600rgb(255, 102, 0)hsl(24, 100%, 50%)24°, 100%, 100%0%, 60%, 100%, 0%≈ orangered
navy#000080rgb(0, 0, 128)hsl(240, 100%, 25%)240°, 100%, 50%100%, 100%, 0%, 50%navy
cmyk(0%, 100%, 100%, 50%)#800000rgb(128, 0, 0)hsl(0, 100%, 25%)0°, 100%, 50%0%, 100%, 100%, 50%maroon
rgba(0, 0, 0, 0.5)#00000080rgba(0, 0, 0, 0.5)hsla(0, 0%, 0%, 0.5)0°, 0%, 0%0%, 0%, 0%, 100%black

The ≈ sign means the color has no exact CSS name and the tool shows the closest one. In the last row HSB and CMYK carry no transparency, so they give the opaque value of black.

The 16 basic HTML colors and their codes

HTML 4.01 defined these 16 names, and every browser still supports them; the HSL column helps when you want to derive shades.

CSS nameHEXRGBHSL
black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
silver#C0C0C0rgb(192, 192, 192)hsl(0, 0%, 75%)
gray#808080rgb(128, 128, 128)hsl(0, 0%, 50%)
white#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)
maroon#800000rgb(128, 0, 0)hsl(0, 100%, 25%)
red#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)
purple#800080rgb(128, 0, 128)hsl(300, 100%, 25%)
fuchsia#FF00FFrgb(255, 0, 255)hsl(300, 100%, 50%)
green#008000rgb(0, 128, 0)hsl(120, 100%, 25%)
lime#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)
olive#808000rgb(128, 128, 0)hsl(60, 100%, 25%)
yellow#FFFF00rgb(255, 255, 0)hsl(60, 100%, 50%)
navy#000080rgb(0, 0, 128)hsl(240, 100%, 25%)
blue#0000FFrgb(0, 0, 255)hsl(240, 100%, 50%)
teal#008080rgb(0, 128, 128)hsl(180, 100%, 25%)
aqua#00FFFFrgb(0, 255, 255)hsl(180, 100%, 50%)

Note that green is only #008000; the pure green channel at full strength is lime. Source: W3C HTML 4.01, section 6.5.

What are HTML color codes and what does this tool show?

HTML color codes are the standard ways to write a color so a browser understands it. The common forms are a HEX code such as #31C48D, channel values such as rgb(49, 196, 141) and hsl() notation. Named colors such as teal work too. A screen builds every color from red, green and blue light. Each channel takes 256 values from 0 to 255, so these three channels give you 16,777,216 possible colors.

This tool converts one value into five formats at once. In other words, a client's RGB value, a Figma HSB value and a printer's CMYK figure appear on one screen. The tool also does four more things.

  • It matches the color to the closest CSS color name and adds ≈ when no exact name exists.
  • Four lighter and four darker shades appear, plus complementary, analogous and triadic harmonies.
  • Two cards show the WCAG contrast ratio on white and on black.
  • One click on any of 40 common HTML colors selects it and copies the HEX code.

Also, every calculation runs in your browser. In brand identity projects, my team and I start by pinning the colors down to one list of codes. We then build the rest of the brand identity work on top of that list.

How do you read a HEX code, and when do short and 8 digit forms help?

A HEX code writes the three channel values side by side in base 16: #RRGGBB. The first two digits give red, the next two green and the last two blue. So in base 16, 00 equals zero and FF equals 255. For example, in #DC143C the pair DC means 220 on the red channel. Likewise, 14 means 20 on green and 3C means 60 on blue, so the tool shows rgb(220, 20, 60).

CSS accepts four HEX forms, and the tool reads all of them.

  • Short form #RGB: the browser doubles each digit, so #F60 is really #FF6600.
  • Full form #RRGGBB: the most common six digit notation.
  • Alpha forms #RGBA and #RRGGBBAA: the last digit or pair carries transparency. 00 is fully transparent and FF fully opaque, while 80 gives close to 50% opacity.

Upper or lower case makes no difference; #dc143c and #DC143C are the same color. Still, I recommend one spelling across the team. Otherwise two spellings of the same color slip through when you search a design file. The tool always returns upper case, and it still recognizes a code when you forget the hash sign.

RGB, HSL or HSB: which one should you use?

All three describe the same color; however, each one suits a different job. RGB is the language of the screen: three channels from 0 to 255. As a result, it is the most familiar format in image editors and in code.

HSL defines a color as hue (0-360°), saturation and lightness. It is the most practical notation for lighter and darker versions of a color in CSS. In short, you change only L and the hue stays put. At an L of 100 every color turns white, and at 0 it turns black.

HSB (HSV in some apps) is what you meet in the pickers of design tools such as Figma and Photoshop. Here B means brightness, and a value of 100 gives the most vivid version of the hue instead of white. For example, #1F8FFF has a lightness of 56% in the HSL row. The HSB row, however, shows a brightness of 100% for the same color.

In practice, I take HEX or HSB from the design file and write HEX or HSL in CSS. For client reports I use RGB. My post on web design in Figma covers the design side of that flow. If you type an HSB value as hsb(210, 88%, 100%), the tool converts it to HEX as well.

CSS color names: can you trust all 148 of them?

CSS recognizes 148 color names today. Sixteen of them are the basic colors from HTML 4.01, and the table above lists them with their codes. Most of the rest came from the X11 color list and became standard with CSS Color Level 3. The newest name, added in CSS Color Level 4, is rebeccapurple. The current list lives in the W3C CSS Color Module Level 4 specification.

Some names are two spellings of one color: gray and grey, aqua and cyan, fuchsia and magenta give identical values. As a result, the 148 names map to 139 distinct colors. Names are easy to read. However, they hide a few traps.

  • Dark is not always darker: darkgray is #A9A9A9, while gray is #808080.
  • No transparency: every name is an opaque color; only the transparent keyword is fully see through.
  • Case does not matter: DodgerBlue and dodgerblue give the same color.

When your color has an exact name, the tool shows it. If the color has several names, you see all of them, for example darkgray / darkgrey. Without an exact name, the tool suggests the name with the smallest difference in the CIELAB color space. It then marks that name with ≈, and the hint helps you find a nearby shade. However, it does not replace the code, so keep writing the HEX value in CSS.

Why does the CMYK value never print exactly?

A screen makes color with light, while print makes it with ink. RGB is additive: push all three channels to the maximum and you get white. CMYK is subtractive; cyan, magenta, yellow and black ink reduce the white of the paper. Therefore some vivid screen colors, especially bright greens and blues, never reach the same intensity in ink.

The CMYK row in this tool uses a simple, device independent formula. Specifically, that formula knows nothing about paper stock, ink set or the printer's color profile. So for corporate print jobs I follow three steps.

  1. Ask the printer for the color profile that matches their paper and press.
  2. Set Pantone references or profile based CMYK values for the main logo colors.
  3. Order a proof before the full run and compare the color with the proof, not with your screen.

The CMYK value here is still useful. It is a good starting point for slide decks, office printouts or a first brief to a printer. Moving a printed identity online, on the other hand, is the reverse trip. My post on taking a print brand identity digital walks through it step by step.

How do you manage HTML color codes for a brand?

Brand colors tend to multiply over time. One code lives on the website, another in the social media template and a third in the slide deck. Soon the same blue exists in five versions. To prevent that, I keep a short color list in every project.

  • Primary color: one HEX code, the same on every channel.
  • Shades: lighter and darker versions from the Shades strip for hover states, backgrounds and borders.
  • Neutrals: two or three grays for text, surfaces and lines.
  • Status colors: separate colors for success, warning and error messages.

The Shades strip mixes the color with white at 72%, 54%, 36% and 18%. On the dark side it mixes with black at 16%, 32%, 48% and 64%. That way the dark hover shade stays in the same family as the primary color. Define the list as CSS variables, for example --brand: #31C48D. Then you can change a color across the whole site in one place. In larger teams the same idea lives inside a design system.

Use the same code for QR codes, social media graphics and email signatures too. For example, the QR code generator asks for a HEX value for the code color. Pick a dark shade on a light background, and phones scan the code more reliably.

How do you check harmonies and contrast together?

The Harmonies tab finds the mathematical partners of a color on the hue wheel. The tool keeps saturation and lightness fixed and rotates only the hue.

  • Complementary (180°): the strongest contrast, for accents and call to action buttons.
  • Analogous (-30° and +30°): neighboring hues, for calm and cohesive palettes.
  • Triadic (+120° and +240°): balanced yet lively trios, useful in illustrations and charts.

These partners are a starting point, not a rule. In my experience most business websites need one primary color, one accent and a set of neutrals. Moreover, if you give all three triadic colors equal weight, the page quickly feels crowded.

Factor in readability when you choose. WCAG 2.2 asks for at least 4.5:1 contrast for normal text and 3:1 for large text. The two cards in the panel measure the color on white and on black. Each card labels the result as AAA, AA, large text only or too low. Because the ratio is symmetric, the value on the white card also applies to white text placed on this color. Click a card to open the Color Contrast Checker with the same color. That tool then suggests the closest shade that passes.

For the bigger picture, read my post on web accessibility and WCAG. Want to set up your site's colors from scratch? Our web design service covers palette, typography and contrast together.

Common mistakes with HTML color codes

  • MistakeTaking a color from a screenshot or a compressed JPEGDo this insteadTake the code from the design file or brand guide. A sampled color can drift a few steps because of compression and screen settings.
  • MistakeCopying a transparent color as a 6 digit HEXDo this insteadPaste #00000080 as #000000 and the transparency is gone. Copy the 8 digit HEX or the rgba() value instead.
  • MistakePutting white text on a light brand colorDo this insteadCheck the white card first. Below 4.5:1, use dark text or pick a darker shade from the Shades strip.
  • MistakeTreating a CSS color name as a brand colorDo this insteadNames such as orange or gold are fine for quick tests. For the brand, define your own HEX code as a variable.
  • MistakeTyping an HSB value into hsl()Do this insteadAn HSB value from Figma inside hsl() gives a completely different color. Enter those values as hsb() instead.

Frequently Asked Questions

A color palette is only the first step of brand identity.

The right palette, logo, typography and a consistent visual language make a brand memorable. Let's design your brand identity together.

Explore Brand Identity

Related Tools

All Tools (91)
Case ConverterUPPER, lower, Title and Sentence case; correct Turkish İ/ı handling.
Giveaway PickerFair winners + backups from a name list; cryptographic randomness, no sign-up.
Readability CheckerReadability score with Flesch (EN), Ateşman (TR) and Flesch-Amstad (DE).
Hashtag GeneratorPick a topic and niche; get a balanced big, medium and niche set that fits Instagram's 5 hashtag limit.
Word & Character CounterWords, characters, sentences + live checks against Google, Instagram, X limits.
IG Engagement RateMeasure real account strength: ER calculation + tier scale + influencer check.