back

by KilledByAPixel·6y ago·view on hn ↗
Encoding to base64 increases the size by at least 33%. This is to help make links small enough to share on places like twitter, dischord etc where the max length is around 4000 bytes.
2 comments
If you compress the json first, it isn't quite so bad.

Example #1 (short string):

  input: 103 bytes
  gzip(input): 87 bytes
  base64(gzip(input)): 117 bytes
Example #2 (long string):

  input: 3122 bytes
  gzip(input): 840 bytes
  base64(gzip(input)): 1121 bytes
Thanks, that is good reference. It makes sense that Zip would beat out JSON for longer strings. Just as another point of comparison, how about encodeURIComponent(gzip(input))?
This project also blows up the size and it seems by much more than 33% on average. You'd safe some space by using base64.