# Color converter

> Turn any color into HEX, RGB, HSL, OKLCH, and CMYK, and check the contrast ratio.

Free color converter and contrast checker. Paste HEX, RGB, HSL, OKLCH, CMYK, or a CSS color name and read every format back. The contrast ratio uses WCAG 2, with AA and AAA flags for normal and large text, plus the nearest Tailwind token.

- Page: https://benchline.fabwaseem.com/t/color-converter
- Runs: in the browser. Input stays on the device.
- Price: free, no account
- Input: A foreground color in HEX, RGB, HSL, OKLCH, CMYK, or a CSS name, and a background color.
- Output: HEX, RGB, HSL, OKLCH, CMYK, the nearest Tailwind token, and the WCAG contrast ratio.
- Keywords: hex to rgb, contrast checker, oklch converter, cmyk converter, hsl to hex
- Updated: 2026-10-18
- Built by: Waseem Anjum (https://fabwaseem.com)

## How to use it

1. **Paste a color.** Use HEX, rgb(), hsl(), oklch(), cmyk(), or a CSS name. The swatch and every format update together.
2. **Copy the format you need.** Each row has its own copy button for HEX, RGB, HSL, OKLCH, and CMYK.
3. **Check the contrast.** Set a background. The ratio and the AA and AAA flags use WCAG 2, after flattening any transparency.

## Use it from an AI agent

MCP tool name: `convert_color`
MCP endpoint: https://benchline.fabwaseem.com/mcp (Streamable HTTP, no key)
HTTP: POST https://benchline.fabwaseem.com/api/v1/tools/color-converter with the input as the JSON body
This call does not fetch anything. It runs on the arguments you send.

Convert HEX, RGB, HSL, OKLCH, or CMYK into every format, name the nearest Tailwind token, and report the WCAG 2 contrast ratio against a background.

### Input schema

```json
{
  "type": "object",
  "properties": {
    "color": {
      "type": "string",
      "description": "HEX, rgb(), hsl(), oklch(), cmyk(), or a CSS color name."
    },
    "background": {
      "default": "#ffffff",
      "description": "Background used for the WCAG contrast ratio.",
      "type": "string"
    }
  },
  "required": [
    "color",
    "background"
  ],
  "additionalProperties": false
}
```

### Example tools/call

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "convert_color",
    "arguments": {
      "color": "example",
      "background": "#ffffff"
    }
  }
}
```

Setup for Claude, Cursor, and VS Code: https://benchline.fabwaseem.com/mcp/guide

## Questions

### Which color formats can I paste?

HEX (#ff0000 or #f00), rgb(), hsl(), oklch(), cmyk(), and CSS names such as rebeccapurple. The page fills HEX, RGB, HSL, OKLCH, and CMYK from that one value.

### How is the contrast ratio measured?

It is the WCAG 2 contrast ratio from relative luminance. 4.5:1 passes AA for normal text. 3:1 passes AA for large text and interface components. 7:1 passes AAA for normal text. Large text AAA uses 4.5:1.

### Do transparent colors count?

Yes. A color with alpha is flattened over the background you pick, then the ratio is measured on that opaque result.

### What is OKLCH?

OKLCH is lightness, chroma, and hue in the OKLab space. Lightness tracks what looks lighter, so it is easier to build a ramp than HSL.

### Is the CMYK value a print profile?

No. It is the simple device conversion from the sRGB bytes: the black plate is whatever the darkest channel leaves behind. A press profile will differ.

### What does the Tailwind name mean?

It is the nearest token in the current Tailwind palette, measured in OKLab. red-500 next to pure red means that token is the closest chip, not that the hex is identical.

## Related tools

- [OG image generator](https://benchline.fabwaseem.com/t/og-image-generator): Pick a template, watch the card update, then download the PNG or copy the Next.js file.
- [Image format converter](https://benchline.fabwaseem.com/t/image-convert): Convert HEIC, WebP, PNG, JPG, and AVIF in the browser. Nothing is uploaded.
- [Image resizer](https://benchline.fabwaseem.com/t/image-resize): Resize by pixels or percent, with the aspect ratio locked and a batch ZIP.
- [Image compressor](https://benchline.fabwaseem.com/t/image-compress): Shrink JPEG, PNG, WebP, and AVIF in the browser, with the real before and after size.
