الترميز
Gzip/Deflate ↔ Base64
ضغط النص بصيغة Gzip أو Deflate ثم ترميز النتيجة بـ Base64 — والعكس. يعمل عبر Compression Streams API مباشرة في المتصفح.
Base64 by itself doesn't compress anything — quite the opposite, it grows the size by about 33%. To send large text compactly through a text-only channel, it's first compressed with Gzip or Deflate, and only then is the result Base64-encoded.
How to use it
- Compress: paste text and the tool compresses it with Gzip or Deflate (the browser's Compression Streams API) and encodes the result as Base64.
- Decompress: paste a Base64 string of compressed content to get the original text back.
- Pick Gzip or Deflate depending on which format the receiving system expects.
Common uses
- Compactly embedding a large text value (an SVG, a config) in a URL parameter or cookie with a size limit.
- Preparing a compressed payload for an API that accepts Base64-encoded Gzip data.
- Decompressing data received in this format from another system so it can be read manually.
Things to keep in mind
Compression only pays off on sufficiently large, compressible text — on short strings the Gzip header overhead plus the Base64 expansion can actually make the result bigger.
Deflate skips Gzip's headers, so its output is more compact, but the format is less self-describing: the receiving side needs to know in advance that it's Deflate specifically.
الأسئلة الشائعة
ما الفرق بين Gzip وDeflate؟
Deflate هو خوارزمية الضغط الخام نفسها، بينما Gzip هو تنسيق يضيف رأسًا (header) ومجموع تحقق CRC حول بيانات Deflate. لهذا بيانات Gzip المضغوطة أكبر قليلًا لكنها تحمل معلومات تحقق إضافية من سلامة البيانات.
لماذا تفشل عملية فك الضغط أحيانًا رغم أن Base64 يبدو صحيحًا؟
غالبًا لأن الصيغة المختارة (Gzip أو Deflate) لا تطابق الصيغة الفعلية التي ضُغطت بها البيانات الأصلية؛ فرأس Gzip يختلف عن بيانات Deflate الخام، لذا يجب اختيار نفس الصيغة المستخدمة عند الضغط.
هل يتم إرسال النص إلى خادم لضغطه أو فك ضغطه؟
لا، تعتمد الأداة على Compression Streams API المدمج في المتصفح، فكل عمليات الضغط وفك الضغط والترميز تتم محليًا دون إرسال أي بيانات إلى خادم.
لماذا يعطي فك الضغط أحيانًا خطأ "invalid header"؟
السبب الأشيع هو الخلط بين الصيغتين: بيانات ضُغطت كـ Deflate "خام" بلا ترويسة، ثم حاولنا فك ضغطها كـ Gzip (الذي يتوقع ترويسته الخاصة وCRC-32)، أو العكس. جرّب تبديل الصيغة في إعدادات الأداة.
هل يقلّل الضغط دائمًا من الحجم النهائي؟
لا. في السلاسل القصيرة جدًا، قد تتجاوز تكاليف ترويسة Gzip والزيادة الناتجة عن Base64 المكاسب المتحققة من الضغط — هذا الأسلوب منطقي فقط مع بيانات نصية كبيرة بما يكفي وقابلة للضغط جيدًا.