Invoice Details (ZATCA Tags 1–5)
Scannable ZATCA Fatoora QR Code
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.
| Tag | Field | Value | UTF-8 Bytes | Hex Prefix (Tag + Len) |
|---|
Decode & Validate Any ZATCA Phase 1 or Phase 2 Base64 QR Payload
| Tag | ZATCA Field Name | Byte Length | Decoded Value | Check |
|---|---|---|---|---|
| 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));
}
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.
Related ZATCA Guides & Resources
ZATCA Phase 2 API Integration • Saudi E-Invoicing Software • ZATCA QR Requirements Guide • UBL 2.1 XML Format Explained • ZATCA Error Codes Troubleshooting