ZATCA QR Code Decoder

Decode and validate ZATCA e-invoice QR codes instantly. Extract seller info, VAT number, timestamp, and verify Phase 2 cryptographic data. Free online tool.

All processing happens in your browser. No data is sent to any server.

Paste QR Content (Base64)

Or scan a QR code

Decoded Invoice Data

Paste Base64 or scan QR to decode

Need to generate ZATCA-compliant QR codes for your invoices?

Need to generate & validate QR codes programmatically?

Use the Qeemah ZATCA API to automate QR generation, validation, XML signing, and Fatoora submission directly from your ERP or POS system.

Explore ZATCA API

Complete Guide to Decoding ZATCA QR Codes

ZATCA (Zakat, Tax and Customs Authority) mandates that all electronic invoices in Saudi Arabia include a machine-readable QR code. This QR code contains essential invoice information encoded using the TLV (Tag-Length-Value) format and converted to Base64. Understanding how to decode these QR codes is crucial for invoice verification, audit compliance, and system integration.

Understanding TLV Encoding Structure

The ZATCA QR code uses a binary encoding scheme where each piece of data is structured as:

  • Tag (1 byte): An integer from 1-9 identifying the data type
  • Length (1 byte): The number of bytes in the value (max 255)
  • Value (variable): The actual data, encoded in UTF-8 for Tags 1-7, or raw binary for Tags 8-9

After concatenating all TLV tuples, the resulting byte array is encoded to Base64, which is then rendered as the QR code image.

ZATCA QR Code Tags Explained

Phase 1 Tags (Mandatory since December 2021)

Tag Field Format Example
1 Seller Name UTF-8 String شركة المثال ذ.م.م
2 VAT Number 15 digits (3...3) 310122393500003
3 Timestamp ISO 8601 2024-01-15T14:30:00
4 Invoice Total Decimal 1150.00
5 VAT Amount Decimal 150.00

Phase 2 Tags (Additional Cryptographic Data)

Tag Field Format Purpose
6 XML Hash Base64 (44 chars) SHA-256 hash of invoice XML
7 ECDSA Signature Base64 (~96 chars) Digital signature of the hash
8 Public Key DER Binary (Base64) Key for signature verification
9 ZATCA Signature Binary (Base64) CA signature (simplified invoices)

Decoding Process Step-by-Step

  1. Extract Base64: Scan the QR code to get the Base64 string
  2. Decode to bytes: Convert Base64 to a byte array using standard decoding
  3. Parse TLV tuples: Read Tag, Length, Value sequentially from the byte array
  4. Interpret values: Convert bytes to strings/numbers based on tag type
  5. Validate fields: Check format compliance (VAT format, timestamp, etc.)

Common Decoding Errors and Solutions

Troubleshooting Guide

  • Invalid Base64: Ensure the complete QR content is captured. Partial scans will fail.
  • TLV parsing error: The QR may use a non-ZATCA format. Verify it's from a ZATCA-compliant system.
  • Missing Phase 2 tags: Phase 1 invoices only have Tags 1-5. Tags 6-9 require ZATCA integration.
  • Corrupted signature: Binary data (Tags 8-9) must be handled as raw bytes, not UTF-8.

Integration with ZATCA E-Invoicing

For businesses operating in Saudi Arabia, understanding QR decoding is essential for:

  • Invoice Verification: Validate received invoices before payment processing
  • Audit Compliance: Ensure QR codes match invoice details during tax audits
  • System Integration: Parse QR data for automated accounting workflows
  • Customer Trust: Allow customers to verify invoice authenticity

Pro Tip: Verify with Official Tools

Always cross-check decoded QR data with the official ZATCA VAT App for production invoices. This decoder is perfect for development, testing, and understanding QR structure, but official validation should use ZATCA's approved channels.

Related Tools for ZATCA Compliance

Complete your e-invoicing toolkit with these complementary tools:

Frequently Asked Questions

What is TLV encoding in ZATCA QR codes?

TLV (Tag-Length-Value) is the encoding format mandated by ZATCA for e-invoice QR codes. Each data field is encoded as: a 1-byte Tag number (1-9), a 1-byte Length indicating the data size, and the actual Value bytes. This structure allows QR scanners to parse invoice data reliably. Tags 1-5 contain basic invoice info (seller name, VAT number, timestamp, totals), while Tags 6-9 contain Phase 2 cryptographic data.

What is the difference between Phase 1 and Phase 2 ZATCA QR codes?

Phase 1 QR codes contain 5 mandatory fields: Seller Name (Tag 1), VAT Number (Tag 2), Timestamp (Tag 3), Invoice Total (Tag 4), and VAT Amount (Tag 5). Phase 2 QR codes include additional cryptographic security with Tags 6-9: XML Hash, ECDSA Signature, Public Key, and ZATCA Certificate Signature. Phase 2 ensures invoice integrity and prevents tampering.

How do I validate a ZATCA QR code?

You can validate ZATCA QR codes using three methods: (1) Use this free decoder tool to extract and validate all TLV fields, (2) Use the official ZATCA VAT App available on iOS and Android, (3) For Phase 2 invoices, verify the cryptographic signature matches the invoice XML hash using the embedded public key.

Why is my VAT number showing as invalid?

ZATCA VAT registration numbers must be exactly 15 digits, starting with '3' and ending with '3'. The format is: 3XXXXXXXXXXXX3. If your VAT number doesn't match this pattern, it will fail validation. Common issues include: wrong number of digits, not starting/ending with '3', or including non-numeric characters.

Can I decode QR codes from printed invoices?

Yes! Use the 'Upload Image' or 'Use Camera' features to scan QR codes from printed invoices, PDFs, or screenshots. The tool uses advanced QR recognition to extract the Base64 content, then automatically decodes the TLV data. For best results, ensure the QR code is clear and well-lit.

What does the XML Hash (Tag 6) represent?

Tag 6 contains a SHA-256 hash of the invoice XML document, encoded in Base64 (44 characters). This hash acts as a digital fingerprint - any modification to the invoice XML will produce a different hash, making tampering detectable. In Phase 2, this hash is signed using ECDSA to prove the invoice hasn't been altered.

Is this tool safe to use with real invoices?

Absolutely. All processing happens 100% in your browser using JavaScript. No invoice data is ever sent to any server. You can verify this by using the tool offline or checking the network tab in your browser's developer tools. Your invoice data remains completely private.

Chat with us on WhatsApp