What is inside a ZATCA QR code
Since 4 December 2021 every tax invoice and simplified tax invoice in Saudi Arabia must carry a QR code defined by the Zakat, Tax and Customs Authority (ZATCA). The code contains a Base64-encoded TLV (tag-length-value) structure:
| Tag | Field | Phase |
|---|---|---|
| 1 | Seller's name โ ุงุณู ุงูุจุงุฆุน | 1 and 2 |
| 2 | VAT registration number (15 digits) โ ุงูุฑูู ุงูุถุฑูุจู | 1 and 2 |
| 3 | Invoice date and time (ISO 8601) | 1 and 2 |
| 4 | Invoice total including VAT | 1 and 2 |
| 5 | VAT total | 1 and 2 |
| 6 | Hash of the XML invoice | 2 |
| 7 | ECDSA signature | 2 |
| 8 | ECDSA public key | 2 |
| 9 | ZATCA stamp signature (simplified invoices) | 2 |
A normal QR scanner app only shows the unreadable Base64 string. This decoder unpacks the tags, shows them in English and Arabic, and runs plausibility checks: is the VAT number 15 digits starting and ending with 3, is the timestamp valid, does VAT รท (total โ VAT) give the standard 15%?
Portuguese invoice QR code (ATCUD)
In Portugal, invoices issued by certified software must show a QR code (Portaria n.ยบ 195/2020) and the ATCUD unique document code. The QR content is a list of fields separated by asterisks, for example A:123456789*B:999999990*C:PT*D:FS*โฆ*H:CDF7T5HD-12345*โฆ*O:0.80. The decoder translates each field: issuer and buyer NIF, document type (FT, FS, FR, NCโฆ), status, date, unique identification, ATCUD, VAT bases and amounts per rate and region (mainland, Azores, Madeira), stamp duty, withholding, total and the software certificate number.
Decoding is not verification
Anyone can create a QR code with these fields. Decoding shows you what the code claims; it does not prove the invoice was reported. To verify officially:
- Saudi Arabia: use the ZATCA verification service or app (scan the QR) or check the VAT number on the ZATCA website. Phase 2 codes also carry a cryptographic stamp that ZATCA-integrated software can validate.
- Portugal: check the invoice in e-Fatura on the Portal das Finanรงas with the buyer's NIF.
Privacy
Photos are analysed in your browser (with the built-in barcode detector or the open-source jsQR library). Nothing is uploaded, and the camera stream never leaves your device.
Frequently asked questions
How do I decode a ZATCA QR code?
What is the difference between Phase 1 and Phase 2 QR codes?
Does this verify the invoice with ZATCA?
Can I scan the QR code with my phone camera?
Does it read Portuguese invoice QR codes?
Updated: