인코딩
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는 압축 알고리즘 자체의 원시(raw) 결과물이고, Gzip은 그 위에 헤더와 CRC 체크섬 등 추가 정보를 감싼 포맷입니다. 두 형식은 서로 호환되지 않으므로 압축할 때 선택한 형식과 압축 해제 시 선택하는 형식이 반드시 같아야 합니다.
결과로 나온 Base64 문자열을 아무 데서나 압축 해제할 수 있나요?
해당 환경이 같은 압축 형식(Gzip 또는 Deflate)을 지원해야 합니다. 브라우저나 라이브러리마다 지원 범위가 달라서, 예를 들어 Deflate raw 스트림을 기대하지 않는 도구에 넣으면 오류가 날 수 있습니다.
입력한 텍스트가 서버로 전송되나요?
아니요. 압축·압축 해제·Base64 변환 모두 브라우저의 Compression Streams API를 이용해 로컬에서 처리되며 서버로 전송되지 않습니다.
압축 해제 시 왜 가끔 "invalid header" 오류가 나나요?
가장 흔한 원인은 형식 혼동입니다: 헤더 없는 "원시" Deflate로 압축한 데이터를 (자체 헤더와 CRC-32를 기대하는) Gzip으로 압축 해제하려 하거나 그 반대의 경우입니다. 도구 설정에서 형식을 바꿔보세요.
압축은 항상 최종 크기를 줄여주나요?
아니요. 매우 짧은 문자열에서는 Gzip 헤더의 오버헤드와 Base64로 인한 크기 증가가 압축 이득보다 클 수 있습니다 — 이 방식은 충분히 크고 압축이 잘 되는 텍스트 데이터에서만 의미가 있습니다.