Hex Encoder Encoders
Input
Output
Settings
What is Hexadecimal Encoding?
Hexadecimal (hex) is a base-16 number system that uses 16 distinct symbols: 0-9 to represent values zero to nine, and A-F (or a-f) to represent values ten to fifteen. In computing, hexadecimal is widely used because it provides a more human-readable representation of binary data, with each hex digit representing exactly four binary digits (bits).
How Does Hex Encoding Work?
Hex encoding converts each byte of data into two hexadecimal characters. Since one byte equals 8 bits and can represent 256 different values (0-255), it maps perfectly to two hex digits (16 × 16 = 256). For example, the ASCII character 'A' (decimal 65) becomes '41' in hex, and 'Hello' becomes '48656C6C6F'.
Binary Bridge
Easily convert between human-readable text and machine-level binary representation.
Color Codes
Standard format for web colors (#RRGGBB) using hexadecimal notation.
Memory Addresses
Used to represent memory locations and pointer values in programming.
Data Analysis
Essential for analyzing binary files, network packets, and debugging.
Common Use Cases for Hexadecimal
- Web Development: CSS color codes use hexadecimal notation (#FF0000 for red).
- Programming: Memory addresses, debugging output, and bitwise operations.
- Cryptography: Hash values (MD5, SHA) are typically displayed in hexadecimal.
- Network Analysis: MAC addresses and packet inspection tools use hex representation.
- File Analysis: Hex editors for viewing and modifying binary files at the byte level.
- Embedded Systems: Firmware programming and hardware debugging.
- Data Recovery: Analyzing disk sectors and recovering corrupted data.
Hexadecimal Examples
Text to Hex Example:
Input: Hello World!Output: 48 65 6C 6C 6F 20 57 6F 72 6C 64 21
Color Code Example:
RGB(255, 0, 0) = #FF0000 (Red)RGB(0, 255, 0) = #00FF00 (Green)RGB(0, 0, 255) = #0000FF (Blue)
Binary to Hex Example:
Binary: 01001000Hex: 48Decimal: 72ASCII: H
Frequently Asked Questions
What's the difference between hex and decimal?
Decimal uses base-10 (0-9), while hexadecimal uses base-16 (0-9, A-F). Hex is more compact for representing binary data, as each hex digit represents 4 bits compared to decimal's variable bit representation.
Why do programmers use hexadecimal?
Hexadecimal provides a concise way to represent binary data that's easier to read than long strings of 1s and 0s. It's particularly useful for memory addresses, color codes, and debugging.
How do I convert hex to RGB colors?
Split the 6-digit hex code into three pairs: first two digits for red, middle two for green, last two for blue. Convert each pair from hex to decimal (0-255).
What is a hex dump?
A hex dump displays binary data in hexadecimal format, typically showing the offset, hex values, and ASCII representation side by side for easy analysis.
Technical Specifications
| Specification | Details |
|---|---|
| Base | 16 (Hexadecimal) |
| Digits | 0-9, A-F (case insensitive) |
| Bits per digit | 4 bits |
| Common prefixes | 0x, #, \x |
| Byte representation | 2 hex digits = 1 byte |
Developer Guide
JavaScript
// Text to Hex
const text = "Hello World!";
const hex = Array.from(text)
.map(char => char.charCodeAt(0).toString(16).padStart(2, '0'))
.join('');
console.log(hex); // 48656c6c6f20576f726c6421
// Hex to Text
const hexString = "48656c6c6f20576f726c6421";
const decoded = hexString.match(/.{1,2}/g)
.map(byte => String.fromCharCode(parseInt(byte, 16)))
.join('');
console.log(decoded); // Hello World!
Python
# Text to Hex
text = "Hello World!"
hex_string = text.encode().hex()
print(hex_string) # 48656c6c6f20576f726c6421
# Hex to Text
hex_data = "48656c6c6f20576f726c6421"
decoded = bytes.fromhex(hex_data).decode()
print(decoded) # Hello World!
# With spaces
hex_spaced = ' '.join(hex_string[i:i+2] for i in range(0, len(hex_string), 2))
print(hex_spaced) # 48 65 6c 6c 6f 20 57 6f 72 6c 64 21
PHP
// Text to Hex
$text = "Hello World!";
$hex = bin2hex($text);
echo $hex; // 48656c6c6f20576f726c6421
// Hex to Text
$hexString = "48656c6c6f20576f726c6421";
$decoded = hex2bin($hexString);
echo $decoded; // Hello World!
// With spaces and uppercase
$hexFormatted = strtoupper(implode(' ', str_split($hex, 2)));
echo $hexFormatted; // 48 65 6C 6C 6F 20 57 6F 72 6C 64 21
Hexadecimal Reference
ASCII Table (Common)
| Space | 20 |
| 0-9 | 30-39 |
| A-Z | 41-5A |
| a-z | 61-7A |
| ! | 21 |
| @ | 40 |
| # | 23 |
| $ | 24 |
Hex Digits
| 0-9 | 0-9 |
| 10 | A |
| 11 | B |
| 12 | C |
| 13 | D |
| 14 | E |
| 15 | F |
Common Uses
- Color codes (#FF0000)
- Memory addresses
- Binary data representation
- Cryptographic hashes
- Network protocols