One byte is two hex digits
Encode text as hexadecimal
Hex is a way to show raw bytes. This page encodes text as UTF-8 first, then prints each byte. Decoding accepts only an even number of digits and rejects bytes that are not UTF-8.
Upper case is a display choice. The bytes do not change if you only change case. Spaces, commas, colons, and a 0x prefix are removed before decoding, so a dump copied from a debugger can be pasted as it is. A lone digit is rejected instead of being padded. This is not a hex editor for arbitrary files, and it will not decode a byte sequence that is invalid UTF-8 into replacement characters.
The text stays in this tab. It is not sent to an encoder on a server.
This tool runs in your browser. Turn on JavaScript to use it.
Two UTF-8 characters, six bytes
Each of these characters uses three bytes. The spaces are only for reading.
- Text
- 你好
- Hex
- e4 bd a0 e5 a5 bd
How to use it
- 1Paste text and encode it.
- 2Or paste hex and decode it back.
- 3Copy the result. Upper case is optional.
Good to know
- UTF-8, not UTF-16 code units.
- An odd number of digits is an error.
- Invalid UTF-8 is rejected rather than shown with replacement characters.
Questions
Why is one character more than two digits?
Two digits are one byte. Characters outside ASCII often need two or three UTF-8 bytes.
Can I paste a 0x prefix?
Yes. 0x, spaces, commas, and colons are ignored while decoding.
Does this accept a file?
No. It converts the text in the box.
Related tools
- Base64 encode and decode
Base64 writes bytes as letters, digits, plus, and slash. It is how a token or a file preview survives a text field. It does not hide the contents from anyone who can read the alphabet.
- Inspect Unicode code points
A character you see may be one code point or several. This page lists the first 80 code points, with U+ notation, decimal, UTF-8 bytes, and a JavaScript escape.
- Hash text or a file
A hash is a fixed-length fingerprint. The same bytes always produce the same digest, and the digest is not a way back to the file. Use it to compare a download or to spot a changed string.