HEX to RGB Converter

Convert HEX color codes to RGB values quickly and accurately for web design and digital projects.


Paste a 3- or 6-digit HEX code, with or without the # sign.
Clear

What is a color converter?

A color converter translates a single color between the formats used across the web, design, and print. The same shade of blue can be written as #4F8AB2, rgb(79, 138, 178), hsl(207, 38%, 50%), or cmyk(56%, 22%, 0%, 30%) - different formats serve different tools, but they all describe the same color.

Color format reference

  • HEX - A 6-character hex code used in CSS and design tools, like #4F8AB2.
  • RGB - Red, Green, Blue components from 0 to 255 - used by CSS and most APIs.
  • HSL - Hue (0-360), Saturation (%) and Lightness (%) - easier to reason about visually.
  • CMYK - Cyan, Magenta, Yellow, Key - the four-channel format used for print.

How to convert HEX to RGB manually

A HEX color is just three pairs of hexadecimal (base-16) digits. Convert each pair to a decimal number from 0 to 255.

  1. Split the 6-digit HEX into three pairs: RR, GG, BB (drop the leading #).
  2. For each pair, multiply the first digit by 16 and add the second digit (A=10, B=11, … F=15).
  3. The three results are your Red, Green and Blue values.

Example: #4F8AB2 → 4F = 4×16 + 15 = 79, 8A = 8×16 + 10 = 138, B2 = 11×16 + 2 = 178 → rgb(79, 138, 178).

Use this tool from your AI agent

Free JSON API and Model Context Protocol (MCP) server. No signup, no API key, CORS open. Designed for Claude, ChatGPT, Cursor, scripts and frontend apps.

curl -X POST https://mate.tools/api/v1/color-convert.php \
  -H "Content-Type: application/json" \
  -d '{"color":"#FF5733"}'
import urllib.request, json

req = urllib.request.Request(
    "https://mate.tools/api/v1/color-convert.php",
    data=json.dumps({"color":"#FF5733"}).encode(),
    headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as r:
    print(json.load(r))
const r = await fetch("https://mate.tools/api/v1/color-convert.php", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({"color":"#FF5733"}),
});
console.log(await r.json());

Add to claude_desktop_config.json (Claude Desktop), ~/.cursor/mcp.json (Cursor), or any other MCP-compatible client:

{
  "mcpServers": {
    "mate-tools": {
      "command": "npx",
      "args": ["-y", "@mate-tools/mcp-server"]
    }
  }
}
API documentation OpenAPI 3.1 npm 60 req/min · 600 req/hour · 1 MB body cap

Frequently Asked Questions

Split the HEX code into three pairs and convert each pair from hexadecimal to decimal. For #4F8AB2: 4F = 79, 8A = 138, B2 = 178, giving rgb(79, 138, 178). The converter does this for you in real time.

HEX, RGB, and HSL all describe the same RGB color in different notations: HEX is compact, RGB is direct channel values, and HSL is intuitive for adjusting hue, saturation, or brightness. CMYK is a separate four-channel space designed for printing - it is computed from RGB and may not perfectly match every screen color.

Yes. Three-digit HEX codes are shorthand where each digit is doubled - so #FA0 expands to #FFAA00. The converter accepts both 3- and 6-digit forms, with or without the leading #.

Screens use additive RGB while print uses subtractive CMYK, and not every RGB color has a perfect CMYK match. Professional design software adjusts for the specific paper, ink, and printer profile - the values shown here are a mathematical conversion useful as a starting point.

RGB channels are clamped to 0-255 and HSL saturation and lightness to 0-100%. Hue is treated as a 0-360 degree value. If you enter a value outside the range, the converter rounds it back into the valid range and updates all other formats accordingly.

How Do I Convert HEX to RGB?

A HEX to RGB converter changes a hex color code like #FF8800 into RGB values for use in design tools and code. Each pair of hex digits is one channel - red, green and blue - with a value from 0 to 255.