The comparison base currently contains over 160 different methods of compressing objects into strings and corresponding scripts to test those methods regarding performance and compression rate.
You can find the latest test results over here: serialize-comparison.jaid.codes
The most efficient way of compressing objects turned out to be
json5 as serializer and
brotli as compression algorithm. The Brotli compressor performs pretty fast and gives insane compression results for a wide spectrum of input data.
const data = a: "a" b: 2const jsonBin = Bufferconst compressed = Buffer// compressed = "CwWAe2E6J2EnLGI6Mn0D"
The search is not over
The CLI script runs the tests locally and prints the top 10 (regarding compression ratio) as an ansi-colored table.
yarn global add serialize-comparisonserialize-comparison
npm install --global serialize-comparisonserialize-comparison