Color Converter

Type or paste a color in any format and get every other format at once.

Luminance
 
Contrast on white
 
Contrast on black
 
Best text color
 
Decimal
 

Code snippets

Convert many colors at once

How to use the Color Converter

  1. Enter a color in any field: HEX, RGB, HSL, HSV, HWB, CMYK, LAB, OKLCH or a CSS name.
  2. All the other fields update as you type. Invalid input is highlighted.
  3. Click the copy button next to any format, or copy ready-made code for CSS, Tailwind, Android, Flutter, SwiftUI, UIKit, Unity or GLSL.
  4. To convert a whole list, paste it into Convert many colors at once and pick the target format.

Color Converter features

  • Ten formats: HEX, RGB, HSL, HSV, HWB, CMYK, CIE LAB, OKLCH, OKLab and CSS names
  • Type in any field and all the others update instantly
  • Ready-made code for CSS, Tailwind, Android, Compose, Flutter, SwiftUI, UIKit, Unity and GLSL
  • Batch conversion of whole lists, with copy and .txt download
  • Luminance, contrast on white and black, and the best text color
  • Transparency supported in HEX, RGB and HSL

Convert any color code to any other format

This color converter turns a color in one format into all the others at once. Type or paste a value into any field (HEX, RGB, HSL, HSV, HWB, CMYK, CIE LAB, OKLCH, OKLab or a CSS color name) and every other field updates as you type. It is the fastest way to go from hex to RGB, RGB to hex, hex to HSL, HSL to hex, hex to CMYK or hex to OKLCH without doing the math yourself.

You do not need to choose a direction or tell the converter which format you entered. It recognises the format automatically, including short hex codes, 8-digit hex with transparency, rgba(), hsla() and the modern space-separated CSS syntax.

Supported color formats

FormatExample (tomato)Typical use
HEX#FF6347CSS, HTML, design apps
RGB / RGBArgb(255, 99, 71)CSS, JavaScript, canvas
HSL / HSLAhsl(9, 100%, 64%)CSS, adjusting colors by hand
HSV / HSBhsv(9, 72%, 100%)Photoshop, Figma, Procreate
HWBhwb(9 28% 0%)CSS Color Level 4
CMYKcmyk(0%, 61%, 72%, 0%)Print reference
CIE LABlab(62.99% 59.37 47.88)Color science, print and photo editing
OKLCHoklch(69.62% 0.1955 32.32)Modern CSS and design systems
OKLaboklab(69.62% 0.1652 0.1045)Smooth gradients and color mixing
CSS nametomatoReadable CSS; the closest name is shown for other colors

Code for apps and games

Under the preview you will find the same color written for the platforms developers use most. Click one to copy it:

  • CSS with the modern rgb(r g b / a) syntax and a Tailwind arbitrary value such as bg-[#FF6347].
  • Android XML (#AARRGGBB) and Jetpack Compose.
  • Flutter Color(0xFFFF6347).
  • SwiftUI and UIKit with channel values from 0 to 1.
  • Unity new Color(...) and GLSL vec4(...) for shaders.
  • The color as a single decimal integer, used by some APIs and Discord embeds.

The converter also reports the color's relative luminance, its contrast against white and black text and whether black or white text reads better on it.

Convert a list of colors at once

Have a whole palette or a list of brand colors to convert? Paste them into Convert many colors at once, one per line or separated by commas, and choose the target format. You can mix formats in the input. The result can be copied or downloaded as a text file, and the list is remembered in your browser so you can come back to it.

How the conversions work

All conversions follow the formulas in the CSS Color Module, using the sRGB color space and the D65 white point that browsers use. That means the values you copy match what a browser renders. A few things are worth knowing:

  • HEX, RGB, HSL, HSV and HWB are different ways of describing the same sRGB colors, so converting between them is exact apart from rounding.
  • CMYK is calculated with the standard, uncalibrated formula. Real print results depend on the paper, ink and printer profile, so ask your printer for exact values in color-critical work.
  • LAB, OKLab and OKLCH can describe colors outside the sRGB range. When you enter one of those, it is brought into the range a standard sRGB screen can show.

Hex to RGB: how it works by hand

A hex code is three pairs of hexadecimal digits. Convert each pair to a decimal number from 0 to 255: #FF6347 splits into FF = 255, 63 = 99 and 47 = 71, which gives rgb(255, 99, 71). Going the other way, convert each channel to hexadecimal and join them. For more on each format, see the HEX Color Picker, RGB Color Picker and HSL Color Picker.

Related tools

Pick a color visually with the Color Picker, get a color code from a photo with the Image Color Picker, or check whether two colors have enough contrast with the Contrast Checker.

Color Converter: frequently asked questions

What is OKLCH?

OKLCH is a perceptual color space supported by modern CSS. Changing its lightness keeps colors looking evenly spaced, which makes it great for design systems.

Why are some CMYK values approximate?

Converting screen colors to print depends on the paper and ink. This tool uses the standard uncalibrated formula, which is fine for reference but not for color-managed print work.

Can I enter colors with transparency?

Yes. 8-digit hex, rgba(), hsla() and the slash syntax like rgb(0 0 0 / 50%) are all supported.

How do I convert hex to RGB?

Paste the hex code into the HEX field and read the RGB field. By hand, convert each pair of hex digits to decimal: #FF6347 becomes 255, 99 and 71.

How do I convert RGB to hex?

Type the RGB value, such as rgb(255, 99, 71), into the RGB field and copy the HEX field (#FF6347).

Can I convert many colors at once?

Yes. Paste a list into Convert many colors at once, one per line or separated by commas, and choose the target format. Mixed input formats are fine.

How do I use a hex color in Flutter or Android?

Flutter and Compose expect Color(0xAARRGGBB), with the alpha first. Android XML uses #AARRGGBB. The code snippets section writes these for you.