Overview
Introduction
This tool reverses #RRGGBB hex color notation back into the packed 24-bit integer value it represents, the same packing used in graphics APIs and pixel buffers.
It's the counterpart to the Integer to Pixel Converter, letting you recover the raw integer behind a hex color you already have.
What Is Pixel to Integer Converter?
A converter that takes a list of hex color strings, one per line, in either #RRGGBB or bare RRGGBB form, and outputs the packed 24-bit integer each one represents.
It only accepts the full 6-hex-digit form; 3-digit shorthand colors (like #F00) aren't literal packed-integer notation and aren't supported.
How Pixel to Integer Converter Works
Each line is matched against a pattern allowing an optional leading "#" followed by exactly 6 hexadecimal digits.
Those 6 digits are parsed as a single base-16 number using `parseInt` with radix 16.
The resulting value is the packed 24-bit integer, with red in the top 8 bits, green in the middle 8, and blue in the bottom 8.
When To Use Pixel to Integer Converter
Use it to recover the packed integer value behind a hex color for use in graphics code, image data, or APIs that expect a single numeric color value.
It's also useful for verifying round-trip correctness with the Integer to Pixel Converter.
Often used alongside Integer to Pixel Converter and Hex to Integer Converter.
Features
Advantages
- Accepts both the common #RRGGBB and bare RRGGBB forms without requiring extra formatting.
- Case-insensitive, so it works with hex colors from any source style.
Limitations
- Doesn't support 3-digit shorthand colors (like #F00) or colors with an alpha channel (#RRGGBBAA).
- Requires exactly 6 hex digits; shorter or longer strings are rejected.
Examples
Best Practices & Notes
Best Practices
- Expand any 3-digit shorthand colors (like #F00 to #FF0000) before using this tool, since only the full 6-digit form is accepted.
Developer Notes
Uses a single regex, `/^#?([0-9a-fA-F]{6})$/`, to accept the optional hash and validate exactly 6 hex digits in one step, then `parseInt(match[1], 16)` to get the packed value.
Pixel to Integer Converter Use Cases
- Recovering the packed integer color value behind a #RRGGBB hex color for graphics code
- Verifying round-trip correctness against the Integer to Pixel Converter
- Converting a list of hex colors into their numeric values for sorting or comparison
Common Mistakes
- Using a 3-digit shorthand color (like #F00), which isn't accepted since it isn't literal 6-digit packed-integer notation.
- Including an alpha channel (#RRGGBBAA), which has 8 digits and won't match the expected 6-digit pattern.
Tips
- Use the companion Integer to Pixel Converter to generate valid 6-digit test colors from known integers.