Hex Converter

Convert between hexadecimal, plain text, binary sequences, and decimal values. Supports multi-byte UTF-8 strings, arbitrary-precision integers, endianness reversal, and canonical byte dump inspection.

Presets:
Input Type:
Bytes: 13Nibbles: 26Bits: 104UTF-8 Chars: 13
Hex Case:
Prefix:
Separator:
Hexadecimal (Base 16)0x
48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21
Text (UTF-8)String
Hello, World!
Binary (Base 2)0b
01001000 01100101 01101100 01101100 01101111 00101100 00100000 01010111 01101111 01110010 01101100 01100100 00100001
Decimal (Base 10)Bytes
72 101 108 108 111 44 32 87 111 114 108 100 33
ASCII (Character View)0x00–0x7F
Hello, World!
Base64 & OctalMulti-Format
Base64
SGVsbG8sIFdvcmxkIQ==
Octal (Base 8)
110 145 154 154 157 054 040 127 157 162 154 144 041

Quick Controls Reference

Conversion ModeToggle between continuous byte streams, single numeric radix values, or canonical offset views.
Prefix NotationChoose output prefixes including C-style 0x, escape sequence \x, CSS #, or plain hex.
Byte DelimitersFormat byte sequences with spaces, colons, commas, or unspaced continuous character strings.
Endianness OrderingSwitch byte sequence order between Big-Endian (network order) and Little-Endian (processor native).

Byte & Nibble Architecture in Memory (Why Hexadecimal?)

In modern computer architecture, the fundamental addressable storage unit is the 8-bit byte. Inspecting raw bytes in binary (10100101_2) is visually unwieldy and prone to transcription errors, while decimal (165_10) splits byte boundaries unevenly (e.g. 256 rolls over to 3 digits unpredictably).

Hexadecimal solves this because 16 is an exact power of two (2^4 = 16). Every 8-bit byte cleaves cleanly into two 4-bit halves known as nibbles:

FieldHigh Nibble (Bits [7:4])Low Nibble (Bits [3:0])Full 8-Bit Byte
Bitwise Pattern1010010110100101
Bitwise Extraction(byte >> 4) & 0x0Fbyte & 0x0F(high << 4) | low
Hex RepresentationA50xA5 (165)

Because every byte is guaranteed to map to exactly two hexadecimal characters (0x00 to 0xFF), hex strings maintain a strict 2:1 character-to-byte ratio. When parsing raw byte buffers or packet payloads, any odd-length hex input (such as "A" or "1F4") indicates a missing leading zero nibble and must be left-padded ("0A", "01F4") to align with whole byte boundaries.

Character Encoding: US-ASCII vs Multi-Byte UTF-8 Sequences

When text is converted to hexadecimal, the resulting byte sequence depends on the underlying character encoding. Under US-ASCII (ANSI X3.4), characters occupy a single 7-bit byte in the range 0x00 through 0x7F.

Modern applications standardize on UTF-8 (RFC 3629), a variable-length encoding backwards-compatible with ASCII that allocates between 1 and 4 bytes per Unicode code point:

Character CategoryExample GlyphUnicode Code PointUTF-8 Byte Sequence (Hex)Byte Length
Basic Latin (ASCII)AU+0041411 byte
Latin Extended / AccentséU+00E9C3 A92 bytes
CJK Unified Ideographs字U+5B57E5 AD 973 bytes
Emoji & Symbols (SMP)💻U+1F4BBF0 9F 92 BB4 bytes

Multi-byte sequences use structural bit prefixes: 2-byte characters begin with 110xxxxx (0xC0–0xDF), 3-byte characters begin with 1110xxxx (0xE0–0xEF), and 4-byte characters begin with 11110xxx (0xF0–0xF7). All trailing continuation bytes strictly follow the pattern 10xxxxxx (0x80–0xBF).

Common ASCII to Hexadecimal & Binary ReferenceStandard 7-bit ASCII (0x00–0x7F)

