TechStyle.JsonCompress
1.0.0
dotnet add package TechStyle.JsonCompress --version 1.0.0
NuGet\Install-Package TechStyle.JsonCompress -Version 1.0.0
<PackageReference Include="TechStyle.JsonCompress" Version="1.0.0" />
<PackageVersion Include="TechStyle.JsonCompress" Version="1.0.0" />
<PackageReference Include="TechStyle.JsonCompress" />
paket add TechStyle.JsonCompress --version 1.0.0
#r "nuget: TechStyle.JsonCompress, 1.0.0"
#:package TechStyle.JsonCompress@1.0.0
#addin nuget:?package=TechStyle.JsonCompress&version=1.0.0
#tool nuget:?package=TechStyle.JsonCompress&version=1.0.0
TechStyle.JsonCompress
Lossless JSON compression that is still JSON. No dependencies on .NET 8 and later, no binary framing, no code generation. Typically 45–75% smaller, and an exact round trip.
using System.Text.Json.Nodes;
using TechStyle.JsonCompress;
var users = JsonNode.Parse("""
[{"id":1,"name":"Ada","role":"admin","country":"United Kingdom"},
{"id":2,"name":"Bob","role":"admin","country":"United Kingdom"},
{"id":3,"name":"Cy", "role":"user", "country":"United Kingdom"}]
""");
var small = JsonCompressor.Compress(users);
// {"jc":1,"k":["id","name","role","country"],
// "d":{"~t":[0,1,2,3],"~e":[0,0,0,2],"~cv":["United Kingdom"],
// "~r":[[1,"Ada","admin"],[2,"Bob","admin"],[3,"Cy","user"]]}}
JsonCompressor.Decompress(small); // exactly the array you started with
What it does
JSON spends most of its bytes saying the same things over and over. A thousand
records is a thousand copies of every key name; a status column with three
possible values is a thousand copies of three short strings; a currency field
that is always "GBP" is a thousand copies of one. This writes each of those
down once.
| Key catalogue | Every key name is written once and referenced by a one- or two-character token. |
| Columnar tables | An array of like-shaped objects becomes a column list and a rows matrix. |
| Constant columns | A column whose value never changes is stored once. |
| Dictionary columns | A column drawn from a small set of strings becomes integer indices. |
| String catalogue | Any string value that repeats often enough to pay for itself is written once. |
The output is still ordinary JSON, so it goes anywhere JSON goes: an HTTP body,
a WebSocket frame, a jsonb column, a queue message, a log line.
What it measures
| Scenario | Minified | Compressed | Saved | + gzip | Saved |
|---|---|---|---|---|---|
| API record set (1,000 users) | 206.2 KB | 54.8 KB | 73% | 13.9 KB | 16% |
| Nested API response (orders with lines) | 96.5 KB | 39.9 KB | 59% | 9.8 KB | 3% |
| Time series (2,000 readings) | 166.7 KB | 44.3 KB | 73% | 12.4 KB | 13% |
| Structured logs (1,500 lines) | 237.3 KB | 57.3 KB | 76% | 21.8 KB | 9% |
| GeoJSON feature collection (400 points) | 58.9 KB | 31.6 KB | 46% | 7.2 KB | 3% |
| Config document (small, few repeats) | 3.1 KB | 2.2 KB | 29% | 0.5 KB | −24% |
Use it for record sets, logs, time series and API responses. For a small
document you already gzip it will not earn its keep — JsonCompressor.Measure
will tell you so before you commit.
The rest of the surface
Stringify/Parse— the same pair at the string level.CompressValue<T>/ParseValue<T>— for data that is not already aJsonNode.DecompressIfNeeded/IsCompressed— for a boundary you do not fully control.Measure— what compression would buy, with and without gzip.JsonCompressCodec— options bound once, safe to share across threads.Validate/Locate— where a JSON document breaks, with line and column.Minify/Beautify— whitespace only.TablePack— the columnar idea on its own, with no envelope.
One format, several languages
The wire format is specified in SPEC.md, and a document written here reads correctly in the JavaScript implementation — which is not a claim but a test, run against a corpus that encoder produced.
Full documentation: github.com/eharain/JSON-Compress/tree/main/dotnet
Licence
MIT. Built by Tech Style Ltd.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.5)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 65 | 8/18/2026 |
First release. Implements version 1 of the json-compress wire format.