What is a Hex File?
A HEX file is a text file that contains the data for a computer program in hexadecimal form. In a HEX file, each line contains a HEX record. These records consist of hexadecimal encoded numbers corresponding to machine language codes or constant data. The HEX files are commonly used to transfer programs and data to be stored in ROM or EPROM. Most of EPROM programmers or emulators use HEX files.
Hex File Format
An HEX file consists of any number of hexadecimal records. Each record contains 5 fields, which are arranged in the following format:
simplified hex format:
Actual hex file:
Each set of letters or numbers corresponds to a different field. Each field consists of at least two hexadecimal-encoded digits.
“:” is the begins of each HEX record.
“ll” and “10” are the data length field, it represents the number of data bytes (dd) in the record.
“aaaa” and “2462” are the address field, it represents the starting address of the data in the record.
“tt” and “00” are the field representing the HEX record type, it may be one of the following data:
00 – data logging
01 – end-of-file record
02 – Extended Segment Address Record
04 – Extended Linear Address Record
“dd…” and “464C5549442050524F46494C4500464C” are the data field, it represents a byte of data. A record can have many data bytes. The number of data bytes in the record must match the number specified in the data length field (ll).
“cc” and “33” are the checksum field, it represents the checksum of this record. The checksum is calculated by adding the values of all pairs of hex-encoded digits in the record, modulo 256, making the following complements.
How to Open Hex File?
There are a few different ways that you can open a hex file, such as hex editor software and online hex editor. If you have a hex editor installed on your computer, you can simply double-click on the hex file to open it in the editor. Alternatively, you can right-click on the hex file and select “Open With” from the context menu, then choose a hex editor from the list of programs.
1. Windows Notepad
If you don’t have a hex editor installed, you can use the Windows built-in notepad program to open the hex file. It’s the easiest way among all the choices. However, because hex files are not meant to be human-readable, the contents of the file will likely appear to be gibberish.
2. Hex Editor Software
There’re many hex file editor software available, like Notepad++, ImHex, Free Hex Editor Neo, WinHex and more. Everyone has their own features and special fuctions, you can choose one best for yourself.
Acceptable platform: Windows only
Acceptable platform: Windows, MacOS, Linux
ImHex is a powerful hexadecimal editor, which is specially designed for reverse engineers and programming developers.
2.3 Free Hex Editor Neo
Acceptable platform: Windows
HHD Software Ltd has developed Free Hex Editor Neo, a fast binary file editor for the Windows platform. It is available for free and provides all the basic editing functions. Of course, it’s also useful for analyzing your hexadecimal files.
3. Online Hex Editor
If you don’t have an hex editor software on your computer, you can also use online editor as an alternative. Here we recommend an easy to use hex editor online: hexed.it
As you can see, this online hex editor is divided into top, left, center and right areas.
The top toolbar includes functions such as creating new files, opening files and widgets. To open your own hex file, you just need to click “open file” menu on the top dashboard.
On the left, there’re data inspector, which will automatically convert various bases according to the content of the file data selected by your mouse.
The middle area is the file content, and the right area is some attribute information of the file.
Hex File vs Bin File
HEX files and BIN files are two file formats that we often use. The following is a brief introduction to the difference between the two file formats:
- – A hex file is a file that contains data in hexadecimal (base-16) format, while a bin file is a file that contains binary data.
- – Hex files are often used for firmware or other data that needs to be in a human-readable format, while bin files are often used for data that needs to be in a machine-readable format.
- – Hex files are typically larger than bin files, since each byte of data takes up two characters in a hex file (one character for each nibble), while each byte of data only takes up eight bits in a bin file.
Hex File to Binary
A hex file is a file that contains hexadecimal data. Hexadecimal data is a way of representing binary data using the base 16 number system. Each byte of binary data is represented by two hexadecimal digits. For example, the byte value of “11” would be represented as “0x11” in a hex file.
To convert a hex file to binary, you need to first understand how hexadecimal data is represented. Each hexadecimal digit represents four bits of data. The first hexadecimal digit is the most significant digit, and the second hexadecimal digit is the least significant digit. For example, the hexadecimal value “0x11” would be represented as follows in binary:
The most significant digit (1) represents the following binary values:
0 0 0 1
The least significant digit (1) represents the following binary values:
0 0 0 1
Therefore, the hexadecimal value “0x11” would be equivalent to the binary value “00010001”.