Integer to Pixel Converter

Converts a list of integers (one per line, 0-16777215) into #RRGGBB hex color strings, treating each integer as a packed 24-bit RGB value (8 bits each for red, green, and blue). A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-27

Overview

Introduction

Graphics code often stores an RGB color as a single packed 24-bit integer rather than three separate red/green/blue values. This tool converts a list of such integers into readable #RRGGBB hex color strings.

It's the same packing scheme used throughout web development and image formats: 8 bits per channel, red first, then green, then blue.

What Is Integer to Pixel Converter?

A converter that takes a list of integers, one per line, in the range 0 to 16777215, and outputs each one as a #RRGGBB hex color string.

Each integer is treated as a packed 24-bit RGB value, exactly as used in CSS hex colors, image pixel buffers, and many graphics APIs.

How Integer to Pixel Converter Works

Each line is parsed as a non-negative whole number and checked against the maximum packed value of 16777215.

The red component is extracted from bits 16-23, green from bits 8-15, and blue from bits 0-7, using bit shifting and masking.

Each 8-bit component is converted to a 2-digit uppercase hex string and the three are joined with a leading "#".

When To Use Integer to Pixel Converter

Use it when you have a packed integer color value (from a data format, pixel buffer, or API) and need its readable hex color equivalent.

It's also useful for teaching how RGB colors map to a single packed integer.

Features

Advantages

  • Produces standard #RRGGBB syntax directly usable in CSS, HTML, or most graphics tools.
  • Validates the input range, catching values that couldn't represent a valid 24-bit color.

Limitations

  • Only supports 24-bit RGB (no alpha channel); values requiring transparency need a separate alpha component.
  • Doesn't validate whether the resulting color is meaningful for any particular use case, only that it's a valid packed value.

Examples

Pure red

Input

16711680

Output

#FF0000

Black

Input

0

Output

#000000

Best Practices & Notes

Best Practices

  • If you need an alpha channel too, handle it as a separate value outside this tool, since the packing here is strictly 24-bit RGB.

Developer Notes

Uses bit shifting (`(n >> 16) & 0xff`, `(n >> 8) & 0xff`, `n & 0xff`) to extract each channel, which is safe here since the valid input range (up to 16777215) stays well within JavaScript's 32-bit bitwise operator range.

Integer to Pixel Converter Use Cases

  • Converting packed pixel/color integers from image data or APIs into readable hex colors
  • Teaching how a single integer encodes a full RGB color
  • Generating test hex colors from known packed integer values

Common Mistakes

  • Entering a value above 16777215, which can't be represented in 24 bits and is rejected.
  • Expecting an alpha channel to be included; this tool only handles the 24-bit RGB portion.

Tips

  • Use the companion Pixel to Integer Converter to confirm a hex color round-trips back to the same packed integer.

References

Frequently Asked Questions