Space (SP)0x20
Dec: 3200100000
!0x21
Dec: 3300100001
"0x22
Dec: 3400100010
#0x23
Dec: 3500100011
$0x24
Dec: 3600100100
%0x25
Dec: 3700100101
&0x26
Dec: 3800100110
00x30
Dec: 4800110000
10x31
Dec: 4900110001
90x39
Dec: 5700111001
@0x40
Dec: 6401000000
A0x41
Dec: 6501000001
B0x42
Dec: 6601000010
C0x43
Dec: 6701000011
M0x4D
Dec: 7701001101
Z0x5A
Dec: 9001011010
a0x61
Dec: 9701100001
b0x62
Dec: 9801100010
m0x6D
Dec: 10901101101
z0x7A
Dec: 12201111010
{0x7B
Dec: 12301111011
}0x7D
Dec: 12501111101
~0x7E
Dec: 12601111110
DEL0x7F
Dec: 12701111111

Endianness and Memory Address Ordering

When storing multi-byte integer values in physical computer memory, the sequence in which individual bytes are arranged is defined by endianness. For example, consider the 32-bit integer 0x12345678, where 0x12 represents the Most Significant Byte (MSB) and 0x78 represents the Least Significant Byte (LSB):

Memory OffsetBase Address + 0Base Address + 1Base Address + 2Base Address + 3Primary Applications
Big-Endian (MSB First)12345678Internet Protocol (IP) network headers, JVM bytecode, Motorola architectures
Little-Endian (LSB First)78563412x86, x86-64, ARM processors (operating in default mode), RISC-V

Understanding endianness is critical when parsing binary streams across networks: socket communication uses Network Byte Order (Big-Endian), requiring conversion via functions such as ntohl() or htonl() on Little-Endian host systems.

Hexadecimal Notations, Prefixes, and Formatting Standards

Programming languages, networking standards, and markup specifications utilize standardized prefixes and delimiters to distinguish hexadecimal values from decimal integers:

Notation FormatSyntax PatternExampleStandard Scope & Environments
C-Style Literal0x[0-9A-Fa-f]+0x7F, 0xDEADBEEFC, C++, Java, JavaScript, Python, Rust, Go, Swift
String Byte Escape\x[0-9A-Fa-f]{2}\x1B\x5B\x32\x4ARegular expressions, C-string byte literals, shell escape sequences
CSS Color Code#[0-9A-Fa-f]{3,6,8}#3B82F6, #10B98180CSS Color Module Level 3/4, SVG, graphics software palettes
HTML / XML Entity&#x[0-9A-Fa-f]+;&#x2603; (☃)HTML5 numeric character references, XML entity declarations
Assembly Suffix[0-9][0-9A-Fa-f]*h0FFh, 1000hIntel x86 assembly syntax (NASM, MASM)

Bitmasking & Byte Manipulation Cheat Sheet

Systems engineers and protocol implementers use hexadecimal literals for bitwise masks because powers of two and bit groupings align predictably with 4-bit hex boundaries:

OperationHex Mask / ExpressionBitwise TargetReal-World Engineering Usage
Byte Isolationval & 0xFFBits [7:0]Truncate 32/64-bit integer to unsigned 8-bit byte; isolate LSB
16-Bit Word Isolationval & 0xFFFFBits [15:0]TCP/UDP port number extraction, UTF-16 code unit masking
High Nibble Extraction(byte >> 4) & 0x0FBits [7:4]Unpack IP version in IPv4 header (first nibble of byte 0 is 0x4)
Low Nibble Extractionbyte & 0x0FBits [3:0]Extract Internet Header Length (IHL) in 32-bit words from IPv4 byte 0
Color Channel Extraction(rgba >> 16) & 0xFFBits [23:16]Extract Green channel from 32-bit RGBA integer (0xRRGGBBAA)
Cache Line Alignment(addr & 0x3F) == 0Bits [5:0] == 0Verify whether memory pointer is aligned to a 64-byte hardware cache line

