Hex ↔ Text Converter

Decode hex data to UTF-8 text or encode text to hex. Perfect for decoding Ethereum calldata and logs.

Format: 0x followed by hexadecimal characters (even length)

Understanding Hex and Text Encoding

Hexadecimal encoding is fundamental to Ethereum development. Every piece of data on the blockchain is ultimately stored as hex: calldata, logs, contract storage, and event parameters. Understanding how to convert between hex and human-readable text is essential for debugging and development.

What is Hex Encoding?

Hexadecimal (base-16) uses digits 0-9 and letters a-f to represent data. Each hex pair represents one byte of data.

"H" = 0x48
"e" = 0x65
"l" = 0x6c
"l" = 0x6c
"o" = 0x6f

Why Use Hex in EVM?

  • Compact: Represents binary data efficiently
  • Universal: Standard in blockchain and cryptography
  • Machine-friendly: Easy for computers to process
  • Predictable: Consistent encoding across platforms

Solidity Example

Common patterns for encoding/decoding in smart contracts:

// Encode text to hex (UTF-8 bytes)
string memory text = "Hello";
bytes memory encoded = bytes(text);
// Produces: 0x48656c6c6f

// Decode hex back to text
bytes memory data = hex"48656c6c6f";
string memory decoded = string(data);
// Produces: "Hello"

// Common with function calls
bytes memory calldata = abi.encodeWithSignature(
  "transfer(address,uint256)",
  recipient,
  amount
);

Hex → Text Use Cases

  • Decoding transaction calldata
  • Reading event log data
  • Extracting text from contract storage
  • Debugging token metadata (name, symbol)
  • Analyzing raw contract interactions

Text → Hex Use Cases

  • Encoding function parameters
  • Creating input data for contract calls
  • Constructing transaction calldata
  • Preparing data for hashing
  • Testing Solidity contract behavior

UTF-8 Standard

This tool uses UTF-8 encoding, the universal standard for encoding text. Most characters (ASCII range) are 1 byte, but special characters may use 2-4 bytes. When decoding hex, UTF-8 ensures proper character representation for all supported languages and symbols.

Frequently Asked Questions