Tools / Color Converter / RGB → HEX

RGB to HEX Converter.

RGB to HEX is the reverse of reading a hex string: take each 0-255 channel, convert it to a two-digit base-16 number, and concatenate them behind a #. The only gotcha is zero-padding — a channel like 5 must become 05, not 5.

HEX —
All formats

    The RGB → HEX formula

    hex = '#' + toHex(R) + toHex(G) + toHex(B) where toHex(n) = n.toString(16).padStart(2,'0').

    Worked example

    Convert rgb(154, 42, 42):

    1. Red: 154 = 9A in hex
    2. Green: 42 = 2A in hex
    3. Blue: 42 = 2A in hex
    4. Concatenate: #9A2A2A

    JavaScript

    const h = n => n.toString(16).padStart(2,"0");
    const hex = "#" + h(154) + h(42) + h(42); // "#9a2a2a"

    FAQ

    Why pad to two digits?

    Each channel must occupy exactly two hex digits. Without padding, rgb(5, 16, 255) would collapse to #510ff instead of #0510FF.

    Upper or lower case?

    Both are valid and identical to browsers. Designers often prefer uppercase for readability; it carries no semantic difference.

    Paid links below. As an Amazon Associate we earn from qualifying purchases.

    Library

    Colour references for your next project

    Compare the original references behind this archive. Check the contents, edition and format before choosing a book.

    Book links are Amazon Associates affiliate links. Your price is unchanged; a small commission supports the archive. As an Amazon Associate we earn from qualifying purchases.

    • A Dictionary of Color Combinations by Sanzo Wada — book cover

      Sanzo Wada

      A Dictionary of Color Combinations

      The 2010 Seigensha republication of the 1933–34 original. Japanese import.

      The printed original behind this archive: Wada's 1933–34 combinations on Seigensha's matte plates, in a Japanese binding small enough to carry, and a copy you can cite. Every plate is also free to browse here, hex values and all. Already know it? Vol. 2 is a different book of his later work.

    • A Dictionary of Color Combinations Vol. 2 by Sanzo Wada — book cover

      Sanzo Wada

      A Dictionary of Color Combinations Vol. 2

      Seigensha, 2020. Japanese import.

      Wada's 1935–36 and 1938 follow-ups: 72 plates on the Japanese seasons and 165 drawn from early-century fashion, interior, and graphic design. Not in Vol. 1. Not in this archive. The book itself is a design object — Japanese binding, matte pages, zero captions.

    Torn between the two Wada dictionaries? Vol 1 vs Vol 2, compared plate by plate →

    Book links are Amazon Associates affiliate links. Your price is unchanged; a small commission supports the archive. As an Amazon Associate we earn from qualifying purchases.

    Last updated

    Looking for a combination we don’t have yet?

    Tell us the colour, mood, or palette you were after — it shapes which editorial combinations we add next.

    Did you find what you were looking for?

    Not quite? Tap what was off: