Text to Hex and Hex to Text
ED-10Paste text to see its UTF-8 bytes as hexadecimal, or paste hex bytes to read the text. Separators, prefixes and case are your choice.
Runs in your browser. Nothing is uploaded.
Text or hex bytes
Result
How to use it
- Paste your text or hex bytes into the input box.
- Press Text to hex or Hex to text.
- Choose the separator, the 0x prefix and the letter case for the hex output.
- Copy the result or download it as a .txt file.
How the bytes are produced
Text is first converted to UTF-8, then each byte is written as two hex digits. ASCII characters are one byte each, so Hello is 48 65 6c 6c 6f. An accented letter such as é takes two bytes (c3 a9), and most emoji take four. That is why the number of hex pairs can be larger than the number of characters. The tool encodes only text it can represent in UTF-8 and rejects an unpaired surrogate.
What Hex to text accepts
Bytes can be separated by spaces, commas, colons, dashes or line breaks, or run together with no separator, and may carry 0x or \x prefixes. Each byte needs exactly two hex digits, so a token with an odd number of digits is reported with its position. After decoding, the bytes must form valid UTF-8. Data in another encoding, such as Latin-1 or UTF-16, or a binary file, is reported as an error and is not guessed at.
Hex bytes versus hex numbers
This page treats hex as a way to write bytes of text. It does not convert a number such as FF into 255. For converting numbers between bases, including very large ones, use the Number Base Converter on this site. For other encodings of the same bytes, see the Base64 tool.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
"g" at line 1, column 5 is not a hex digit. Hex uses 0 to 9 and a to f. | The input holds a character other than 0 to 9, a to f, A to F or a separator. | Remove or correct the character shown. |
"656" at line 1, column 4 has 3 hex digits. Each byte is two digits, so look for a missing or extra digit. | A group of hex digits has an odd length. | Add the missing digit, for example 0656, or fix the grouping. |
The bytes are not valid UTF-8 text: byte 1 of 2 (0xFF) cannot start or continue a character there. | The bytes decode to no valid UTF-8 text at the byte shown. | Check the source encoding. This tool reads UTF-8 only. |
Questions people ask
How do I convert text to hex?
Paste the text and press Text to hex. Each UTF-8 byte appears as two hex digits. Choose a separator, add 0x prefixes, or switch to uppercase to match what you need.
How do I convert hex to text?
Paste the hex bytes and press Hex to text. Spaces, commas, colons, dashes and 0x or \x prefixes are all accepted. The bytes are read as UTF-8, and an error shows where the text could not be decoded.
Why does one character give several hex bytes?
UTF-8 uses one byte for ASCII, two for letters such as é or ö, three for most Chinese, Japanese and Korean characters, and four for emoji. The hex output shows one pair of digits per byte, not per character.
What does an odd number of hex digits mean?
A byte needs exactly two hex digits, so an odd count means a digit is missing or extra. The error shows the token and its position. Note that a single byte such as 5 must be written 05.
Can I get the output in the format 0x48, 0x65?
Yes. Choose Comma and space as the separator and tick the 0x prefix box. That gives output such as 0x48, 0x65, 0x6c, which is ready to paste into a C or JavaScript array.
Why does Hex to text say the bytes are not valid UTF-8?
The bytes do not form a legal UTF-8 sequence, for example a lone byte above 7F, a truncated character, or data from another encoding or a binary file. The error shows the byte position where decoding failed.
About this tool
Text is converted to its UTF-8 bytes, so ASCII letters are one byte each, accented letters take two and most emoji take four. Hex to text accepts bytes with spaces, commas, colons or dashes between them, or none at all, and with 0x or \x prefixes. Each byte needs exactly two hex digits. The bytes must form valid UTF-8; files in other encodings such as Latin-1 or UTF-16 are reported as errors, not guessed at. This does not convert hex numbers to decimal; the Number Base Converter does that.