Introduction
Intel HEX is a text format for binary data that is to be written into memory, most often the firmware for a microcontroller. Each line is one record: a run of bytes, written as hexadecimal digits, with the address they belong at and a checksum. Because it is plain text with addresses, a HEX file can describe memory with gaps in it and survive being sent over links that only carry text.
Toolchains for AVR, PIC, ARM Cortex-M and many other chips produce it. The SDCC
compiler names its output .ihx. Motorola’s
S-record format does the same job.
Structure
Every record is one line that starts with a colon. After it come pairs of hexadecimal digits: the number of data bytes, a 16-bit address, the record type, the data bytes and a checksum. The checksum is chosen so that all the bytes of the record, added together, come to zero in their lowest eight bits.
Six record types exist. Type 00 is data and 01 marks the end
of the file. Because a record address is only 16 bits, types 02 and
04 set an upper part that applies to the records after them, giving 20-bit
or 32-bit addresses. Types 03 and 05 give the start address.
Every field, the address rules and worked examples of each record type are on the
records page. The start records are optional, and
the address records may appear anywhere in the file.
:10010000214601360121470136007EFE09D2190140
:100110002146017E17C20001FF5F16002148011928
:00000001FF
0start code:1 character1byte count, the number of data bytes2 digits3address4 digits7record type: 00 data, 01 end, 02 to 05 addresses2 digits9data2 digits per byte…checksum2 digits
Not described
The records page follows Intel’s own specification (Revision A, 1988), which was read in full.
The viewer
The explorer opens a HEX file as a tree of records (byte count, address, type, data, checksum, line ending), checks every record, builds the memory image the records describe and, when you choose a processor, disassembles it. It reports, without refusing the file: a wrong checksum, a character that is not a hexadecimal digit, a record shorter or longer than its byte count says, a wrong length for the record type, an unknown record type (naming the vendor types 06, 0A–0E and 81–88), a non-zero load offset in the end-of-file record (shown as the old-style start address), data after the end-of-file record, a missing end-of-file record (noting a closing zero-length data record), mixed line endings, a byte order mark, blank lines and text that is not a record, spaces around a record, data that runs past the end of its 64 KiB address range or past 0xFFFFFFFF (wrapped to 0), a non-zero load offset in a record of type 02 to 05 (Intel says 0000; ignored), files that have both 02 and 04 records (with the option Base records: add, as both objcopy tools, or SRecord reading, which also wraps a record at the end of a segment, ignores what follows the end-of-file record and takes the end-of-file load offset as a start address only in the 8-bit mode, and a summary row that says whether it matters for this file), bytes written twice (with the same value or another) and gaps between regions. It understands the extended segment (02) and extended linear (04) address records and the two start address records (03, 05), accepts all six types in any file (Intel allows 02 and 03 in 16-bit and 32-bit files), shows a start record without calling it a problem, and does not need one.
Microchip PIC files (INHX8M and INHX32) are Intel HEX with each word stored low byte first and every address doubled; the options bar choice Addresses and words: PIC words reads them that way (word addresses, words high byte first, INHX32 told from INHX8M by its type 04 records). Types 02, 03 and 05, odd byte counts and odd addresses are reported there. No PIC processor is disassembled.
The file does not say which processor the code is for, so the options bar asks: none (the bytes, sixteen to a row; the default), AVR (the Arduino case; the addresses in a HEX file are byte addresses; see the AVR pages), MSP430 / MSP430X (the MSP430 pages) or any other processor of the general CPU registry, the same list the Motorola S-record viewer and Read as raw machine code offer (25 processors in all: x86, ARM and Thumb, AArch64, RISC-V, MIPS, PowerPC, SuperH, 68000, Z80 and relatives, 6502 family, 65816, HuC6280, 6800 and 6809, TLCS-900, CDP1802, F8, TMS9900, CP1610, 2650, V810, PDP-11, Xtensa) with its variant, byte order and own options. Each region is disassembled when you open it, and its bytes are read from the image when needed; the start address of a type 05 record is the entry point of the region that holds it. The PIC processors are not in the registry, so a PIC file (INHX8M, INHX32) is read as words but not disassembled.
Checked against llvm-objcopy -I ihex -O binary byte for byte on five real files (four Arduboy games and a micro:bit firmware, 281,042 image bytes together, plus four files built with clang for the AVR and MSP430), against both llvm-objcopy and GNU objcopy on 50 generated files (random data; chunks of 1 to 255 bytes; CRLF, LF and lower case; 64 KiB and 196 KiB images; overlaps, gaps, segment records, start records, with and without an end-of-file record: 40 give identical images; the five with a zero-length data record are refused by llvm-objcopy only; the five that cross 0xFFFFFFFF are wrapped by the explorer and not by the tools), and, for the four Arduboy games, against the flash image the Arduboy emulator’s own HEX loader makes.
Known, not yet covered
- Reference: the records page was checked line by line against the extracted text of Intel’s Revision A (all 11 pages, third check, 14 November 2026). Every record rule on it agrees; the points that are not in Intel’s document (digit case, line endings, end-of-file last and once, the I8HEX/I16HEX/I32HEX names, the history) are marked as conventions and rest on Wikipedia, which was re-read from its wikitext, on the SRecord manuals, and on the GNU binutils
bfd/ihex.cand SRecordintel.ccsource code. On 19 November 2026 six of its pages were also rendered and compared with the extraction (they agree). The third check also added: the end-of-file load offset as the old start address, reading stopping at the first end-of-file record, the zero-length data record some CP/M assemblers write, how binutils and SRecord behave, and the record types other vendors use (06, 0A–0E, 81–88). - Reference: Microchip’s INHX8M and INHX32 are described on the records page from Lucid Technologies’ two pages (third-party, cited by Wikipedia), checked against Microchip’s MPLAB XC16 Assembler, Linker and Utilities User’s Guide (DS50002106D, p. 240) and the AS assembler manual. Microchip’s manual does not use the names INHX8M or INHX32 and does not say which form a tool writes by default, so that INHX32 is the default output of MPLAB is not stated anywhere we read. Its worked example also carries a checksum (
96) that by our arithmetic should be94. - Reference (vendor variants): (changed 19 November 2026, hex9) Microchip’s own documents now describe INHX8S (the split pair .HXL and .HXH, addresses halved; MPASM User’s Guide DS33014F, Appendix A) and INHX16 (types 0 to 3, 20-bit addresses; MPLAB XC8 User’s Guide, Hexmate): see the records page. What is still not described from a primary document: INHX16M’s byte order (AS manual and Wikipedia only; Microchip’s text does not give it), why the MPASM guide lists a type 02 for INHX32 where the later documents list 04 and 05 (reported, not explained), and the Texas Instruments variant (addresses counted in register widths), the Zilog and c’t variants and the other start codes, which are only named, by Wikipedia: no vendor document for them was found in searches on 19 and 25 November 2026 (Microchip, bitsavers, archive.org, TI). Changed 25 November 2026 (hex10): the Mostek format (BYTE, July 1977, from Mostek’s own text) and the TDL relocatable format (BYTE, November 1977; Nascom Journal, June 1981) are now described from those documents on the records page; they are not Intel HEX variants in the sense of the other lines (Mostek’s data and end-of-file records are Intel’s, with extra
$records; TDL’s are a different,;-led format), and nothing in the viewer reads them. The records page does not describe the vendor types beyond the one-line meanings Wikipedia gives. Not Intel’s format. - Reference: Intel’s text does not say what a reader must do with an unknown record type, a record with the wrong length for its type, or a bad checksum; the page gives what the explorer does and, as separate tables, what binutils (in its two stages, recognising the file and then reading it), SRecord (starting mode, splitting, offsets, empty and missing records, line ends) and llvm-objcopy (line splitting, exact lengths, zero-length data, types 03 and 05) do, and what both objcopy tools write, from their source code; we read it and did not run SRecord (the two objcopy tools were run on the generated files). The llvm source read is the
mainbranch of 19 November 2026, the llvm-objcopy run is 22.1.8. SRecord has never been run (not installed; no third-party build): instead 35 cases were derived by hand from its savedintel.ccand the explorer’s “SRecord reading” option is asserted against them (test-hex-srecord-reading); that test is only as good as our reading of the source. Five more readers (avr8js, avrdude, OpenOCD, stm32flash, IntelHex) were read from their raw source files and compared in a table on the records page (none run); esptool was examined in hex10 (25 November 2026): it only writes HEX files, through python-intelhex, and reads none (records page, “Five more readers”). The attempt to download SRecord’s source for a real run was refused by the permission system on 25 November 2026 and was not repeated; SRecord remains unrun. Other readers (vendor programmers such as MPLAB IPE and PICkit, IDEs, STM32CubeProgrammer, Keil, IAR, MikroC and the like) were not examined: their source is not public, and what they do with a bad file is known to us only if someone has documented it. - Viewer: the Memory regions list (with the gap before each region) is a plain table up to 2000 regions and a paged list of all of them above that; data that crosses the end of a 64 KiB address range is continued into the next range (and reported), as the objcopy tools do, where the specification’s wrap-around inside a segment is not modelled; a segment-mode file is not wrapped at 1 MB. Only the top of the 32-bit space follows Intel (wrap to 0, reported); the objcopy tools do not wrap there.
- Reference and viewer: Intel does not say how a type 02 and a type 04 record combine in one file; the page gives our reading (both stay in force and are added), the three programs’ answers (GNU objcopy and llvm-objcopy add, SRecord replaces) and the viewer has an option for both. Our reading of Intel's silence is not a rule of the specification.
- Reference: (fixes of 19 November 2026, after re-check 5) added to the records page: Intel’s note (page 9) that code starting in the real mode of the 80386 should use the start segment record (03) and not 05; what the GNU writer does with addresses that do not fit 32 bits and in the segment form (
ihex.c779-790, 805-852), and the llvm writer’s own condition, base-record choice and 32-bit checks (ELFObject.cpp355-368, 2775-2790, 2823-2842); llvm’s exact trim set; the line numbers inintel.cc(the count is on 388, the empty-record warning on 389-392) andihex.c(the writer comment is on 822-827). Wikipedia’s wikitext, Lucid’s two pages and Microchip’s text were re-read against the pages: one difference found (Wikipedia spells INHX8S “INTHX8S”), noted on the records page. Re-read again on 19 November 2026 (hex8): Wikipedia’s wikitext, Lucid’s two pages (Wayback copies of 28 February 2020), Microchip DS50002106D section 15.3.3 (page 240; the example line:040200003322110096and its wrong checksum included) and the AS manual section 6.3: every statement of the records page about them agrees (the INHX8S spelling is the one difference already noted).ELFObject.cppwas fetched again (identical to the saved copy) andELFObject.hwas fetched and read:class IHexWriter : public ASCIIHexWriter(lines 395-399), so the Intel HEX writer does useASCIIHexWriter::finalizeandcheckSectionwith their 32-bit checks, which is what llvm-objcopy 22.1.8 showed when it was run. - Viewer: size (changed 19 November 2026): a file of 2,000,000 records (90 MB, 32,000,000 bytes of image) now takes about 0.8 s and 330 MB in Node (the test process, which holds the file twice) (it took 8.4 s and about 3.4 GB; llvm-objcopy 0.6 s and 195 MB, GNU objcopy 1.5 s and 44 MB). The viewer keeps typed arrays, not a node, object or string per record. The memory image is a hash table of 16-byte blocks with no limit on the number of blocks (a file may touch all 1,048,576 pages of 4 KiB that 4 billion addresses hold, and the memory it uses follows what the file writes, not the range of addresses it writes in; for the memory a hostile file costs see the “Memory, measured” note below: it is NOT “about 3 bytes for each character”, which an earlier version of this page said and which was false); the regions, and the problems (each is a line number, a message code and two numbers) have no limit either: every region has a row in the byte listing and in the paged Memory regions list, every problem is in the paged Problems list and on its record. Two limits remain, and when a file reaches one the viewer says so in a “Not read” row and in the Problems list: a file over 256 MiB is not read at all (the explorer’s own limit on a decoded file,
MAX_DECODEDinengine/levels.js, shared by all viewers; not set here); and at most 5,000 regions are disassembled when a processor is chosen (the others are not disassembled, and are listed as bytes in a Memory image section after the code). Not covered: a file over 256 MiB is not shown at all, and there is no way to raise a limit from the options bar. Measured 19 November 2026 after the limits were removed (Node 26, this Mac): the 2,000,000-record file 0.8 s and 405 MB peak (the test process, which also holds the 90 MB file; 328 MB after the memory reduction of hex8); 1,048,576 pages touched (one byte each) 0.9 s; 1,000,100 problems 0.2 s. - Viewer: processors (changed 19 November 2026, hex9): all 25 processors of the general CPU registry are offered, besides AVR and MSP430 with their own options (the old note that only those two were disassembled and ARM was not is gone).
parser-test/test-hex-cpu.mjsbuilds a HEX image of two regions for every processor, variant and byte order it offers (147 programs) and checks that each region’s rows equal the registry layout’s on the same bytes and that the first instructions are what the encodings mean (1,237 checks). Still not covered: the PIC processors (hex10: the decoders for the 12-bit, 14-bit, enhanced 14-bit and PIC18 words, with and without the extended set, are written and tested inexplorer/cpu/pic, but they are not in the general registry yet, which is not ours to edit, so the options bar does not offer them and PIC files are still shown as words only); a file that mixes processors or ARM and Thumb code is disassembled as the one processor and variant chosen (there is no mapping symbol in a HEX file to switch on); at most 5,000 regions are disassembled (stated, the rest listed as bytes). The disassembly view has its own “Go to address” box. - Viewer: Motorola S-record files (.srec, .s19) are read by their own viewer (see its page), not this one; a file named .hex that holds S-records is sent there by its content.
- Reference: (corrected 19 November 2026, after re-check 6) the records page said the second GNU writer check (“address 0x… out of range”,
ihex.c838-847) cannot fire after the masking at line 790. It can, and the page now says so as observed with the command and the message (GNU objcopy 2.47: a 32-byte section at 0xFFFFFFF0 or 0xFFFFFFF8 stops with “address 0x100000000 out of range for Intel Hex file”; one that ends at 0xFFFFFFFF is written). llvm-objcopy 22.1.8 was run on the same files: it refuses sections past 32 bits (“section ‘.data’ address range [0x…, 0x…] is not 32 bit”) and a start address above 32 bits (“entry point address … overflows 32 bits”), and accepts sign-extended addresses; the page says so.ELFObject.hwas read afterwards (hex8, see above); SRecord was not run. - Viewer: (changed 19 November 2026, after re-check 6) the three caps the re-check found (32,768 image pages, 100,000 regions, 1,000,000 problems) are removed: see the size note above. What still holds the viewer back from
full: the explorer-wide 256 MiB limit on a decoded file (a larger file is not read, with a notice; not ours to change), the disassembly limit of 5,000 regions (stated, the rest listed as bytes), the PIC processors not disassembled (hex9: every processor of the registry now is; hex10: the PIC decoders exist but are not registered yet, and a mixed file is read as the one processor chosen), and S-records read by a separate viewer. The paged Memory regions list (above 2000 regions) was seen in a browser by re-check 7 (all 150,000 regions listed, 200 to a page); it has Previous and Next only, no “Go to region #” control, because the shared rows component (components/table.js) has none and is not ours to change. - Reference: (re-check 7) the records page says that at
--change-addresses 0xFFFFFFE0GNU objcopy writes a start record:04000005FFFFFFE0“that GNU adds”. The record is real, but the cause was wrong:--change-addressesalso shifts the start address by the same amount (objcopy.c5744-5745 and 2817), so the input’s start address 0 becomes0xFFFFFFE0; with--change-section-address .data=0xFFFFFFE0there is no start record. The llvm-objcopy comparison used a different option set. Fixed (hex8):scripts/hex/objcopy-4g-cross.mjsnow runs both tools with the same option sets (section address only; section address and--change-start; GNU--change-addresses), and the records page has a table that names the option set of every row and says why the start record appears. With the same options the two tools write the same file for a section that ends at 0xFFFFFFFF, with or without the start record. - Viewer: Memory, measured (hex8, 19 November 2026, Node 26, this Mac; replaces the false “about 3 bytes of memory for each character” that re-check 7 found). The memory is not bounded by a small multiple of the file; it is bounded only by the 256 MiB limit, at several times the file. CHANGED in hex9 (19 November 2026): the memory of a hostile file is now bounded at about 3.6 bytes for each character (it was about 9). The cause was the line table: every line cost 18 bytes (its start, kind, flags, type, count, address, checksums, the address in the image) and every problem on a line 9 more. Now a line costs 0.25 bytes: only where every 64th line starts is kept, with the number of problems before it and the address base in force; a line, its fields, its own problems (digits, count, checksum, type, spaces: all worked out from the line alone) and the address of a data record are worked out from the bytes when asked for, in a window of at most 64 lines, and only the problems that depend on earlier lines (after the end-of-file record, a second one, a record that crosses 64 KiB or 4 GiB, overlaps, the PIC checks) are stored, 9 bytes each. In addition the image keeps no hash table while the blocks arrive in ascending order (a binary search over them), and the region lists are made at their exact size. Measured on this Mac (Node 26,
/usr/bin/time -landprocess.resourceUsagein a child process, the parse alone without the file, which the browser also holds): (1) 100.4 MB, 7,100,000 one-byte records, each in a block of its own, ascending: 7.5 s, 2.84 bytes per character (was 4.8); (2) 102 MB, 3,400,000 such records scrambled, each with its own type 04 record: 6.4 s, 1.77 (was 2.9); (3) 99.5 MB, 7,100,000 one-byte records in 64 KiB windows, each window in descending order of address (14 characters a record, so the hash table and the sorting are paid for without the 30 characters of case 2): 9.9 s, 3.55 bytes per character, the highest found; (4) 50 MB of 25,000,000 lines that are not records: 0.8 s, 0.3 to 0.6 (was 8.8); (5) 25 MB of 25,000,000 blank lines: 0.5 s, about 1.1 (the process’s own memory over 27 MB, in whole megabytes; the viewer keeps 1.5 MB for it). The honest worst case: about 3.6 bytes of memory for each character, so at the 256 MiB limit about 0.95 GB for the reading plus the 0.27 GB file (this is arithmetic, not a run: no 256 MiB file was built). The target of at most 3 bytes was not reached for case 3: a block costs 22 bytes, its place in the hash table about 7, its place in the sorted order 4 and its region 8. It is still a bound set only by the explorer’s 256 MiB limit; a file the browser cannot hold may fail with the browser’s own memory error. The test (test-hex-big, section D) makes the hostile files in the temporary directory, measures them in a child process, deletes them, and asserts a per-character bound for each (3.3, 2.1, 4.0, 1.2 and 2.0), andtest-hex-sparsechecks the sparse line table against a file built from a plan (30,000 lines, every problem, every node, every address across all windows, every byte offset). The Memory regions rows cannot be selected to highlight bytes (no such feature); the jump controls are described in the next item. - Viewer: (re-check 8, browser, 19 November 2026) the tree (the Structure tab) of a file of 150,075 records opens with its first 200 records and a button “Show the next 200 of … more”: every record can be reached, but only 200 at a time (749 clicks for the last one), and the paged lists (Memory regions, Memory image, Problems) have Previous and Next only: there is no jump to a record, region or page in the tree or in the lists (the shared components have none). Selecting a problem row selects its record and its bytes in the byte pane, which is the quick way to a record. The memory worst case of about 9 bytes for each character that this item reported held until hex9; it is now 3.6 (see the memory item above). Jump controls (hex9): not added. “Go to record #”, “Go to region #” and “Go to address” controls would have to live in the shared components:
explorer/components/table.js(itspager()gives Previous and Next only; the Memory regions, Memory image and Problems lists use it) and the tree’s virtual list inengine/tree.js(“Show the next 200” only) are not ours to change and have no such control; the data model here is ready for them (previews.regions,previews.imageandpreviews.issuestake afromandto, and the tree list hasindexAt(offset)). The only jump the explorer has that applies is the “Go to address” box of the disassembly view (components/code.js), available when a processor is chosen. Reported to the lead: components/table.js needs a “Go to row #” box and the tree needs a “Go to node #”. - Viewer: (hex10, 25 November 2026) Memory: the blocks of the memory image are now 8 bytes (they were 16; 13 bytes for a block instead of 22), so a file that touches one byte in each block costs less. Measured as before (Node 26, this Mac, the parse alone): the worst case, 7,100,000 one-byte records in descending 64 KiB windows (99.5 MB), 2.2 to 3.0 bytes for each character over three runs (it was 3.55); ascending 2.2 (it was 2.84); scrambled 1.4 (it was 1.77). At the 256 MiB limit the worst measured case is 3.0 × 268,435,456 = about 0.8 GB (arithmetic, not run); the target of about 0.77 GB (2.9 a character) is not reached with certainty. The test bounds are 2.8 (ascending) and 3.2 (windows). Jump controls: the shared table component now has a “Go to row #” box (components/table.js, added by its owner), so the paged lists (Memory regions, Memory image, Problems) have it; the tree (components/tree.js) still has only “Show the next 200”: the exact patch for its owner is in
6502/progress-hex10.md, not applied.
Links
Software
- Arduino IDE – builds sketches into HEX files and uploads them to boards (Windows, macOS, Linux)
- AVRDUDE – command-line programmer for AVR microcontrollers (Windows, macOS, Linux)
- STM32CubeProgrammer – ST’s tool for programming STM32 chips (Windows, macOS, Linux)
- GNU Binutils – its
objcopyconverts HEX to and from binary and ELF (Windows, macOS, Linux) - SRecord – converts, merges and checks HEX and other firmware files (Windows, macOS, Linux)
Developers
- IntelHex – library that reads, writes and merges HEX files (Python)