Canonical Hex Dump Architecture (hexdump -C / xxd)

Software engineers and security analysts use canonical hex dumps to examine raw binary structures without executing or decoding the file blindly. The canonical format divides each 16-byte row into three coordinated sections:

00000000 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 0d 0a 00 |Hello, World!...|
00000010 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
↑           ↑                        ↑                        ↑
Offset    First 8 Hex Bytes        Second 8 Hex Bytes        ASCII Gutter
1. Byte Offset ColumnAn 8-digit hexadecimal memory address indicating the byte index relative to the file origin (0x00000000).
2. Two 8-Byte Blocks16 bytes partitioned into two 8-byte halves separated by double spacing for rapid visual column scanning.
3. Printable ASCII GutterPrintable characters (0x20–0x7E) rendered directly; non-printable bytes replaced with dots (.).

Binary File Signatures (Magic Bytes) Reference

Operating systems, virus scanners, and binary inspectors identify file types by verifying fixed byte sequences located at specific offsets (usually offset 0x00) rather than relying on unreliable file extensions:

File FormatStarting Magic Bytes (Hexadecimal)ASCII EquivalentFormat Specification
PNG Image89 50 4E 47 0D 0A 1A 0A. P N G \r \n \x1A \nPortable Network Graphics (RFC 2083)
JPEG / JFIF ImageFF D8 FF\xFF \xD8 \xFFStart of Image (SOI) Marker (ISO 10918)
GIF Image47 49 46 38 39 61G I F 8 9 aGraphics Interchange Format 89a
PDF Document25 50 44 46% P D FAdobe Portable Document Format (ISO 32000)
ZIP Archive / DOCX / JAR50 4B 03 04P K \x03 \x04PKZIP Local File Header
ELF Executable7F 45 4C 46\x7F E L FLinux Executable and Linkable Format
Windows PE Executable4D 5AM ZDOS MZ Header / Portable Executable (EXE, DLL)

Programmatic Hex Conversion Reference Across Languages

The standard library patterns below demonstrate how to perform hexadecimal encoding and decoding across production runtime environments:

TypeScript & Node.js (Buffer / Uint8Array)
// String to Hexadecimal
const hexString = Buffer.from('Hello, World', 'utf-8').toString('hex');
// Result: "48656c6c6f2c20576f726c64"

// Hexadecimal back to UTF-8 String
const utf8Text = Buffer.from(hexString, 'hex').toString('utf-8');

// Numeric integer to Hex with BigInt support
const hexNum = (3735928559n).toString(16).toUpperCase(); // "DEADBEEF"
const parsedInt = BigInt('0x' + hexNum); // 3735928559n
Python 3 (Built-in bytes & binascii)
# String to Hexadecimal bytes
raw_bytes = "Hello, World".encode("utf-8")
hex_repr = raw_bytes.hex()  # '48656c6c6f2c20576f726c64'

# Hexadecimal to decoded String
decoded = bytes.fromhex(hex_repr).decode("utf-8")

# Integer to Hex and reverse
num_hex = hex(3735928559)  # '0xdeadbeef'
original_num = int("0xdeadbeef", 16)  # 3735928559
Go (encoding/hex package)
package main

import (
    "encoding/hex"
    "fmt"
)

func main() {
    data := []byte("Hello, World")

    // Encode byte slice to hex string
    hexEncoded := hex.EncodeToString(data)
    fmt.Println("Hex:", hexEncoded)

    // Decode hex string back to byte slice
    decodedBytes, err := hex.DecodeString(hexEncoded)
    if err == nil {
        fmt.Println("Decoded:", string(decodedBytes))
    }
}
Unix / Linux CLI (hexdump & xxd)
# Display canonical hex dump of a binary file
hexdump -C archive.tar.gz | head -n 5

# Reversible hex dump using xxd
xxd binary_payload.bin payload.hex

# Reconstruct binary file from hex dump
xxd -r payload.hex reconstructed.bin

