Convert & calculate · bytes32

Text & bytes converter

Convert text to hex bytes and back, including fixed-size bytes32 values.

Runs in your browser

What have you got?

Text one way, hex bytes the other. Both convert as you type.

Anything readable: a name, a label, a sentence. Spaces and emoji are fine.

Your text as bytes

Type on the left and the hex bytes, the byte count and the bytes32 form all appear here.

Bytes, hex and bytes32

The three words this tool keeps using, in plain English.

A byte

A number from 0 to 255. Text becomes bytes through UTF-8: “A” is 65, written as 41 in hex.

Hex

Each byte written as exactly two characters, 00 to ff, usually with 0x in front. It is compact and unambiguous, which is why chains use it everywhere.

bytes32

A fixed 32-byte slot in Solidity. Storing text in one is cheap but caps you at 31 bytes, since the value is zero-padded and needs a zero to end on.

About this tool

This converter turns text into hex bytes using UTF-8, and hex bytes back into text, as you type. It also gives Solidity's bytes32 form: the text's bytes padded with zeros on the right to 32 bytes, as ethers.js encodeBytes32String does. Text must fit in 31 bytes so at least one zero byte marks where it ends. Paste a bytes32 value to read the text inside it.

Common questions

How do I convert a string to bytes32?

Type the string in Your text. If it is 31 bytes or fewer, the bytes32 row shows it padded with zeros to 32 bytes, ready to pass to a contract. Longer text needs a bytes or string type instead.

Why do emoji and accented letters take more bytes?

UTF-8 stores plain English letters in one byte each, but accented letters take two or more bytes and most emoji take four. That matters for bytes32, which holds at most 32 bytes.