100% Client-Side • ZATCA Fatoora Phase 1 & Phase 2 Spec

Free ZATCA QR Code Generator & TLV Base64 Decoder

Generate scannable Saudi Arabia ZATCA e-invoice QR codes with exact UTF-8 Arabic byte-length TLV encoding, or paste any Phase 1 / Phase 2 Base64 QR string to decode and validate all 9 tags instantly.

Invoice Details (ZATCA Tags 1–5)

Scannable ZATCA Fatoora QR Code

ZATCA TLV Base64 Output

Live TLV Binary & Hex Byte Breakdown

Every field is packed as [1-byte Tag][1-byte UTF-8 Byte Length][UTF-8 Value Bytes] and concatenated before Base64 encoding.

TagFieldValueUTF-8 BytesHex Prefix (Tag + Len)

Decode & Validate Any ZATCA Phase 1 or Phase 2 Base64 QR Payload

TagZATCA Field NameByte LengthDecoded ValueCheck
Paste a ZATCA Base64 string above to inspect all TLV tags.

Developer Reference: ZATCA TLV Base64 Code Snippets

Use these production-ready snippets in Laravel/PHP or Node.js/Browser JavaScript (always using UTF-8 byte length for Arabic company names).

PHP / Laravel ZATCA TLV Encoder

function zatcaTlvBase64(string $seller, string $vatNo, string $isoDate, string $total, string $vat): string {
    $fields = [1 => $seller, 2 => $vatNo, 3 => $isoDate, 4 => $total, 5 => $vat];
    $tlv = '';
    foreach ($fields as $tag => $value) {
        $tlv .= chr($tag) . chr(strlen($value)) . $value; // strlen() = raw UTF-8 bytes in PHP
    }
    return base64_encode($tlv);
}

JavaScript (UTF-8 Safe) ZATCA TLV Encoder

function zatcaTlvBase64(seller, vatNo, isoDate, total, vat) {
  const enc = new TextEncoder();
  const fields = [seller, vatNo, isoDate, total, vat];
  const chunks = [];
  fields.forEach((val, idx) => {
    const bytes = enc.encode(String(val));
    chunks.push(idx + 1, bytes.length, ...bytes);
  });
  return btoa(String.fromCharCode(...chunks));
}

Need Automated ZATCA Phase 2 Fatoora Clearance in Your POS?

LookPOS automates UBL 2.1 XML generation, cryptographic ECDSA stamping (CSID), TLV QR thermal receipts, and real-time B2B clearance & B2C reporting across Riyadh, Jeddah, and Dammam—starting at $95/year with 0% commission.

Explore ZATCA POS → WhatsApp Demo

ZATCA QR Code Technical FAQ

What tags are required in a ZATCA Phase 1 vs. Phase 2 QR code?

Phase 1 requires 5 TLV tags: Tag 1 (Seller Name), Tag 2 (15-digit VAT Registration Number), Tag 3 (ISO-8601 Invoice Timestamp), Tag 4 (Invoice Total including VAT), and Tag 5 (VAT Amount). Phase 2 (Integration Phase) appends Tag 6 (SHA-256 XML Invoice Hash), Tag 7 (ECDSA Digital Signature), Tag 8 (ECDSA Public Key), and Tag 9 (ZATCA CSID Cryptographic Stamp for simplified B2C invoices).

Why does my Arabic company name fail ZATCA Fatoora scanner validation?

The #1 developer bug is using string.length (UTF-16 code units) instead of UTF-8 byte length. Every Arabic letter takes 2 bytes in UTF-8, so a 10-character Arabic name requires a TLV length byte of 20 (0x14), not 10. This tool automatically calculates exact UTF-8 byte lengths.