I recently came up with a useful tool for my Airtable toolkit, and I thought I would share it in case others may find useful.
On a recent project, I needed to transform a large amount of data into a JSON object for use by external applications. Unfortunately, I quickly ran up against Airtable’s 100,000 character limit on text fields. It occurred to me that if I could find a way to compress the JSON data, I could fit more data into a cell and wouldn’t have to worry about the character limit.
There are a handful of javascript libraries out there for text compression, but what I settled on using is the lz-string.js library. It is based on LZW compression, and was designed for use on mobile browsers, meaning that it is fast, and optimized enough to use in Airtable Automations without going over the CPU time caps. Due to its repetitive nature, JSON data compresses very well—results will vary depending on the structure of your data, but with my current data I’m able to fit the equivalent of 900,000 characters in a cell, rather than 100,000.
Consider this a proof of concept—if you need to access this data from outside of Airtable you’ll need to find a way to decompress it (FWIW, this library has been ported to a number of different languages). There are some other javascript compression libraries out there that may be more interoperable, but for my use case this was the easiest to set up. I’m using this data for generating printed documents on demand, so I do the decompression from within an app.
I implemented the scripts as automations so that I could benchmark them, but it’s just as easy to implement them in an app. Here are the scripts, I trigger them off of the “Run Compression” and “Run Decompression” checkboxes. Just clear out all the cells to the right of the “Data” column to see the results of running the compression scripts yourself.