Android color int to HEX

Paste the number as it appears in a log or debugger, such as -16777216, to see the color and its alpha.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter color int.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

A negative value gets 2^32 added, then A = floor(u ÷ 2^24) and R, G, B are the next bytes in order.

Example

Inputs: Color int = -32,768. Result: Android HEX (#AARRGGBB): #FFFF8000; Alpha byte: 255.

Limits and caveats

  • A value of 16777215 or less has alpha 0, so on Android it is fully transparent. That is correct but can be surprising.

Questions about this tool

What color is -16777216?

Opaque black #FF000000, which is Color.BLACK on Android.

Should I enter the signed or unsigned value?

Either works: -32768 and 4294934528 both give #FFFF8000.

Why is the CSS code sometimes 8 digits?

When alpha is below FF it is appended to the CSS code; opaque colors stay at 6 digits.