Text to Hex
Type text and read its bytes as hex, or paste hex and read the text back. The text is encoded as UTF-8 first, so é is c3 a9, an emoji is f0 9f 98 80, and the byte count beside the result is the real byte count rather than a character count. Hex on the way in is read whatever separates it, spaces, commas, colons, hyphens or 0x prefixes, and hex that is not valid UTF-8 stops with the byte and its position named rather than coming back quietly changed.
Hex ready. 12 bytes from 12 characters. UTF-8, lower case, separated by a space.
12 bytes from 12 characters. UTF-8, lower case, separated by a space.
- 48 65 6c 6c 6f 2c 20 77 6f 72 6c 64
- f0 9f 98 80
- That is 3 hex digits, an odd number. Every byte is two digits, so one digit is missing or one is extra: check the end of what you pasted.
Up to 1,000,000 characters in one pass, converted here in your browser with nothing uploaded. Up to 100,000 characters of what you type is kept in this browser alone so it is still here when you come back, and the Start over button above forgets it.
Common questions
- Why is é two bytes of hex and not one?
- Because the text is encoded as UTF-8, which is what files, web pages, databases and network connections actually hold. In UTF-8 the first 128 characters take one byte each and everything else takes two, three or four, so é is c3 a9. A converter that shows e9 for é is using Latin-1, one byte per character, which is a different thing and will not match the bytes in your file. The byte count next to the result is there so the difference is visible.
- What does "an odd number of hex digits" mean?
- Every byte is exactly two hex digits, so a valid string of hex has an even number of them. An odd count means one digit is missing or one is extra, usually from a copy that clipped the end. Nothing is padded with a zero or trimmed to fit here, because either guess would hand you a byte you never had: the conversion stops and says how many digits it counted.
- Does it accept hex with 0x prefixes, commas or colons?
- Yes. Hex going in can be separated by spaces, commas, colons, semicolons, hyphens, underscores or line breaks, can carry an 0x or a backslash x in front of each byte, and can run together with nothing between the bytes at all. Mixed forms work too. Anything that is not a hex digit or a separator is named with its position instead of being skipped. On the way out you choose the separator and whether the digits are lower case or upper case.
- What happens if the hex is not valid UTF-8?
- It is refused, with the byte, its position and the rule it breaks. A continuation byte with nothing to continue, a sequence that stops in the middle of a character, a value written the long way round, a surrogate half and a value above U+10FFFF each get their own message. Most tools hand back U+FFFD in place of the bad byte, which looks like a successful conversion of text you never had, so this one stops instead.
- What is ASCII only mode for?
- It is the same encoder with a refusal attached, for when you need to know the text is plain. In ASCII only mode any character that would take more than one byte stops the conversion and is named, and any byte above 0x7f in hex you paste is refused the same way. Switch the encoding back to UTF-8 and the same input converts.
- How much can I convert, and does anything leave my computer?
- Up to 1,000,000 characters in one pass, which is the point past which rebuilding the output on every keystroke stops feeling like typing. Past it the input is refused with its own size quoted and nothing is cut off. The conversion is arithmetic that runs in your browser: nothing is uploaded, there is no account, and up to 100,000 characters of what you type is kept in this browser alone so it is still there when you come back. The Start over button forgets it.
Exact byte-for-byte conversion. Text is encoded as UTF-8 before it is shown as hex, so a character outside ASCII becomes more than one byte, and the byte count says so.