You are offline. The tools work from the copy saved in this browser; pages you have not opened yet need a connection.
Modbus Frame Converter: RTU ↔ TCP ↔ ASCII
Paste a Modbus frame in any form and get the same request or response as Modbus RTU, Modbus TCP and Modbus ASCII, with the CRC, MBAP header and LRC recalculated.
Frames
ExampleRTU with CRC, TCP with MBAP header, ASCII starting with a colon, or just the PDU (function code and data). One frame per line. Wireshark hex streams and Modbus Poll logs work as they are.
Leave both fields empty to keep the values from the frames. A frame without a transaction ID gets one counted from 1, and a response always gets the ID of its request.
Converted frames
Runs entirely in your browser. Nothing you enter is sent to a server.
What each variant adds to the PDU
| Part | RTU | TCP | ASCII |
|---|---|---|---|
| Start | — | — | colon (3A) |
| Header | — | transaction ID 2 B, protocol ID 0 2 B, length 2 B | — |
| Device address | 1 byte | unit ID, 1 byte | 2 hex characters |
| PDU (function code + data) | binary | binary | hex text, 2 characters per byte |
| Check | CRC-16, low byte first | none, TCP protects the data | LRC, 2 hex characters |
| End of frame | silence of 3.5 characters | given by the length field | CR LF (0D 0A) |
The PDU is the same in all three variants, so a conversion never changes register values. A PDU has at most 253 bytes.
How the conversion works
All three Modbus variants carry the same PDU: the function code and its data. Only the envelope differs. RTU puts the device address in front and a CRC-16 at the end. TCP puts a 7-byte MBAP header in front (transaction ID, protocol ID 0, length, unit ID) and has no checksum. ASCII writes the address, the PDU and an LRC as hex text between a colon and CR LF. The converter takes the PDU out of whatever you paste and wraps it again, so the CRC, the length and the LRC are always recalculated. To see what each byte means, open the frames in the frame decoder.
A Modbus TCP to RTU gateway does exactly this with every request. When a gateway setup does not work, compare what your software sends over TCP with what should appear on the RS-485 side.
Common mistakes
- Modbus TCP and RTU over TCP are not the same. RTU over TCP sends the RTU frame with its CRC unchanged through a TCP connection, without an MBAP header. A device or gateway that expects one and gets the other stays silent. Use the RTU line for RTU over TCP and the TCP line for Modbus TCP.
- Wrong unit ID through a gateway. The unit ID from the TCP header becomes the device address on the serial line. TCP software often sends 255 or 0 by default, and no serial device answers to that in normal use. Enter the real address in the field above.
- Transaction ID ignored. A Modbus TCP response carries the transaction ID of its request. Software that sends several requests at once uses it to tell the responses apart, so the converter keeps request and response IDs matched.
- Length field off by one. The MBAP length counts the unit ID and the PDU, not the first six header bytes. Hand-built frames often get this wrong; the converter always calculates it.
Questions from practice
How do I convert a Modbus RTU frame to Modbus TCP?
Remove the two CRC bytes from the end, keep the device address as the unit ID and put six bytes in front: the transaction ID, two zero bytes and the length (PDU length + 1). For 11 03 00 6B 00 03 76 87 that gives 00 01 00 00 00 06 11 03 00 6B 00 03.
What is the difference between Modbus TCP and Modbus RTU over TCP?
Modbus TCP uses the MBAP header and no CRC. RTU over TCP, called RTU encapsulated or serial tunnelling in some software, sends the serial RTU frame including its CRC unchanged through a TCP connection. Both often use port 502, so the device or gateway manual or a Wireshark capture is the only way to tell which one is expected.
Which unit ID should I use through a Modbus TCP gateway?
The address of the serial device behind the gateway, 1–247. The gateway copies the unit ID into the RTU frame. Some gateways map unit IDs to other addresses or answer unit 0 or 255 themselves, so check the gateway settings if the address alone does not help.
Does the converter change register values?
No. The function code and the data bytes are copied unchanged. Only the device address (if you set one), the transaction ID and the header or checksum around the PDU change.
Why does a Modbus ASCII frame end with CR LF?
Modbus ASCII marks the end of every frame with carriage return and line feed (0D 0A). The converter shows the frame without them so it can be pasted into a terminal; when sending, add CR LF or turn it on in the terminal program.
Related tools
- Register DecoderFloat32, Int32, UInt16 and bits in every byte order, plus Find my value.
- Address Converter40001 ↔ offset 0, 4x/3x/0x/1x notation, 5- and 6-digit addresses.
- Value EncoderTurn a value like 230.5 into registers for every byte order.
- CRC-16 CalculatorModbus RTU checksum in wire order, plus a full frame check.
- Frame DecoderRead RTU and TCP frames from Wireshark or a serial log.
- Request GeneratorRead and write requests in RTU, TCP and ASCII, plus a check of the reply.
- Function & Exception CodesWhat each code means and the usual cause in practice.
- Status Word DecoderName each bit of a 16- or 32-bit status register.
- Modbus RTU Timing CalculatorCharacter time, t1.5 and t3.5, frame length, shortest timeout and how many reads per second fit on the line.
- 4–20 mA ScalingRaw values to engineering units, 0–10 V and 4–20 mA with fault detection.
- IEEE 754 ConverterFloat32 and Float64 to hex and back, bit by bit, with registers for every byte order.
- CRC-8 / CRC-16 / CRC-32 CalculatorAny CRC from 3 to 82 bits: 113 named algorithms, your own parameters, and finding which CRC a device uses.
- S5TIME / DT / DTL ConverterSiemens S7 time formats: S5TIME, TIME, DATE, TOD, DATE_AND_TIME and DTL to raw hex and Modbus registers and back.
- P1 Telegram Decoder (DSMR)Decode a smart meter P1 telegram (DSMR, Belgian e-MUCS): OBIS codes, CRC check, power per phase, gas and water.
- Pt100 / Pt1000 CalculatorResistance to temperature and back per IEC 60751, with 2-wire lead error and tolerance classes.
- Thermocouple CalculatormV to °C and back for types K, J, T, E, N, R, S and B, with cold junction compensation.
- Register mapsReady-made register maps for meters, inverters and batteries.