Frequently Asked Questions

Why do hexadecimal representations always display bytes as pairs of two characters?

In modern computer architecture, the foundational unit of addressable memory is the 8-bit byte. One hexadecimal digit represents exactly 4 bits (a nibble), covering values from 0 (0000) to 15 (1111 or 0xF). Consequently, two hexadecimal digits represent exactly 2 × 4 = 8 bits, spanning the range 0x00 (0) through 0xFF (255). A single unpaired hex digit would represent only half a byte, so byte streams are canonically represented in even pairs.

How does hexadecimal handle signed negative numbers in computer memory?

Computers represent signed integers using two's complement binary notation rather than negative signs in memory. For instance, in an 8-bit signed integer, 0xFF represents -1, 0x80 represents -128, and 0x7F represents +127. When converting hex numbers to decimal values, you must define the target word size (such as 8, 16, 32, or 64 bits) to determine whether the most significant bit functions as a sign bit or as standard unsigned magnitude.

What is the difference between a hex-encoded string and raw binary data?

A raw binary byte consumes 8 bits (1 byte) in storage and memory. When converted into a printable hexadecimal string (such as "FF"), each character is stored as an ASCII character taking 1 byte each ("F" is 0x46, "F" is 0x46), resulting in 2 bytes of storage. Hex encoding provides a human-readable representation of raw bytes for debugging, serialization, and text-based network protocols at the cost of doubling storage requirements.

How does UTF-8 multi-byte character encoding map to hexadecimal bytes?

Standard ASCII characters (code points U+0000 to U+007F) map directly to single bytes from 0x00 to 0x7F. Unicode characters beyond ASCII require between 2 and 4 bytes in UTF-8. The first byte (lead byte) indicates the total sequence length (e.g. 0xC0–0xDF for 2 bytes, 0xE0–0xEF for 3 bytes, 0xF0–0xF7 for 4 bytes), followed by continuation bytes in the range 0x80–0xBF. For example, the character "€" (U+20AC) encodes to the three hex bytes E2 82 AC.

When should Big-Endian vs Little-Endian byte order be applied?

Big-Endian stores the most significant byte (MSB) at the lowest memory address, which matches natural left-to-right human numerical reading and standard TCP/IP network protocol headers (Network Byte Order). Little-Endian stores the least significant byte (LSB) first at the lowest address, which is the native architecture of x86, x64, and most ARM processors. When inspecting raw memory dumps or binary protocol payloads, selecting the matching endianness prevents reversed numeric calculations.

Why do CSS color hex codes use 3, 6, or 8 characters?

CSS hex colors map directly to color channels in the sRGB color space. A 6-digit code (#RRGGBB) allocates two hex digits (00–FF or 0–255) to Red, Green, and Blue. An 8-digit code (#RRGGBBAA) appends a two-digit Alpha channel for opacity. The 3-digit (#RGB) and 4-digit (#RGBA) shorthand forms expand each character into a duplicate pair (#F5A expands to #FF55AA), providing a concise format for uniform channel values.

How does a canonical hex dump differ from continuous hex strings?

Continuous hex strings concatenate byte values without spatial context. A canonical hex dump (such as the output of `hexdump -C` or `xxd`) organizes data into three distinct columns: an 8-digit byte offset address on the left, 16 hexadecimal bytes grouped into two 8-byte blocks in the center, and a 16-character ASCII preview on the right where non-printable control characters are replaced with dots (.). This allows developers to correlate byte positions with human-readable text.

What occurs when an input hex string contains odd lengths or invalid characters?

In strict byte-stream parsing, an odd-length hex string cannot map cleanly to full 8-bit octets because the final nibble lacks a corresponding pair. Robust parsers handle this by either prepending a leading zero (e.g. "A" becomes "0A") or signaling a format error. Characters outside the hexadecimal alphabet [0–9a-fA-F] are filtered out or treated as delimiters (such as spaces, colons, or commas) depending on parser settings.