Measured result
Encoded size by fixture
Brotli quality 5 produced the smallest output for all three fixtures in this run. The medium catalog and large event batch were highly repetitive and compressed far more than the small response. These fixture-specific reductions are not a forecast for unrelated payloads.
| Fixture | Identity | gzip | gzip reduction | Brotli | Brotli reduction |
|---|---|---|---|---|---|
| Small API response3 records | 421 B | 271 B | 35.63% | 244 B | 42.04% |
| Medium service catalog120 records | 45,643 B | 2,541 B | 94.43% | 1,795 B | 96.07% |
| Large event batch1,200 records | 429,257 B | 26,368 B | 93.86% | 12,181 B | 97.16% |
Identity is the compact UTF-8 JSON body with no content encoding. Reductions compare encoded bytes with that fixture's identity bytes.
Methodology
Measure how encoded body size changes for three defined JSON fixture shapes when the same bytes are left uncompressed, compressed with gzip level 6, or compressed with Brotli quality 5 in text mode.
- Runs
- 30 per fixture and encoding
- Statistic
- Median encoded byte length
- Serialization
- JSON.stringify with UTF-8 encoding and no added whitespace
- gzip setting
- Node.js gzipSync, compression level 6, mtime 0
- Brotli setting
- Node.js brotliCompressSync, quality 5, text mode
- 1
Generate each fixture deterministically in memory with no random values or network input.
- 2
Serialize each fixture once with JSON.stringify and convert the resulting string to UTF-8 bytes.
- 3
Encode the same source buffer 30 times with identity, gzip, and Brotli.
- 4
Reject the run if an encoding produces different byte lengths across identical repetitions.
- 5
Report the median byte length and reduction from the uncompressed source for each fixture.
Fixed synthetic fixtures
The public runner generates these inputs from fixed values. Each SHA-256 identifies the exact compact UTF-8 source bytes measured in this run.
Small API response
A status envelope with pagination metadata and three compact user records.
3c8f8b8aad4bef9f7713ab3e154bea556e8547136cd0afa0d4ff1c0762278968
Medium service catalog
A 120-record service catalog with repeated keys, regions, tiers, labels, and limit structures.
24eefc284800094d8c9c3736c1c60554ed2449620e83caa8e8b41ceaa236f229
Large event batch
A 1,200-record event batch with recurring field names, event types, routes, regions, tags, and messages.
b063e1505e97ca08266ded82c2a210ce79ed6cc2dd00e13932b1997c9dc444fd
Recorded environment
- Runtime
- Node.js 18.20.8
- zlib
- 1.2.11
- Brotli
- 1.0.9
- Operating system
- Linux 5.14.0-687.5.4.el9_8.x86_64, x86_64
- Processor
- AMD EPYC 7713 64-Core Processor, 4 logical CPUs available
- Performed
Observations
- The small response compressed from 421 bytes to 271 bytes with gzip and 244 bytes with Brotli. At this scale, the absolute gap between the two compressed outputs was only 27 bytes.
- The medium catalog and large event batch repeated many keys and values, giving both encoders substantially more reusable structure than the small response.
- Brotli quality 5 was smaller than gzip level 6 for every fixture here, but this benchmark does not measure the extra CPU time, memory, or response latency needed to produce either representation.
- Compression behavior belongs to the exact source bytes and settings. A representative production fixture is more useful than applying these percentages to a different payload.
Limitations
- All three fixtures are synthetic. The catalog and event batch are intentionally structured and highly repetitive.
- The source is compact JSON. Pretty-printed JSON, encrypted fields, precompressed values, images, and high-entropy content can behave differently.
- This benchmark measures encoded byte length only. It does not compare compression time, decompression time, memory use, energy use, or end-to-end latency.
- Results apply to the recorded Node.js, zlib, Brotli, and encoder settings. Other implementations or quality levels can produce different output.
- Each fixture is compressed as one complete independent buffer. Streaming flushes, shared dictionaries, caches, headers, TLS, and protocol framing are outside the test.
- No claim is made about provider performance, universal encoder superiority, or the transfer savings of a production application.
Reproduce the run
The runner prints the environment, settings, fixture SHA-256 values, and raw result table as JSON. Runs on another environment should retain fixture hashes but can produce different compressed sizes.
node payload-compression.mjs
Runner SHA-2565084b9ff9380f8ccc53759665f804673e999ca8f01fe23c286514679ef97ae34
Specifications and runtime documentation
- Zlib API, Node.js 18.20.8 Node.js Documentation
- RFC 1952, GZIP file format specification RFC Editor
- RFC 7932, Brotli Compressed Data Format RFC Editor