Enkode
Gzip/Deflate ↔ Base64
Kompresi teks menjadi Gzip atau Deflate lalu encode hasilnya sebagai Base64 — dan sebaliknya. Bekerja melalui Compression Streams API langsung di browser.
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.
Artikel tentang alat ini: Gzip + Base64: mengompresi data untuk dikirim sebagai teks
Pertanyaan yang sering diajukan
Apa bedanya format Gzip dan Deflate di sini?
Deflate adalah algoritma kompresi mentah, sementara Gzip adalah Deflate yang dibungkus header tambahan berisi metadata dan checksum CRC. Karena perbedaan wrapper ini, data yang dikompres sebagai Gzip tidak bisa langsung di-decode sebagai Deflate begitu saja, atau sebaliknya.
Kenapa hasil kompresi masih perlu di-encode ke Base64?
Hasil kompresi Gzip/Deflate berupa data biner, sedangkan Base64 dibutuhkan agar data itu bisa disalin, ditempel, atau dikirim lewat medium berbasis teks seperti JSON atau URL tanpa rusak.
Apakah teks yang saya proses dikirim ke server?
Tidak. Alat ini memakai Compression Streams API bawaan browser, sehingga kompresi, dekompresi, dan encoding Base64 semuanya berjalan lokal tanpa mengirim data ke server.
Kenapa dekompresi kadang menghasilkan error "invalid header"?
Penyebab paling umum adalah format yang tertukar: data dikompresi sebagai Deflate "mentah" tanpa header, tetapi dibongkar sebagai Gzip (yang mengharapkan header sendiri dan CRC-32), atau sebaliknya. Coba ganti format di pengaturan alat ini.
Apakah kompresi selalu memperkecil ukuran akhir?
Tidak. Pada string yang sangat pendek, overhead header Gzip dan pembengkakan dari Base64 bisa melebihi manfaat kompresi — pendekatan ini hanya masuk akal untuk data teks yang cukup besar dan mudah dikompresi.