Hex Code Decoder
Hex code decoder: paste hexadecimal and read it as text. It accepts 0x, \x, % and spaced bytes, decodes UTF-8, UTF-16 or ASCII, and lists every byte. When a digit is wrong it names the character and its position. Decoding runs in your browser, so nothing you paste is uploaded.
Use this decoder for general hex-to-text decoding in UTF-8 and other encodings; use Hex to ASCII for a strict 7-bit reading with a character table.
Byte table (13 bytes)
| # | Hex | Dec | Binary | Char |
|---|---|---|---|---|
| 1 | 48 | 72 | 01001000 | H |
| 2 | 65 | 101 | 01100101 | e |
| 3 | 6C | 108 | 01101100 | l |
| 4 | 6C | 108 | 01101100 | l |
| 5 | 6F | 111 | 01101111 | o |
| 6 | 2C | 44 | 00101100 | , |
| 7 | 20 | 32 | 00100000 | |
| 8 | 57 | 87 | 01010111 | W |
| 9 | 6F | 111 | 01101111 | o |
| 10 | 72 | 114 | 01110010 | r |
| 11 | 6C | 108 | 01101100 | l |
| 12 | 64 | 100 | 01100100 | d |
| 13 | 21 | 33 | 00100001 | ! |
Hex dump, xxd style (13 bytes)
00000000: 4865 6c6c 6f2c 2057 6f72 6c64 21 Hello, World!
How to decode hex code to text
Hex writes each byte as two digits drawn from 0-9 and A-F. To get text back, split the string into pairs, turn each pair into a number between 0 and 255, and look that number up in a character table. The pair 48 is 4 × 16 + 8 = 72, and 72 is the capital letter H in ASCII. Repeat for every pair and the text appears.
The pairing is why spaces, commas and prefixes do not matter to the result: they only mark where one byte ends. It is also why the length matters. Ten hex digits are five bytes, and a string of eleven digits cannot be split into whole bytes, so one digit has no partner.
Length is easy to predict. The hex string is always twice as long as the data, so 26 digits are 13 bytes. The number of characters is not fixed. In UTF-8 each character takes one to four bytes: 13 bytes can be 13 English letters, or a handful of accented letters and one euro sign. When the character count of the result is smaller than the byte count, multi-byte characters are the usual reason.
The lookup table is where the choice of character encoding comes in. For the letters, digits and punctuation on a US keyboard the common encodings agree, so 48 65 6C 6C 6F reads as Hello in all of them. They disagree for bytes of 80 and above, and that is where most wrong results come from; the encoding section below covers it.
Hex to string, worked through: 48 65 6C 6C 6F
Take the five pairs 48 65 6C 6C 6F. Convert each to decimal (the first digit is multiplied by 16, the second added), then read the character with that code. The table is produced by the same code the decoder uses, and the byte table under the decoder's result lists the same columns for whatever you paste.
| Byte | Hex | Calculation | Decimal | Binary | Character |
|---|---|---|---|---|---|
| 1 | 48 | 4 × 16 + 8 | 72 | 01001000 | H |
| 2 | 65 | 6 × 16 + 5 | 101 | 01100101 | e |
| 3 | 6C | 6 × 16 + 12 | 108 | 01101100 | l |
| 4 | 6C | 6 × 16 + 12 | 108 | 01101100 | l |
| 5 | 6F | 6 × 16 + 15 | 111 | 01101111 | o |
Two details are worth noticing. The two l characters are the same byte, 6C, so repeated letters give repeated pairs. And 65 is lower case e: capital E is 45, a difference of 20 in hex, which is 32 in decimal. The ASCII table lists all 128 values if you want to read a short string by hand.
Hex input formats the decoder accepts
Hex turns up in source code, network captures, databases and URLs, and each place writes it differently. The decoder strips the notation and keeps the digits, so you can paste what you have. A prefix such as 0x or \x starts a new byte group, which means 0x4865 is read as 48 65 and a stray single digit after a prefix is padded with a zero and flagged.
| Notation | Example | Bytes read |
|---|---|---|
| Plain digits | 48656c6c6f | 48 65 6C 6C 6F |
| Spaces | 48 65 6C 6C 6F | 48 65 6C 6C 6F |
| Commas or colons | 48:65:6c:6c:6f | 48 65 6C 6C 6F |
| 0x prefix | 0x48, 0x65, 0x6C, 0x6C, 0x6F | 48 65 6C 6C 6F |
| \x escapes | \x48\x65\x6c\x6c\x6f | 48 65 6C 6C 6F |
| Percent encoding | %48%65%6C%6C%6F | 48 65 6C 6C 6F |
| h suffix | 48h 65h 6Ch 6Ch 6Fh | 48 65 6C 6C 6F |
| Mixed case, line breaks | 48 65 6c ⏎ 6C 6F | 48 65 6C 6C 6F |
Anything else is reported rather than skipped. If a g, a stray quote or a non-breaking space turns up, the message names the character and its position in the input, and the Show button moves the cursor there. Silent skipping is how a corrupted dump decodes into plausible but wrong text, so the decoder does not do it.
Hex from source code: arrays and escapes
Programmers meet hex as an array literal, {0x48, 0x65, 0x6C, 0x6C, 0x6F}, or as an escaped string, "\x48\x65\x6c\x6c\x6f". Both can be pasted with the markers left in: the 0x and \x prefixes start a new byte, and commas and spaces are ignored. Quotes and braces are not hex, so the decoder reports them with their position; delete them and the rest decodes. Octal escapes such as \110, which also spell H, are a different notation and are not read as hex.
Percent-encoded input and URLs
A percent sign followed by two hex digits is how URLs carry bytes that are not allowed in a URL, defined in RFC 3986. The euro sign in UTF-8 is E2 82 AC, so in a URL it appears as %E2%82%AC. Pasting that into the decoder gives back the euro sign, because the percent sign is treated as a byte marker. This works for a run of percent-encoded bytes. A whole address mixes literal letters with escapes, and letters such as a, c and f would be read as hex digits too, so decode only the escaped part and leave the rest.
Which character encoding should you pick?
Bytes are not text until an encoding says which character each byte, or group of bytes, stands for. UTF-8 is the default here because it is what almost every web page, JSON file and modern API uses. Change it when the source says otherwise or when the result contains the wrong accents. The same bytes give different answers; "invalid" in the table means the decoder reports an error because the bytes cannot be read in that encoding:
| Bytes | Written by | UTF-8 | Latin-1 | Windows-1252 |
|---|---|---|---|---|
| 63 61 66 C3 A9 | UTF-8 for café | café | café | café |
| 63 61 66 E9 | Latin-1 or Windows-1252 for café | invalid | café | café |
| E2 82 AC | UTF-8 for € | € | âU+0082¬ | € |
| 80 | Windows-1252 for € | invalid | U+0080 | € |
UTF-8 and multi-byte characters
UTF-8 stores the first 128 Unicode characters in one byte, identical to ASCII, and everything else in two to four bytes. The first byte tells you how long the sequence is: a leading 0 means one byte, 110 means two, 1110 means three and 11110 means four. Every continuation byte starts with 10. The euro sign, code point U+20AC, needs three bytes: E2 82 AC. The format is defined in RFC 3629.
When a UTF-8 sequence is cut short, uses a continuation byte in the wrong place or encodes a value that does not exist, the decoder shows U+FFFD and reports the byte offset. That offset is usually the quickest way to find a truncated copy.
ASCII, Latin-1 and Windows-1252
ASCII covers 00 to 7F. Bytes from 80 to FF belong to one of the older single-byte code pages. ISO 8859-1 (Latin-1) maps each byte to the Unicode code point with the same number, so E9 is é. Windows-1252 agrees with Latin-1 almost everywhere but puts printable characters such as €, curly quotes and the bullet in the range 80 to 9F, where Latin-1 has control codes. If you decode 80 and see a euro sign, the data was Windows-1252; U+0080 means Latin-1. Choosing ASCII makes every byte above 7F an error, which is useful as a check that a payload really is plain ASCII. The ASCII table page shows the 128 to 255 range for both code pages.
UTF-16 and byte order
UTF-16 uses two bytes for most characters and four for the rest. The order of the two bytes matters: the letter H (U+0048) is 48 00 in little-endian and 00 48 in big-endian. Windows APIs and .NET strings in memory are little-endian, many network formats are big-endian. If you decode UTF-16 and get CJK-looking characters, swap the byte order. A byte order mark (FF FE or FE FF) at the start shows up as an invisible U+FEFF character, and a string with an odd number of bytes is reported because UTF-16 needs pairs.
Why decoded hex looks like garbage
Wrong output almost always has one of a handful of causes, and the output itself usually points to which. Characters like é mean UTF-8 bytes were read as Latin-1 or Windows-1252. Boxes or � mean the bytes are not valid in the chosen encoding. Text with a NUL between every letter means UTF-16 was read as a single-byte encoding. Random symbols from end to end suggest the bytes were never text.
| Symptom | Likely cause | What to try |
|---|---|---|
| é or € where accents or € should be | UTF-8 bytes shown as Latin-1 or Windows-1252 | Select UTF-8 |
| � replacement characters | Invalid or truncated UTF-8, or Latin-1 data read as UTF-8 | Read the byte offset in the message; try Windows-1252 |
| A NUL (00) after every letter | UTF-16 LE read as UTF-8 or ASCII | Select UTF-16 LE |
| A NUL before every letter | UTF-16 BE | Select UTF-16 BE |
| Mostly symbols, few letters | Compressed, encrypted or binary data | Check the first bytes against file signatures |
| Error at an odd position in a long string | A non-hex character was pasted, such as an offset column | Use Show, then delete the column |
| Last character cut off | One hex digit lost in copying | Add the missing digit; the message gives the position |
If the first bytes are 89 50 4E 47, 25 50 44 46 2D or 50 4B 03 04, the data is a PNG image, a PDF or a ZIP archive and was never meant to be text. The decoder says so beside the output.
Decoding a hex file or a long hex dump
A hex dump is a formatted view of bytes: an offset column on the left, the bytes in hex in the middle and the printable characters on the right. Pasted as it is, the offset would be read as data and the text column would be full of characters that are not hex digits. Remove the offset and the right-hand column first, or reverse the dump with a tool that understands the layout.
00000000: 4865 6c6c 6f2c 2057 6f72 6c64 210a 5365 Hello, World!.Se
00000010: 636f 6e64 206c 696e 652e 0a cond line..Only the middle part, 4865 6c6c 6f2c 2057 …, is the data. The grouping into four digits does not matter to the decoder. A file that contains hex digits as text, such as a .hex or .txt export, can be opened in an editor and its contents pasted whole, line breaks included. Use the download button to save the decoded text. For large dumps, decode in pieces: most of the time the interesting part is a few hundred bytes.
Is hex encryption? Decoding hex with a key
Hex is a notation. Anyone can turn it back into bytes, and no key is involved, the same way no key is needed to read a number written in decimal. If a string looks like hex and has to be decoded with a key, one of two things is going on: the hex is the output of an encryption or hashing step, so the bytes are ciphertext or a digest and not text, or the key belongs to a separate scheme such as XOR or AES that was applied before the bytes were written as hex.
A 32-digit hex string is often a 16-byte value, such as an MD5 digest or an AES block, and a 64-digit one a SHA-256 digest. Decoding them as text gives noise because they are not text. Reversing a hash is not possible, and decrypting ciphertext needs the key and the algorithm, which this page does not have. If the string was made with a single-byte XOR, decoding it first gives you the bytes to try the key against.
Decode hex in Python, JavaScript and the command line
These are the shortest forms for the same job as the page, a plain hex string to text. Each prints Hello.
bytes.fromhex("48 65 6c 6c 6f").decode("utf-8") # 'Hello'
bytes.fromhex("48656c6c6f").decode("utf-8") # spaces are optionalbytes.fromhex skips ASCII whitespace but does not accept 0x or \x prefixes and raises ValueError at the first invalid digit.
Buffer.from("48656c6c6f", "hex").toString("utf8") // 'Hello'
// Browser, no Buffer:
const bytes = Uint8Array.from("48 65 6C 6C 6F".split(" "), h => parseInt(h, 16));
new TextDecoder("utf-8").decode(bytes) // 'Hello'Buffer.from(…, "hex") stops quietly at the first character that is not a hex digit and returns the bytes read so far, so a typo gives short output with no error.
echo 48656c6c6f | xxd -r -p # Hello
printf '\x48\x65\x6c\x6c\x6f' # Hello[System.Text.Encoding]::UTF8.GetString(
[byte[]]("48 65 6C 6C 6F".Split(" ") | ForEach-Object { [Convert]::ToByte($_, 16) }))When hex is a number or a color, not text
The same digits can mean other things. 1D2A3FB is a number if it came from a memory address or an error code, FF8800 is an orange if it came from a stylesheet, and 89504E47 is the start of a PNG file. Text is only one reading, and pasting a value into the decoder shows the other likely readings under the result, with the converted value, so you can tell which one fits. The page you want depends on the shape of the input:
| Input looks like | Probably | Go to |
|---|---|---|
| Even number of digits, pairs below 80 | Text | This page |
| Short value such as 7FFFFFFF, 3E8 or FF | A number | Hex to decimal |
| Digits that should become 0s and 1s | Binary | Hex to binary |
| 3, 4, 6 or 8 digits, often with # | A color | Hex to RGB |
| Many bases at once, or a number plus text | Conversion | Hex converter |
| Starts with 89 50 4E 47, FF D8 FF, 25 50 44 46 2D | A file | Check the file note under the output |
Questions about decoding hex
Can hex be decoded without a key?
Yes. Hex is only a way of writing bytes with the digits 0-9 and A-F, so there is nothing to open. Whether the bytes then mean text, a number, a color or a file depends on what produced them, and the decoder tries the text reading first.
Why does my hex string have an odd number of digits?
A byte needs two digits, so a valid hex string for bytes has an even length. An odd count usually means a leading zero was dropped (A instead of 0A), a digit was lost when copying, or the string is a number rather than bytes. The decoder reports the position of the digit that has no partner.
What is the difference between hex and Base64?
Both write bytes as printable characters. Hex uses two characters per byte, so the text is twice as long as the data. Base64 uses four characters per three bytes, a third longer than the data, but its alphabet includes lower case, upper case, digits, + and /. Hex is easier to read byte by byte; Base64 is shorter.
How do I decode hex from an image?
A screenshot or photo of hex has to be typed or run through OCR first; this page only reads text you paste. OCR confuses 0 with O, 1 with l and 8 with B, so check the result: any character outside 0-9 and A-F is flagged with its position.
Is the text I paste sent to a server?
No. Decoding runs in your browser with JavaScript that is already on the page, and the input is not part of any request. The input never becomes part of a request.
