Skip to content
MyToolkit.pro

Code & Data

Color Converter

Paste a color in any notation — #f80, rgb(255, 136, 0), hsl(32, 100%, 50%) or a CSS name — and see every other format at once. Pick a color visually, drag the channel sliders, check WCAG contrast and grab a lighter or darker variant. Your data never leaves this browser.

Private by design: no text is uploaded or stored.

HEX (#f80, #ff8800, #ff8800aa), rgb()/rgba(), hsl()/hsla(), a bare 255, 136, 0 triple, or a CSS name like teal.

Private by design: no text is uploaded or stored.

Channels

Try an example

Result

Updates as you type, pick or drag.

Every format

HEX
HEX8
RGB
RGBA
HSL
HSLA

Contrast & accessibility (WCAG 2.1)

On white
—:1

Sample text

On black
—:1

Sample text

AA needs 4.5:1 for body text, AAA needs 7:1. “AA Large” (3:1) covers text from 18.66px bold or 24px.

Lighter and darker

Same hue and saturation at five lightness steps — click a swatch to load it.

How does the conversion work?

The input format is detected for you, so there is no direction to choose. HEX values may be 3, 4, 6 or 8 digits, with or without a leading #, and the 4- and 8-digit forms carry an alpha channel. rgb()/rgba() and hsl()/hsla() accept commas or spaces and the modern slash-alpha syntax such as rgb(255 136 0 / 50%). A bare 255, 136, 0 triple and the 16 basic CSS color names also work. HSL is computed with the standard conversion and rounded to whole degrees and percents. Contrast uses the WCAG 2.1 relative-luminance formula against white and black: 7:1 passes AAA, 4.5:1 passes AA, and 3:1 passes AA for large text. Everything runs locally in your browser.

How to convert HEX to RGB (or RGB to HEX)

The tool works out which notation you pasted, so you don't pick a direction. Every format is calculated from the same value.

  1. Paste or type a value into Color to convert: #1e90ff, rgb(30, 144, 255), hsl(210, 100%, 56%), or just 30, 144, 255.
  2. Read the six cards under Every format: HEX, HEX8, RGB, RGBA, HSL and HSLA. They update as you type, so you don't need to press Convert.
  3. Click Copy on a card to copy that one string, for example rgb(30, 144, 255) to paste into a stylesheet.
  4. To adjust the color instead of typing it, use Pick a color or drag the Red, Green, Blue and Alpha sliders. If Alpha is below 1, the input switches to an rgba() value. At full opacity it switches to a 6-digit hex.
  5. To get all formats plus both contrast ratios as plain text, use Copy all. The text keeps the same English labels (HEX: …, Contrast vs white: …) whatever language the page is in.

Worked examples

A HEX code like Dodger Blue, converted to the other formats:

Input: #1e90ff
HEX:   #1e90ff
HEX8:  #1e90ffff
RGB:   rgb(30, 144, 255)
HSL:   hsl(210, 100%, 56%)
Contrast vs white: 3.24 (AA Large)
Contrast vs black: 6.49 (AA)

An RGB color with transparency, written in the modern space-and-slash syntax:

Input: rgb(255 136 0 / 50%)
HEX:   #ff8800
HEX8:  #ff880080
RGBA:  rgba(255, 136, 0, 0.5)
HSLA:  hsla(32, 100%, 50%, 0.5)

The plain HEX card drops the alpha. Only HEX8, RGBA and HSLA keep it.

Some other inputs and what they give:

Input HEX RGB HSL
#f80 #ff8800 rgb(255, 136, 0) hsl(32, 100%, 50%)
teal #008080 rgb(0, 128, 128) hsl(180, 100%, 25%)
#336699 #336699 rgb(51, 102, 153) hsl(210, 50%, 40%)
hsl(400, 50%, 50%) #bf9540 rgb(191, 149, 64) hsl(40, 50%, 50%)

Hues above 360° wrap around, so 400 is read as 40.

When you'd reach for it

  • Moving a brand color from a design file into code. A designer gives you #336699, but your theme variables use hsl() so you can change lightness. Copy the HSL card and edit only the last number.
  • Checking a button label before shipping. Teal (#008080) scores 4.77:1 on white, which passes AA for body text. Orange #ff8800 scores 2.39:1 on white, which fails, but 8.77:1 on black. That means dark text on an orange button is the readable choice.
  • Building hover and pressed states. The Lighter and darker row gives five shades of the same hue and saturation at 10%, 30%, 50%, 70% and 90% lightness. For #ff8800 they are #331b00, #995200, #ff8800, #ffb866 and #ffe7cc. Click one to load it and convert it.
  • Reading a semi-transparent overlay. A token like #00000080 shows up as rgba(0, 0, 0, 0.5), so you can see the opacity right away.

When you have the colors you need, you can turn them into a full scheme with the Color Palette Generator or a background with the CSS Gradient Generator. The article How to Build a CSS Gradient: Angles, Stops and Fallbacks covers what to do with hex stops after that.

Limits and edge cases worth knowing

  • Named colors: only the 16 basic CSS names are recognised (black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, aqua). Extended names such as orange or rebeccapurple show an error. Enter their hex codes instead.
  • HSL is rounded: the tool rounds HSL to whole degrees and percents, so a round trip can be off by one per channel. #1e90ff shows as hsl(210, 100%, 56%), but typing that HSL back in gives #1f8fff. Copy HEX or RGB when you need the exact value.
  • Out-of-range values are rejected: RGB channels must be 0–255 (or 0%–100%), saturation and lightness 0%–100%, and alpha 0–1. rgb(300, 0, 0) shows an error rather than being clamped to 255.
  • Alpha uses two decimals: the tool stores opacity in hundredths, so a few 8-digit hex alphas shift by one step (for example 81 comes back as 82).
  • The color picker has no alpha: picking a color from the native picker replaces the input with a 6-digit hex, which resets transparency to opaque.
  • Only sRGB notations: there's no hwb(), lab(), oklch(), CMYK or Pantone. For the full CSS syntax, see MDN's <color> reference.

Frequently asked questions

How do I convert a hex code to RGB by hand?

Split the six digits into three pairs and read each pair as a base-16 number: in #1e90ff, 1e is 30, 90 is 144 and ff is 255, so the color is rgb(30, 144, 255). For a 3-digit code such as #f80, double each digit first (#ff8800).

What is the difference between HEX and HEX8?

HEX8 adds a fourth pair of digits for opacity, from 00 (fully transparent) to ff (fully opaque). #ff880080 is the same orange as #ff8800 at about 50% opacity.

Is RGB or HEX better for CSS?

Browsers render both the same way, so the choice is about readability. HEX is shorter. rgb() and hsl() make it easier to see or edit individual channels and opacity.

What contrast ratio do I need for accessible text?

WCAG 2.1 asks for at least 4.5:1 for normal body text (level AA) and 7:1 for level AAA. Large text, meaning 24px or 18.66px bold, needs 3:1 for AA.

All in Code & Data

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 to text instantly in your browser.

Code & Data In your browser

JSON to CSV

Convert a JSON array of objects to CSV in your browser. Choose the delimiter, keep or drop the header row, with correct quoting. Nothing is uploaded.

Code & Data In your browser

CSV to JSON

Convert CSV to a JSON array in your browser. Choose the delimiter, use the first row as keys, pretty-print or minify, with RFC 4180 quoting. Nothing is uploaded.

Code & Data In your browser

Number Base Converter

Convert numbers between binary, octal, decimal and hexadecimal in your browser. Arbitrarily large integers supported. Nothing is uploaded.

Code & Data In your browser

CSS Gradient Generator

Build a linear or radial CSS gradient from hex colour stops, copy the ready background declaration and see a live preview. Nothing is uploaded.

Code & Data In your browser

Color Palette Generator

Generate a harmonious colour palette from one hex colour — complementary, analogous, triadic, tetradic or monochrome. Runs in your browser, nothing uploaded.

Code & Data In your browser

What do you need?

Swipe up for the next one