Why convert HEX to BIN?
Intel HEX stores compiled firmware as plain-text ASCII records; each byte is encoded as two hex digits wrapped in address and checksum fields. Many firmware flashing tools, bootloaders, and device update utilities expect a flat .bin image instead - for example, STM32 boards accept a .bin file dragged onto their USB drive while the Arduino toolchain outputs .hex. Converting lets you use firmware built by one toolchain with a flasher that expects the other format.
How to convert HEX to BIN
avr-objcopy OPEN-SOURCE
Run avr-objcopy -I ihex -O binary firmware.hex firmware.bin in a terminal. On Linux the generic objcopy from system binutils accepts the same flags without the AVR-specific package.
SRecord OPEN-SOURCE
Run srec_cat firmware.hex -Intel -o firmware.bin -Binary. SRecord handles address gaps in the HEX file by filling them with 0xFF, matching erased flash memory.
About these formats
A .hex file is an Intel HEX file: compiled firmware for a microcontroller such as an Arduino, AVR, or PIC chip, stored as plain-text records. You don't run it on a PC - you flash it to the…
Open .HEX details →A BIN file is most often a raw, sector-by-sector copy of a CD or DVD that ships with a matching .cue text file describing the tracks. Mount it with PowerISO or DAEMON Tools Lite (point them…
Open .BIN details →Quality & what to watch
- The
.binoutput is smaller than the.hexbecause Intel HEX encodes each byte as two ASCII hex digits plus framing overhead. - If the HEX file has address gaps - common when both flash and EEPROM regions are covered - SRecord fills them with
0xFFby default. - avr-objcopy is bundled inside the Arduino IDE on Windows under
hardware/tools; on macOS it is available via Homebrew with the avr-gcc package.
Frequently asked questions
Does converting HEX to BIN lose any data?
Where do I find avr-objcopy on Windows?
hardware/tools directory, or available via the WinAVR package.Can I use this conversion for non-AVR chips?
objcopy from system binutils with the same flags; SRecord is also architecture-agnostic.