
High-performance, schema-less serialization protocol merging JSON flexibility with binary compactness; dynamically deduces schemas with zero codegen, interns strings for global deduplication, offers positional JSON and ZigZag-varint binary encoding.
SQUASH is a high-performance, schema-less data serialization protocol designed to bridge the gap between the dynamic flexibility of JSON and the extreme density of binary formats like Protobuf.
By dynamically deducing schemas at runtime and utilizing aggressive string interning, SQUASH reduces JSON payload sizes by 50% to 68% with zero code generation or .proto files required.
Unlike rigid formats (gRPC/Protobuf) that require pre-compiled schemas, or naive binary formats (MessagePack/BSON) that repeatedly transmit string keys over the wire, SQUASH operates on a dynamic dictionary-based architecture.
When a payload is serialized:
{} overhead.Raw JSON (117 KB)
[
{"id": 1, "status": "active", "role": "admin"},
{"id": 2, "status": "active", "role": "user"}
]SQUASH v1 Positional (66 KB)
[["id", "status", "role", "active", "admin", "user"], [[1, 3, 4], [2, 3, 5]]](Notice the string keys and values are only transmitted once in the dictionary header).
SQUASH provides two distinct engines depending on your client constraints:
Designed for lightweight web clients where implementing a binary parser isn't feasible. SQUASH v1 flattens payloads into Positional Arrays.
JSON.parse() in the browser at near-binary compression rates, bypassing heavy memory allocations required for parsing large objects.Designed for native mobile apps (iOS/Android) and server-to-server microservices (Python/Kotlin). It serializes the flattened data into a custom byte stream.
Tests run on a standard dictionary mapping containing complex nested objects and arrays.
| Payload Type | Format | Size (KB) | Savings |
|---|---|---|---|
| Large Array (500 Objects) | Raw JSON | 117.0 | 0% |
| SQUASH v1 (Positional JSON) | 66.0 | 43.5% | |
| SQUASH v2 (Binary) | 38.0 | 67.5% | |
| Massive Dict (~500KB) | Raw JSON | 611.5 | 0% |
| MessagePack / CBOR | ~510.0 | ~16.0% | |
| SQUASH v2 (Binary) | 294.7 | 51.8% |
Protobuf requires defining .proto schemas, compiling code for every language, and distributing client SDKs. SQUASH is schema-less. It accepts dynamic dict or Map structures and compresses them on the fly.
MessagePack is a binary representation of JSON, but it still transmits the string keys for every single object in an array. SQUASH deduplicates keys globally, destroying MessagePack in array-heavy payloads.
SQUASH is not a silver bullet. It is purpose-built for specific scenarios:
Adding SQUASH to your backend is as simple as adding a single line of middleware. When a client sends the Accept-Encoding: squash header, the server automatically intercepts and compresses the JSON response.
from fastapi import FastAPI
from squash.middleware import SquashMiddleware
app = FastAPI()
# Transparently compress all outgoing JSON responses
app.add_middleware(SquashMiddleware, schema_name="api_default")
@app.get("/users")
def get_users():
return {"users": [...]} # Returns as compressed SQUASH!You can compress and debug payloads directly from your terminal:
$ pip install squash-protocol
$ squash encode payload.json -o payload.sqsh -v 2
✅ Encoded payload.json -> payload.sqsh using Squash v2
📦 Size: 117.00 KB -> 38.00 KB (Savings: 67.5%)SQUASH distributes native libraries via Maven Central for Kotlin Multiplatform, making integration seamless for mobile apps.
Android (OkHttp / Retrofit) SQUASH provides a drop-in OkHttp Interceptor. Simply add it to your network client, and it will transparently decompress binary SQUASH payloads back into standard JSON before your app even sees them!
import com.squash.android.SquashOkHttpInterceptor
val client = OkHttpClient.Builder()
.addInterceptor(SquashOkHttpInterceptor())
.build()iOS (Swift) For iOS, SQUASH compiles directly to a native framework. You can decompress payloads instantly:
import SquashCore
let engine = BinarySquashEngine()
let decodedJson = try engine.decompress(data: binaryPayload)/squash-core/ - Kotlin Multiplatform core library (JVM, iOS, Android, JS/Wasm)./squash-python/ - Python implementation, CLI, & FastAPI middleware./squash-sample/ - Example projects demonstrating client/server integration./docs/ - Formal Protocol Specifications.SQUASH is open-source and welcomes contributions! Please read our contributing guidelines before submitting pull requests.
SQUASH is a high-performance, schema-less data serialization protocol designed to bridge the gap between the dynamic flexibility of JSON and the extreme density of binary formats like Protobuf.
By dynamically deducing schemas at runtime and utilizing aggressive string interning, SQUASH reduces JSON payload sizes by 50% to 68% with zero code generation or .proto files required.
Unlike rigid formats (gRPC/Protobuf) that require pre-compiled schemas, or naive binary formats (MessagePack/BSON) that repeatedly transmit string keys over the wire, SQUASH operates on a dynamic dictionary-based architecture.
When a payload is serialized:
{} overhead.Raw JSON (117 KB)
[
{"id": 1, "status": "active", "role": "admin"},
{"id": 2, "status": "active", "role": "user"}
]SQUASH v1 Positional (66 KB)
[["id", "status", "role", "active", "admin", "user"], [[1, 3, 4], [2, 3, 5]]](Notice the string keys and values are only transmitted once in the dictionary header).
SQUASH provides two distinct engines depending on your client constraints:
Designed for lightweight web clients where implementing a binary parser isn't feasible. SQUASH v1 flattens payloads into Positional Arrays.
JSON.parse() in the browser at near-binary compression rates, bypassing heavy memory allocations required for parsing large objects.Designed for native mobile apps (iOS/Android) and server-to-server microservices (Python/Kotlin). It serializes the flattened data into a custom byte stream.
Tests run on a standard dictionary mapping containing complex nested objects and arrays.
| Payload Type | Format | Size (KB) | Savings |
|---|---|---|---|
| Large Array (500 Objects) | Raw JSON | 117.0 | 0% |
| SQUASH v1 (Positional JSON) | 66.0 | 43.5% | |
| SQUASH v2 (Binary) | 38.0 | 67.5% | |
| Massive Dict (~500KB) | Raw JSON | 611.5 | 0% |
| MessagePack / CBOR | ~510.0 | ~16.0% | |
| SQUASH v2 (Binary) | 294.7 | 51.8% |
Protobuf requires defining .proto schemas, compiling code for every language, and distributing client SDKs. SQUASH is schema-less. It accepts dynamic dict or Map structures and compresses them on the fly.
MessagePack is a binary representation of JSON, but it still transmits the string keys for every single object in an array. SQUASH deduplicates keys globally, destroying MessagePack in array-heavy payloads.
SQUASH is not a silver bullet. It is purpose-built for specific scenarios:
Adding SQUASH to your backend is as simple as adding a single line of middleware. When a client sends the Accept-Encoding: squash header, the server automatically intercepts and compresses the JSON response.
from fastapi import FastAPI
from squash.middleware import SquashMiddleware
app = FastAPI()
# Transparently compress all outgoing JSON responses
app.add_middleware(SquashMiddleware, schema_name="api_default")
@app.get("/users")
def get_users():
return {"users": [...]} # Returns as compressed SQUASH!You can compress and debug payloads directly from your terminal:
$ pip install squash-protocol
$ squash encode payload.json -o payload.sqsh -v 2
✅ Encoded payload.json -> payload.sqsh using Squash v2
📦 Size: 117.00 KB -> 38.00 KB (Savings: 67.5%)SQUASH distributes native libraries via Maven Central for Kotlin Multiplatform, making integration seamless for mobile apps.
Android (OkHttp / Retrofit) SQUASH provides a drop-in OkHttp Interceptor. Simply add it to your network client, and it will transparently decompress binary SQUASH payloads back into standard JSON before your app even sees them!
import com.squash.android.SquashOkHttpInterceptor
val client = OkHttpClient.Builder()
.addInterceptor(SquashOkHttpInterceptor())
.build()iOS (Swift) For iOS, SQUASH compiles directly to a native framework. You can decompress payloads instantly:
import SquashCore
let engine = BinarySquashEngine()
let decodedJson = try engine.decompress(data: binaryPayload)/squash-core/ - Kotlin Multiplatform core library (JVM, iOS, Android, JS/Wasm)./squash-python/ - Python implementation, CLI, & FastAPI middleware./squash-sample/ - Example projects demonstrating client/server integration./docs/ - Formal Protocol Specifications.SQUASH is open-source and welcomes contributions! Please read our contributing guidelines before submitting pull requests.