Staaarter

CSV Compressor

Compresses CSV text using the browser-native CompressionStream("gzip") API, producing genuine, RFC 1952-compliant gzip bytes downloadable as a .csv.gz file, with a base64 copy of the compressed bytes shown for text-panel copying alongside honest before/after size numbers. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-29
By Staaarter Team
csvcompressiongzip

Overview

Introduction

Large CSV exports, transaction logs, data dumps, generated test files, can get unwieldy to store or send as plain text. This tool compresses CSV text into a real gzip file entirely inside your browser.

It's not a cosmetic "shrink the text" trick, it's the same DEFLATE-based algorithm the standard gzip utility uses, wrapped with an honest before/after size comparison.

What Is CSV Compressor?

A CSV-to-gzip compressor built on the Web Platform's native CompressionStream("gzip") API, which produces byte-for-byte standard gzip output.

Because the compressed result is binary, the tool also base64-encodes it for display and copying in a text panel, while the actual downloadable file is the real, unmodified gzip bytes.

How CSV Compressor Works

The CSV text is UTF-8 encoded to bytes, then piped through CompressionStream("gzip") via a ReadableStream/Response pipeline, producing a genuine gzip byte stream with header, DEFLATE payload, and CRC32 trailer.

Those bytes are offered for download as a .csv.gz file (application/gzip), and separately base64-encoded (in fixed-size chunks, to avoid call-stack limits on large files) for the copyable text panel.

When To Use CSV Compressor

Use this when you want to shrink a large CSV before storing or transmitting it, and need a real, standards-compliant .gz file rather than a text gimmick.

It's also useful for demonstrating how much a given CSV's structure (repeated values, sequential IDs) actually compresses.

Features

Advantages

  • Produces genuine gzip output, verifiable by decompressing it with any standard gzip-aware tool.
  • Runs entirely client-side using a native browser API, your CSV data never leaves your machine.
  • Shows honest original-vs-compressed byte counts, including the (rare) cases where compression doesn't help.

Limitations

  • The copyable text panel holds a base64 encoding of the compressed bytes, not the raw gzip file itself, use the dedicated download button for the real .csv.gz.
  • Very short or already-random-looking CSVs may not shrink, and can grow slightly due to gzip's fixed per-file overhead.

Examples

Compressing a repetitive CSV

Input

id,status
1,active
2,active
3,active
4,inactive

Output

(real .csv.gz download, plus a base64 text copy of the same bytes)

Repeated values like "active" give DEFLATE's dictionary matching real structure to exploit, so the compressed file is meaningfully smaller.

Best Practices & Notes

Best Practices

  • Check the reported compressed-vs-original size before assuming compression helped, for small CSVs it sometimes doesn't.
  • Use the download button, not the base64 text panel, whenever you need the actual .gz file to send or store.
  • Reach for this on genuinely large CSVs, thousands of rows or more, where gzip's savings are most meaningful.

Developer Notes

Uses `new CompressionStream("gzip")` piped through a `ReadableStream`/`Response`, identical to the pattern used elsewhere in this codebase (the `list` category's List Compressor), producing real RFC 1952 gzip bytes; base64 encoding is done in 0x8000-byte chunks via `String.fromCharCode(...)` to avoid exceeding the JS engine's call-stack argument limit on large files.

CSV Compressor Use Cases

  • Shrinking a large CSV export before archiving or transmitting it
  • Producing a .csv.gz test fixture for a service or script that needs to handle gzip-compressed CSV input
  • Demonstrating real gzip compression ratios for CSV data with different amounts of repetition

Common Mistakes

  • Copying the base64 text panel and expecting it to be directly openable as a .gz file, decode it back to bytes first, or just use the download button.
  • Assuming every CSV shrinks meaningfully, compression ratio depends entirely on how repetitive the data is.

Tips

  • If you need maximum compression, sort or group similar rows together first, it can improve DEFLATE's ability to find repeated patterns.
  • Pair with CSV Size Optimizer first (to strip unneeded quotes and blank lines) before compressing, for an even smaller final file.

References

Frequently Asked Questions