TestBench.tools

NMEA Checksum Calculator

XOR checksum for NMEA 0183 sentences, validate or generate.

Checksum VALID

Computed checksum
0x47
Complete sentence
$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
Type
GP / GGA

This tool validates and generates NMEA 0183 checksums. Paste a full sentence with *HH and it verdicts PASS/FAIL with the expected value; paste a body without one and it hands you the complete sentence ready to transmit. The checksum is simply the XOR of every character between $ and *.

How it works

An NMEA 0183 sentence is a printable ASCII line: $<address>,<fields…>*HH. The two hex digits HH are the bitwise XOR of every character after the $ and before the * — the address field, all commas and all data characters. XOR is order-insensitive per bit position and costs one instruction per byte, which suited the 4800-baud instrument links the standard was written for. When validation fails, the mismatch is almost always either a truncated sentence (dropped serial bytes) or a checksum computed over the wrong span.

Worked example

$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
XOR("GPGGA,123519,…,M,,") = 0x47 → VALID

body “GPGLL,4916.45,N,12311.12,W,225444,A” → checksum 0x31

Parameters

ParameterValueNotes
AlgorithmXOR of bytes8-bit
Spanbetween $ and *both exclusive
Outputtwo uppercase hex digits
Line endingCR LFnot part of the checksum

Python implementation

Python
# NMEA 0183 checksum: XOR of characters between '$' and '*'
from functools import reduce

def nmea_checksum(body: str) -> int:
    return reduce(lambda x, c: x ^ ord(c), body, 0)

body = "GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,"
assert f"{nmea_checksum(body):02X}" == "47"
print(f"$" + body + f"*{nmea_checksum(body):02X}")

FAQ

Which characters does the NMEA checksum cover?

Everything between the leading '$' and the '*' — exclusive of both. The two hex digits after '*' are the XOR of those characters. The '$', the '*', the checksum itself and the trailing CR/LF are never included, which is the most common mistake in hand-rolled implementations.

Is the checksum mandatory?

The NMEA 0183 standard makes it mandatory for some sentence types and optional for others, but virtually every modern GNSS receiver emits it and most parsers require it. This tool treats a missing checksum as 'not validated' and shows you the value to append.

How strong is an XOR checksum?

Weak by design: it catches any single-bit error and any odd number of bit errors per position, but two identical errors cancel and reordered characters can pass. It is a sanity check for a short ASCII line over a serial port, not a CRC — adequate for its job, nothing more.

How do I verify this tool?

The canonical example sentence $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47 must validate as correct — 0x47 is its published checksum, and this value is pinned in the site's automated test suite.

Is my data uploaded?

No. Validation and generation run locally in your browser.

Related tools