What is a hexadecimal number?

Hexadecimal, or hex, is base 16. It counts with the digits 0 to 9 and then the letters A to F for ten to fifteen, so F is 15, FF is 255 and 100 is 256. One hex digit stands for four bits and two make a byte, which is why hex is the usual way to write byte values, memory addresses, error codes, color codes such as #FF8800, Unicode code points such as U+00E9 and MAC addresses. In program code, a hex number usually starts with 0x, as in 0x1F.

You check a hex number when a form, a config file or a script expects one, or before you convert it to decimal.

Tool description

Type or paste a value into the Hexadecimal number field, and the result shows as you type: "Hexadecimal number is valid" or "Hexadecimal number is not valid". Spaces and line breaks around a pasted value are ignored. The page has no settings: the rules below always apply.

Numbers that pass

  • The digits 0 to 9 and the letters A to F, small, capital or mixed: FF, ff, 7E3, Ab12
  • A 0x or 0X prefix: 0x1F, 0XFF
  • The rarer 0h prefix: 0hFF
  • Leading zeros and any number of digits: 00FF, FF8800

Numbers that fail

  • The # of color codes: #FF8800
  • Other prefixes and suffixes: $FF, &HFF, \xFF, U+00E9, 0FFh
  • A plus or minus sign: -FF, +0x10
  • Spaces, colons or underscores inside: FF FF, FF:FF, FF_FF
  • A prefix with no digits after it: 0x
  • Letters after F, and decimal points: G1, 1.8

Good to know

  • Every whole number written without a sign, such as 42, is also a valid hex number, so the check can't tell which base someone meant.
  • B and E are hex digits, so 0b1010 and 1e5 pass too, although they look like a binary number and e notation.
  • The check doesn't look at the length, so it can't tell whether a value fits in a byte or any other size.
  • To check a color code with its #, use the Hex Color Validator. To see what a hex number is in decimal, use the Hexadecimal to Decimal Converter.

Features

  • Checks hexadecimal numbers in any letter case
  • Accepts the 0x and 0h prefixes
  • Results as you type, with no button to press
  • Runs in your browser, so nothing you type is sent anywhere