XOR Checksum Calculator (8-bit XOR / BCC) – Free

This XOR checksum calculator combines every byte of your input with exclusive OR and prints the one-byte result in hex, the check value used by NMEA sentences and many serial protocols.

How to use the XOR checksum Calculator tool

  1. Under Input format, choose UTF-8 text for a character string or Hexadecimal bytes for raw frame data.
  2. Enter the data to check in the Input box, leaving out any start marker or existing checksum.
  3. Select Calculate. The Example button runs 123456789 and returns 0x31.
  4. Copy the two hex digits from the Result box into your message, or compare them with the received value.

How an XOR checksum is computed

Start with zero. Take each byte in turn and XOR it into the running value. XOR compares two bits and gives 1 when they differ, with no carry between bit positions. After the last byte, the running value is the checksum. The start value is always zero and there is no final inversion. The tool prints the result as 0x followed by two uppercase hex digits.

Another way to see it: bit 0 of the result is the parity of all the bit 0s in the message, bit 1 is the parity of all the bit 1s, and so on. That is why the same calculation is also called a longitudinal parity check or a block check character.

Worked example: an NMEA 0183 sentence

NMEA sentences from GPS receivers end with an asterisk and two hex digits. The checksum covers the characters between the dollar sign and the asterisk, excluding both. For the sentence below, paste the text starting at GPGLL and ending at the final A, in UTF-8 text mode. The result is 0x32, so the complete sentence ends in *32.

The last two lines show the hex mode and a useful property. The four bytes give 0x67. Append that byte to the frame and the XOR of all five is 0x00, which is the test most receivers apply.

GPGLL,5109.30,N,00145.20,W,101530,A  ->  0x32
$GPGLL,5109.30,N,00145.20,W,101530,A*32

02 10 4A 3F     ->  0x67
02 10 4A 3F 67  ->  0x00

Text and hex input formats

Choose the mode by what the protocol checksums: printable characters or raw bytes. Either way the data is processed in your browser and stays on your device.

  • UTF-8 text: each character is converted to its UTF-8 bytes. ASCII gives one byte per character, while a character such as the euro sign contributes three.
  • Text is not trimmed. A trailing space or line break is a byte and changes the result.
  • Hexadecimal bytes: two digits per byte, separated by spaces, commas or line breaks, or run together as in 02104A3F.
  • A single 0x at the start of hex input is ignored. Writing 0x before every byte, or leaving a lone digit, gives Use complete hexadecimal bytes.
  • Empty input returns 0x00.

What XOR-8 catches and what it misses

A one-byte XOR detects any single flipped bit and any burst of errors up to eight bits long. It fails when two errors hit the same bit position in different bytes, since they cancel. It is also blind to order: the texts AB and BA both give 0x03. Inserting or removing zero bytes changes nothing either.

That is acceptable on a short serial cable and weak anywhere else. For files or network payloads use a CRC. Also check the protocol document before assuming XOR: some checksums named LRC, such as the one in Modbus ASCII, are a negated sum of the bytes, which this tool does not compute.

Frequently asked questions

How do I calculate an NMEA checksum with this tool?

Select UTF-8 text and paste the sentence without the leading $ and without the * and the digits after it. The two hex digits in the result are the checksum.

Why do I get 0x00 when I include the checksum byte?

XOR of a value with itself is zero. If the checksum is correct, it equals the XOR of all the other bytes, so adding it to the calculation cancels everything. A nonzero result means the data or the checksum is wrong.

Does the order of the bytes matter?

No. XOR is commutative and associative, so any ordering of one set of bytes gives one result. This is a known weakness: swapped bytes pass the check.

What is the XOR checksum of 123456789?

It is 0x31. The ASCII codes of the digits 1 to 8 XOR to 0x08, and combining that with 0x39, the code for 9, gives 0x31.

Related tools