PRIVATE BROWSER TOOL
Convert Intel HEX to BIN
The converter validates all records, reconstructs absolute addresses and fills unmapped gaps explicitly so the resulting binary layout is predictable.
Inputs
Results
Run the tool to see a structured report here.
ON THIS DEVICE
Recent history
Your latest 10 runs will appear here on this device.
HOW IT WORKS
Method and formulas
Data records are sorted by absolute address. The lowest mapped address becomes offset zero unless a custom range is selected; unmapped bytes are filled with the selected byte.
Always compare generated firmware with the target device’s memory map, linker output and programming documentation before flashing.
GUIDE
What this tool does and when to use it
The Intel HEX to BIN converter processes addressed Intel HEX records and produces a contiguous raw binary image. It accepts standard HEX files containing data records, extended segment address records, and extended linear address records. The converter sorts all data bytes by their computed 32-bit absolute addresses before writing the output. Users select a fill byte value between 0 and 255 to populate any address gaps that exist between the lowest and highest mapped locations. A custom output range can be specified to extract only a defined address window, which is useful when firmware images must match a fixed flash size. The tool also reports the base address of the resulting binary so developers know the original offset of the first byte. This conversion is required when preparing firmware for direct flash programming tools that expect flat binary images rather than record-based formats. Embedded engineers working with microcontrollers from ST, NXP, or Microchip frequently need this step after extracting firmware from debug probes or vendor update packages.
Worked example with realistic numbers
Consider a short Intel HEX file containing three data records. The first record places two bytes at absolute address 0x08000000. The second record places four bytes at address 0x08000010 after an extended linear address record. The third record places one byte at address 0x08000020. After sorting, the lowest address is 0x08000000. With the default fill byte of 0xFF and no custom range, the output binary begins at offset zero corresponding to 0x08000000. Bytes between 0x08000002 and 0x0800000F receive the fill value, as do the gaps between 0x08000014 and 0x0800001F. The resulting 33-byte binary therefore contains the original data at the correct relative positions and fill bytes everywhere else. A table of input records and output byte positions illustrates the mapping clearly.
| Record Type | Absolute Address | Data Bytes | Output Offset |
|---|---|---|---|
| Data | 0x08000000 | 0x12 0x34 | 0 1 |
| Data | 0x08000010 | 0x56 0x78 0x9A 0xBC | 16 17 18 19 |
| Data | 0x08000020 | 0xDE | 32 |
Formula and method table
The conversion follows a deterministic address-to-offset mapping. Absolute address is calculated as (extended linear base × 65536) + record address. The minimum absolute address among all data records becomes the reference zero unless a user-defined start address overrides it. Output length equals the selected end address minus the chosen start address plus one. Every unmapped byte position receives the user-selected fill value. The table below summarises the key inputs, their units, and the corresponding outputs.
| Input | Unit | Output | Unit |
|---|---|---|---|
| Fill byte | 0-255 decimal | Filled gap bytes | raw binary |
| Start address | 32-bit hex | Binary start offset | byte index 0 |
| End address | 32-bit hex | Binary length | bytes |
| HEX records | list of 16-bit addresses | Absolute mapping | 32-bit addresses |
Units and conversions notes
Addresses in Intel HEX files are expressed in hexadecimal. Extended linear address records supply the upper 16 bits while data records supply the lower 16 bits, yielding a 32-bit absolute address space. Binary output uses byte addressing with no record overhead. When a custom range is supplied, the tool reports both the original base address and the trimmed binary length in bytes. Fill operations preserve exact byte counts so the final image size matches the requested range exactly. All numeric values remain in unsigned integer representation; no sign extension occurs during address arithmetic.
Limitations
The converter operates entirely within browser memory and therefore handles files up to roughly 50 MiB before performance degrades. Address spaces larger than 4 GiB are not supported because 32-bit addressing is used internally. Overlapping data records at the same absolute address trigger an error rather than silent overwriting. Start and end addresses must be supplied in ascending order; reversed ranges are rejected. The tool does not validate checksums beyond basic record syntax; corrupted HEX files may produce unexpected binary content. Custom ranges that fall entirely outside mapped data produce an all-fill output of the requested length.
Common mistakes
Developers sometimes forget to account for extended linear address records and therefore obtain incorrect absolute addresses. Selecting a fill byte of 0x00 when the target flash expects erased 0xFF bytes leads to programming failures. Omitting the custom range on sparse firmware images produces unnecessarily large binaries that exceed flash capacity. Assuming the lowest record address is always zero causes offset errors when the actual base lies at 0x08000000 or similar flash origins. Ignoring the reported base address after conversion results in incorrect vector table placement during flashing.
Additional paragraphs expand on each section to provide complete guidance. Address calculation must consider both the segment and linear record types because some legacy toolchains still emit segment records. When multiple extended linear records appear, the converter updates the current base before processing subsequent data records. The output binary never includes the original record headers or checksums, ensuring a pure image suitable for direct memory writes. Edge cases such as single-byte records at the extreme ends of the address space are handled by extending the fill region accordingly. Users should verify the reported base address against the microcontroller datasheet before programming. Sparse files with large gaps benefit most from the selectable fill byte because it avoids embedding unintended patterns. The method table entries remain constant regardless of file size, guaranteeing reproducible results across different HEX sources. Validation of address ordering occurs before any binary emission, preventing partial outputs when input data is unsorted. Production firmware pipelines often chain this conversion with subsequent CRC insertion steps performed on the raw binary. Understanding the exact byte count after range selection prevents flash overflow during device programming operations.
LONG-FORM ANSWERS
Frequently asked questions
How are extended linear address records combined with 16-bit data record addresses during absolute mapping?
The tool multiplies the extended linear base by 65536 and adds the 16-bit record address to obtain a 32-bit absolute location. This calculation repeats whenever a new extended linear record appears. All subsequent data records use the updated base until the next linear record is encountered.
What occurs when two data records specify the same absolute address?
The converter detects the collision and reports an error instead of choosing one value. This prevents silent data loss in firmware images that should never contain overlapping definitions.
Which fill byte value is recommended when preparing images for erased NOR flash?
Use 0xFF because NOR flash erases to all ones. Any other value may cause the programmer to interpret the image as already containing data in gap regions.
How does the reported base address change when a custom start address is supplied?
The reported base remains the original lowest mapped address from the HEX file. The custom start only affects the first byte written to the output binary and the final length calculation.
What is the maximum binary length that can be produced without exceeding browser memory limits?
Files resulting in binaries larger than approximately 50 MiB may cause the browser tab to become unresponsive. Users should apply a custom range to keep output size reasonable for very large address spaces.
Does the converter preserve segment address records from older Intel HEX variants?
Segment address records are converted using a 16-byte shift instead of the 65536-byte shift used for linear records. The resulting absolute addresses are still sorted correctly before binary emission.
Can the output range start after the first mapped byte and still produce a valid image?
Yes. The tool trims leading bytes and adjusts offsets so the first output byte corresponds to the chosen start address. Fill bytes are inserted only within the selected window.
What validation step should be performed on the resulting binary before flashing?
Compare the reported base address against the microcontroller vector table location and verify total length against flash sector size. A quick hexdump of the first 32 bytes confirms correct data placement after conversion.