Hex Encoder/Decoder

Convert text to hexadecimal (base-16) and back. Essential tool for developers, debuggers, and anyone working with low-level data.

0 characters

About Hexadecimal Encoding

Hexadecimal (hex) is a base-16 number system using digits 0-9 and letters A-F. It's widely used in computing because it provides a human-readable representation of binary data, with each hex digit representing exactly 4 bits.

Hexadecimal Chart

DecimalHexadecimalBinaryDecimalHexadecimalBinary
000000881000
110001991001
22001010A1010
33001111B1011
44010012C1100
55010113D1101
66011014E1110
77011115F1111

ASCII to Hex Examples

CharacterASCII DecimalHexadecimalBinary
A650x4101000001
a970x6101100001
0480x3000110000
Space320x2000100000
!330x2100100001

Common Use Cases

  • Memory Addresses: Display RAM addresses (0x7FFF0000)
  • Color Codes: Web colors (#FF5733 = RGB red, green, blue)
  • MAC Addresses: Network hardware (00:1A:2B:3C:4D:5E)
  • File Signatures: Magic numbers (PNG = 89 50 4E 47)
  • Debugging: View raw data in memory dumps
  • Cryptography: Display hash outputs and keys
  • Unicode: Character codes (U+1F600 = 😀)

Why Use Hexadecimal?

✓ Advantages

  • • More compact than binary (4 bits = 1 hex digit)
  • • Human-readable compared to raw binary
  • • Easy conversion between hex and binary
  • • Aligns with byte boundaries (2 hex = 1 byte)
  • • Standard for memory addresses and dumps
  • • Used in color codes, MAC addresses, etc.

Conversion Examples

Binary: 11111111
Hex: FF
Decimal: 255
Binary: 10101100
Hex: AC
Decimal: 172

Hex in Programming Languages

JavaScript/TypeScript

// Hex literal
const hex = 0xFF; // 255

// Convert to hex
const num = 255;
num.toString(16); // "ff"

// Parse hex string
parseInt("FF", 16); // 255

Python

# Hex literal
hex_val = 0xFF  # 255

# Convert to hex
hex(255)  # '0xff'

# Parse hex string
int('FF', 16)  # 255

C/C++

// Hex literal
int hex = 0xFF; // 255

// Print as hex
printf("%X", 255); // FF

// Parse hex string
int val = strtol("FF", NULL, 16);

Frequently Asked Questions

Why is hex used instead of decimal?

Hexadecimal maps perfectly to binary - each hex digit represents exactly 4 bits. This makes it much easier to read and write binary data. For example, the byte 11111111 is simplyFF in hex, but 255 in decimal (no clear relationship to binary).

Are hex letters case-sensitive?

No, hexadecimal letters (A-F) are not case-sensitive. 0xFF, 0xff, and 0xFf all represent the same value (255). Most programming languages and tools accept both uppercase and lowercase.

What does the 0x prefix mean?

The 0x prefix indicates a hexadecimal number in most programming languages. For example, 0x10 means hex 10 (decimal 16), not decimal 10. Without the prefix,10 would be interpreted as decimal.

How do I convert hex color codes?

Hex color codes like #FF5733 consist of three parts: Red (FF = 255), Green (57 = 87), and Blue (33 = 51). Each color channel uses 2 hex digits, representing values 0-255.

What's the maximum hex value?

For a single byte (8 bits), the maximum hex value is FF (decimal 255). For two bytes (16 bits), it's FFFF (decimal 65,535). For four bytes (32 bits), it'sFFFFFFFF (decimal 4,294,967,295).

Can hex represent negative numbers?

Hex itself doesn't have signs, but it can represent negative numbers using two's complement. For example, in an 8-bit signed system, 0xFF represents -1, 0xFE is -2, and 0x80 is -128. The interpretation depends on whether you're treating it as signed or unsigned.