SUM/XOR/LRC Checksum Calculator

Calculate SUM-8, SUM-16, XOR-8 and LRC-8 together from HEX bytes or UTF-8 text.

All calculations run in your browser. Your input is not uploaded.

Input format

Use continuous HEX or complete byte groups separated by spaces, commas or semicolons. Optional 0x prefixes are supported. Maximum data size: 64 KiB.

Checksum results

Input: 4 bytes

Input bytes (HEX preview)

01 02 03 04

SUM-8

Add every byte and keep the low 8 bits.

HEX
0x0A
Decimal
10
Binary
00001010

SUM-16

Add every byte and keep the low 16 bits.

HEX
0x000A
Decimal
10
Binary
0000000000001010

XOR-8

XOR every byte, starting from 0.

HEX
0x04
Decimal
4
Binary
00000100

LRC-8

Two’s complement of SUM-8: (256 − SUM-8) mod 256.

HEX
0xF6
Decimal
246
Binary
11110110

LRC-8 uses the Modbus ASCII two’s-complement sum definition. Only the supplied bytes are calculated; frame headers and trailers are not detected or removed.

How to calculate a checksum

Choose HEX bytes or UTF-8 text and enter your data. All four results update automatically. HEX accepts complete bytes such as 01020304, 01 02 03 04 or 0x01, 0x02. Half-bytes, minus signs, colons and complete Modbus ASCII frames are not accepted. Switching input format reinterprets the current content; it does not convert it.

What do the algorithms mean?

  • SUM-8: add the byte values modulo 256.
  • SUM-16: add individual bytes modulo 65536. This does not combine adjacent bytes into 16-bit words and is not the Internet checksum.
  • XOR-8: XOR all bytes starting from zero. Some protocols call this BCC; check your device’s definition.
  • LRC-8: the two’s complement of SUM-8, as used by Modbus ASCII. Other protocols may use a different LRC definition.

For HEX 01 02 03 04:

SUM-8 SUM-16 XOR-8 LRC-8
0x0A 0x000A 0x04 0xF6

Modbus ASCII LRC example

Load the Modbus example: 01 03 00 00 00 0A produces LRC-8 0xF2. These are six HEX bytes, not the UTF-8 codes of the displayed hexadecimal characters.

To generate an LRC, enter the address, function and data bytes only. Exclude the opening colon, an existing LRC and the trailing CR/LF. Append F2 to obtain :01030000000AF2, followed by CR/LF. See the Modbus Serial Line Guide, §6.2.1.

To check an existing LRC, enter the data plus LRC in HEX mode, such as 01 03 00 00 00 0A F2. SUM-8 should be 0x00. This checks the sum relationship, not the entire frame structure.

Why do text and HEX give different answers?

Text 01 becomes UTF-8 bytes 30 31; HEX 01 is a single byte. Spaces and line breaks are preserved in text mode, and non-ASCII characters can use multiple bytes. Check the byte preview when results differ. The limit is 64 KiB. Only the first 32 bytes are previewed, but every input byte is calculated.

Simple checksums detect some transmission errors; they do not protect against tampering. Use the linked CRC or file checksum tools for CRC, MD5 or SHA algorithms.