Text to Hex and Back

Every character is stored as one or more bytes. This shows them, two hex digits per byte, and reads hex back into text however it was punctuated.

How it works

Text is turned into bytes with UTF-8, the encoding the web and most files use, and each byte is written as two hex digits from 00 to ff. Plain English letters take one byte each; é takes two, 日 three and 😀 four.

Decoding ignores spaces, line breaks, commas, colons and the 0x or \x prefixes, so you can paste hex straight from a debugger, a C array or a packet capture.

If the bytes do not spell valid UTF-8 text, the tool says so rather than printing garbage. It all runs on this page; nothing is sent anywhere.

How to use it

  1. 1 Pick Encode for text to hex, or Decode for hex to text.
  2. 2 Type or paste into the first box. The result appears as you type.
  3. 3 When encoding, turn Space between bytes off if you need the digits run together.
  4. 4 Copy the result or download it as a .txt file. Swap moves the result back into the first box.

Good to know

  • The number of bytes is the hex length divided by two (or the number of pairs). It is often more than the number of characters.
  • Upper and lower case hex mean the same thing. The encoder writes lower case.
  • If decoding reports an odd number of digits, a digit is missing somewhere: every byte takes exactly two.
  • Hex that came from a file, such as an image header, will not decode to text. That is expected.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

What hex shows you about text that the text itself hides

A computer stores text as numbers, one or more bytes per character, and hexadecimal is the usual way to write those bytes down. A byte holds a number from 0 to 255. In hex, the digits run from 0 to 9 and then a to f for ten to fifteen, so any byte fits in exactly two digits: 0 is 00, 72 is 48 and 255 is ff. That neat fit, two characters per byte, every time, is why programmers read bytes in hex rather than in decimal, where a byte might take one, two or three digits.

Type "Hi" into the box above and you get 48 69. H is character 72, which is 48 in hex, and i is 105, which is 69. For plain English, one character is one byte, because those characters are ASCII, a table from the 1960s that UTF-8 kept for compatibility. Now try "café". The result is 63 61 66 c3 a9: five bytes for four characters. The é is not in ASCII, so UTF-8 writes it as two bytes. The first, c3, starts with the bits 110, which tells a reader that one more byte follows; the second, a9, starts with 10, which marks it as a continuation. Between them they carry the number 233, the code point of é.

That is the useful part of looking at text in hex: it shows things that look identical on screen but are not. A word with é typed as one character (c3 a9) and the same word typed as e followed by a combining accent (65 cc 81) look the same but compare as different strings. A non-breaking space shows up as c2 a0 instead of 20. A file that starts with ef bb bf has a byte order mark that some programs choke on. A curly quote is e2 80 99 where you expected 27. When two strings refuse to match, or a field is longer than it looks, the hex usually tells you why in a second.

Hex arrives in many shapes, depending on where it came from. A debugger prints spaced pairs, C source writes 0x48, 0x69, a Python bytes literal prints \x48\x69, and network tools use colons. The decoder accepts all of them: it ignores spaces, line breaks, commas, colons and semicolons, and drops 0x and \x prefixes before reading the digits. It does insist on two things. Every character left must be a hex digit, and there must be an even number of them, because each byte takes exactly two. When either rule fails, the message says where.

There is a limit worth stating. Not every run of bytes is text. Hex copied out of an image file or a network packet will often contain sequences that are not valid UTF-8, and printing them as characters would only produce a row of question marks. In that case the tool says the bytes are not UTF-8 text rather than guessing. It also does not convert numbers: the number 255 is ff, but the text "255" is three characters, 32 35 35, and this tool works on the text.

Frequently asked questions

Why is "café" five bytes and not four?

Because é is not an ASCII character. In UTF-8, characters beyond plain ASCII take two to four bytes. "caf" is 63 61 66, and é is c3 a9, so the word is five bytes: 63 61 66 c3 a9.

What formats can I paste in to decode?

Plain digits (48656c6c6f), spaced pairs (48 65 6c), 0x-prefixed values with or without commas (0x48, 0x65), \x escapes (\x48\x65), and colon-separated bytes (48:65:6c). Line breaks are ignored too.

Is this the same as converting a number to hex?

No. This converts text: each character becomes the bytes that store it. Converting the number 255 to hex gives ff, but the text "255" is three characters, which are the bytes 32 35 35.

Why does decoding say the bytes are not UTF-8 text?

Not every sequence of bytes is valid UTF-8. Bytes from an image, a compressed file or text saved in an old encoding such as Latin-1 often are not. The tool says so instead of guessing.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.