Modbus Register Decoder
Turn Modbus register pairs into float32, int32, and uint32 across all four byte orders (ABCD, DCBA, BADC, CDAB). Find the word order your device actually uses.
Two registers decode to 32-bit types; four decode to float64. Separate with spaces or commas.
| Register | Hex | uint16 | int16 | Binary |
|---|---|---|---|---|
| 0 | 0x42F6 | 17142 | 17142 | 0100001011110110 |
| 1 | 0xE979 | 59769 | -5767 | 1110100101111001 |
32-bit value in every byte order
One order produces a value in a normal engineering range. That is almost certainly the one your device uses.
| Order | float32 | int32 | uint32 | |
|---|---|---|---|---|
| ABCDlikely | 123.456001 | 1123477881 | 1123477881 | |
| DCBA | 1.518500e+35 | 2045376066 | 2045376066 | |
| BADC | -9.861115e+32 | -163415575 | 4131551721 | |
| CDAB | -1.883367e+25 | -377928970 | 3917038326 |
- ABCD
- — big endian, high word first (Modbus standard)
- DCBA
- — little endian, full byte reversal
- BADC
- — big endian with bytes swapped inside each word
- CDAB
- — word swap, bytes kept in order (very common on gateways)
Why Modbus floats are a problem at all
The Modbus data model has exactly one numeric type: a 16-bit register, transmitted most significant byte first. That is the whole specification. It says nothing about how to represent a 32-bit integer or an IEEE 754 float, because when the protocol was published, devices did not send them.
Vendors needed 32-bit values anyway, so each one decided independently how to split a value across two registers. Two choices had to be made — which 16-bit word goes first, and whether the bytes inside each word are swapped — and all four combinations shipped in real products. The result is that a register pair is meaningless until you know which convention the device follows.
The four byte orders
Take the float 123.456. In IEEE 754 single precision it is the byte sequence42 F6 E9 79. Label those bytes A, B, C, and D from most significant to least. Each convention puts them on the wire differently:
| Order | Register 0 | Register 1 | Also called |
|---|---|---|---|
| ABCD | 0x42F6 | 0xE979 | Big endian, high word first |
| CDAB | 0xE979 | 0x42F6 | Word swap, byte swap none |
| BADC | 0xF642 | 0x79E9 | Byte swap, word order kept |
| DCBA | 0x79E9 | 0xF642 | Little endian, full reversal |
Paste any of those register pairs above and the corresponding row decodes to 123.456 while the other three produce nonsense. That contrast is the fastest way to identify an unknown device.
Finding the order your device uses
- Read a register pair whose value you know. A temperature sensor sitting in a room, a supply voltage, a firmware version — anything where you can predict the answer within an order of magnitude.
- Decode it in all four orders. Paste the registers into the tool above; the plausible reading is highlighted.
- Confirm with a second pair. A single value can occasionally look reasonable under two orders. Checking one more register pair removes the ambiguity.
- Write the order down in your driver. Devices are consistent internally, so once you know the convention, every 32-bit value on that device follows it.
When no order looks right
If all four candidates are implausible, the registers probably do not hold a float at all. Check theint32 and uint32 columns — counters, timestamps, and serial numbers are usually integers. Scaled integers are also common: a device may report 245 for 24.5 °C, with the scale factor documented in the register map rather than encoded in the data.
Gateways add another layer
Modbus TCP-to-RTU gateways and protocol converters sometimes reorder words themselves. If a device reads correctly on a direct serial connection but not through a gateway, the gateway is applying its own swap, and the fix belongs in the gateway configuration rather than in your code.
Register addressing, briefly
A separate and equally common source of confusion is addressing. Documentation often uses the legacy convention where holding registers are numbered from 40001, while the address that actually goes on the wire starts at 0. A register documented as 40108 is address 107 in the frame. If your values are consistently one register off, this offset is usually why.
Frequently asked questions
Which byte order should I use?
There is no universal answer, because the Modbus specification never defined 32-bit values. Read a register pair whose real value you already know — a temperature, a voltage, a serial number — and pick the order that produces it. Every other 32-bit value on that device will use the same order.
Why does my float come out as a huge or tiny number?
That is the signature of a wrong byte order. Swapping bytes scrambles the exponent field, which turns a value like 24.5 into something around 1e-38 or 1e28. If one candidate reading looks like a normal engineering value and the others do not, the plausible one is almost certainly correct.
What is the difference between ABCD and CDAB?
ABCD sends the most significant 16-bit word first, which is what a strict reading of the Modbus data model implies. CDAB sends the least significant word first while keeping the bytes inside each word in big-endian order. CDAB is extremely common because many devices store the value little-endian internally and copy word by word.
Does this tool send my data anywhere?
No. All decoding happens in JavaScript in your browser. Nothing is uploaded, logged, or stored.
How do I decode a 64-bit double?
Enter four consecutive registers. The tool shows the float64 interpretation for each byte order below the 32-bit table. Note that some devices apply the word swap across all four words while others swap within 32-bit halves, so verify against a known value.