UTF-8 / Hex / Bytes Converter
Convert between UTF-8 text, hexadecimal strings, and byte arrays. Essential for encoding and debugging Ethereum data.
Examples
How to Use This UTF-8 / Hex / Bytes Converter
This free online converter translates between UTF-8 text, hexadecimal strings, and byte arrays. It is essential for Ethereum developers working with string encoding, calldata, and on-chain metadata.
- Enter UTF-8 text to see its hexadecimal and byte array representations instantly.
- Paste a hex string (with or without 0x prefix) to decode it back to readable UTF-8 text and its byte values.
- Input byte values as a comma-separated list to convert them to hex and UTF-8.
- Copy any output using the copy button and use it in your smart contracts, scripts, or debugging tools.
All conversions happen locally in your browser. No data is transmitted to any external server, keeping your information private and secure.
Common Use Cases
- Smart contract string encoding — Convert text to hex bytes for passing as calldata or storing in contract storage.
- Event log decoding — Decode hex data from non-indexed event parameters back to human-readable strings.
- NFT metadata — Convert metadata strings to hex for on-chain storage or decode hex metadata back to text.
- Transaction data inspection — Decode raw transaction input data to understand string parameters passed to contracts.
- Debugging encoding issues — Verify that strings are correctly encoded before submitting transactions to avoid failed calls.
Related Tools
Hex / Decimal Converter
Convert between hexadecimal and decimal numbers for block numbers, gas values, and transaction data.
Bytes32 / String Converter
Convert between bytes32 hex values, strings, numbers, and addresses with padding visualization.
Base64 Encoder / Decoder
Encode and decode Base64 strings with support for text and hex input modes.
Frequently Asked Questions
What is UTF-8 encoding and why is it used in Ethereum?
UTF-8 is a variable-width character encoding that can represent every character in the Unicode standard. In Ethereum, UTF-8 is used when converting human-readable strings into bytes for storage in smart contracts, encoding function parameters, or creating metadata. Solidity's string type stores UTF-8 encoded data internally.
How do I convert a string to hex for use in Solidity?
Enter your text in the UTF-8 input field and the tool converts each character to its hexadecimal byte representation. For example, 'hello' becomes 0x68656c6c6f. This hex value can be used directly in Solidity as a bytes literal or passed as calldata to a smart contract function that accepts bytes or string parameters.
What is the difference between hex strings and byte arrays?
A hex string is a text representation of binary data using characters 0-9 and A-F, where each pair represents one byte. A byte array is the actual sequence of byte values (0-255). For example, the hex string '48656C6C6F' and the byte array [72, 101, 108, 108, 111] both represent the same data ('Hello' in ASCII/UTF-8).
How are strings stored on the Ethereum blockchain?
Strings in Solidity are stored as dynamically-sized byte arrays using UTF-8 encoding. In contract storage, short strings (31 bytes or less) are stored in a single storage slot with the length encoded in the lowest-order byte. Longer strings use a separate storage layout with the length in the main slot and data in consecutive slots starting at the keccak256 hash of the slot number.
Can I convert non-ASCII characters to hex?
Yes. This tool supports the full Unicode character set through UTF-8 encoding. Non-ASCII characters like emojis, Chinese characters, or accented letters are encoded as multi-byte sequences. For example, a single emoji can produce 4 bytes of hex data. This is important when calculating gas costs for storing strings on-chain.
Related Tools & Guides
ABI Encoder / Decoder
Encode and decode Ethereum ABI data. Input function signatures and parameters to generate calldata.
Keccak256 Hash Generator
Generate Keccak256 hashes from text input. The hash function used by Ethereum and Solidity.
Hex / Decimal Converter
Convert between hexadecimal and decimal numbers. Useful for Ethereum block numbers, values, and calldata.
Try Also
Calldata Decoder
Decode raw Ethereum calldata hex into human-readable function calls and parameters.
Storage Slot Calculator
Calculate Solidity storage slots for variables, mappings, and nested mappings using keccak256.
Solidity Event Hash Calculator
Calculate keccak256 hashes for Solidity event signatures. Get topic 0 values for filtering Ethereum logs.