Terminator Pattern
The terminator (also called the terminator pattern) is a sequence of up to four zero bits (0000) appended to the end of the data bit stream during QR code encoding. It signals to the decoder that the meaningful data ends here, and is defined in the international standard ISO/IEC 18004.
When and where is it inserted?
It is inserted right after the input data has been converted to a bit stream according to the encoding mode, before the stream is divided into 8-bit codewords. The sequence runs: mode indicator, character count indicator, data payload, then the terminator. If the stream still does not align to an 8-bit boundary, extra zeros are added, and the remaining capacity is filled with the standard pad codewords (alternating 11101100 and 00010001). Error correction codewords are then calculated over this completed stream.
Can it be shorter than four bits?
Yes. The standard specifies the terminator as "up to four bits": when the data nearly fills the symbol's capacity, the terminator is shortened to whatever room remains, and it is omitted entirely if there is no room at all. Since the end of data can also be determined from the codeword count, a shortened or omitted terminator does not affect decoding. Micro QR codes use different lengths: 3 zero bits for version M1, 5 for M2, 7 for M3, and 9 for M4.
How does it differ from remainder bits?
Both are zero-fill mechanisms, but they operate at different layers. The terminator is inserted into the bit stream during encoding, before error correction is calculated, as an end-of-data marker. Remainder bits come at the very last stage: after all codewords have been placed as modules, they fill the leftover fragment of fewer than 8 modules in the data region. See the glossary entry on remainder bits for details.