With the development of the Internet of Things (IoT) technology, two-dimensional (2D) barcodes are widely used in smart IoT applications as a perception portal. In industries with many circulations and testing links like traceability, since the existing 2D barcode cannot be changed once it is printed, it can only be replaced with more expensive radio frequency identification (RFID) labels or new 2D barcodes, causing a waste of human resources and costs. For better circulation efficiency and resource utilization, we propose a new design of the rewritable and sustainable 2D barcode based on the fault-tolerance mechanism. The ability to add new information in the 2D barcode can be achieved through data encryption and the insertion of a rewritable layer. It means the message of 2D barcodes could be changed, and increases the flexibility and liquidity of the 2D barcode application. Besides, the encoding and decoding method of the proposed 2D barcode is presented. Experimental results have illustrated the superiority of rewritable and sustainable 2D barcodes in the traceability of herbal medicine compared with the conventional 2D barcodes, and demonstrated the feasibility of the design. The findings show the potential for significant application in the field of traceability in smart IoT, as well as in the manufacturing industry and logistics.