ColorToolkits
Format Converter

RGB to Hex Converter

Convert decimal RGB values (0–255) into clean lowercase/uppercase hexadecimal codes with instant clipboard copy and CSS snippet.

Converted (HEX)
#2563eb
#2563EB
Try presets:

How to Use This Tool

  1. Enter or paste your RGB value or choose one of the curated preset swatches.
  2. Copy the formatted HEX value directly, or inspect the secondary HEX, RGB, HSL, and OKLCH chips below.
  3. Click into Tailwind Scale Generator or Contrast Checker to validate accessibility on the converted shade.

Key Features

  • Bidirectional parsing supporting CSS Color Level 4 syntax cleanly
  • Each channel integer R, G, and B (0–255) converts to base-16 via toString(16) and pads with a leading zero whenever the byte is below 16.
  • Instant clipboard feedback with live OKLCH and Display-P3 gamut safety
  • Zero server round-trips—every calculation executes immediately in browser memory

Converting 0–255 channels to Hexadecimal

Each channel integer R, G, and B (0–255) converts to base-16 via toString(16) and pads with a leading zero whenever the byte is below 16.

Reference Snippet (JavaScript)

const toHex = (r, g, b) =>
  '#' + [r, g, b].map((v) => v.toString(16).padStart(2, '0')).join('');

Frequently Asked Questions

More Color Tools

View all tools →