Skip to content

Hex, ASCII and hex dumps: reading the bytes behind a text file

Blog / Published 

Hexadecimal is a base-16 way of writing bytes. Each byte is two digits from 0 to 9 and A to F, so the value 255 becomes FF. Programmers use it because one byte always fits in exactly two characters, which makes binary data readable on a screen and easy to compare in a debugger.

Hex and ASCII for the same text

The letter A is code 65 in ASCII, which is 41 in hexadecimal. The lowercase a is 61, the digit 0 is 30, and a space is 20. A line break is 0A. So the word Hi is the two bytes 48 69 in hex. If you know the ASCII table, you can read short hex strings by eye, and the hex to text converter does the same lookup for longer ones.

Reading a hex dump

A hex dump shows a file in rows. The left column is the offset, the position in the file counted in bytes and written in hex. The middle columns hold the bytes of that row, usually sixteen per line. The right column shows the same bytes as characters, with a dot for anything that cannot be printed. Tools such as xxd print it this way, and the hex dump tool produces the same layout in your browser.

A dump is the fastest way to answer a question like "why does this file not open?". The first few bytes often identify the format. A PNG starts with the bytes 89 50 4E 47, and a PDF starts with the ASCII text %PDF. If the expected bytes are missing, the file is probably not the type its name claims.

Where UTF-8 changes the count

A character is not always one byte. Plain ASCII characters take one byte each, but an accented letter such as é takes two in UTF-8, written C3 A9. That is why a string can look short on screen and still be longer in a hex dump, and why a length check that counts bytes gives a different answer from one that counts characters.

Converting in both directions

The hex converter turns text into hex and back, and it runs entirely in your browser, so a hex string copied from a log or a firmware image is never uploaded. Check the output against the table above before you trust it for anything important, especially when the input contains spaces or a missing digit.

Common mistakes

Written by Ján Turský

Creator of TextArray — building free, privacy-first tools that run entirely in your browser.