Fastest possible Javascript object serialization with Google V8

I made a recent (2020) article and benchmark comparing binary serialization libraries in JavaScript.

The following formats and libraries are compared:

  • Protocol Buffer: protobuf-js, pbf, protons, google-protobuf
  • Avro: avsc
  • BSON: bson
  • BSER: bser
  • JSBinary: js-binary

Based on the current benchmark results I would rank the top libraries in the following order (higher values are better, measurements are given as x times faster than JSON):

  1. avsc: 10x encoding, 3-10x decoding
  2. js-binary: 2x encoding, 2-8x decoding
  3. protobuf-js: 0.5-1x encoding, 2-6x decoding,
  4. pbf: 1.2x encoding, 1.0x decoding
  5. bser: 0.5x encoding, 0.5x decoding
  6. bson: 0.5x encoding, 0.7x decoding

I did not include msgpack in the benchmark as it is currently slower than the build-in JSON library according to its NPM description.

For details, see the full article.


For serialization / deserialization protobuf is pretty tough to beat. I don't know if you can switch out the transport protocol. But if you can protobuf should definitely be considered.

Take a look at all the answers to Protocol Buffers versus JSON or BSON.

The accepted answer chooses thrift. It is however slower than protobuf. I suspect it was chosen for ease of use (with Java) not speed. These Java benchmarks are very telling.
Of note

  • MongoDB-BSON 45042
  • protobuf 6539
  • protostuff/protobuf 3318

The benchmarks are Java, I'd imagine that you can achieve speeds near the protostuff implementation of protobuf, ie 13.5 times faster. Worst case (if for some reason Java is just better for serialization) you can do no worse the the plain unoptimized protobuf implementation which runs 6.8 times faster.