diff --git a/toolkit/modules/JSONFile.sys.mjs b/toolkit/modules/JSONFile.sys.mjs
index 397991e4af8f49b6365d729fc11267b5c1113400..1955b7ff1d428e891f5ef066e7a4ac25aa5ec9b4 100644
--- a/toolkit/modules/JSONFile.sys.mjs
+++ b/toolkit/modules/JSONFile.sys.mjs
@@ -132,6 +132,7 @@ export function JSONFile(config) {
     this._finalizeInternalBound,
     () => ({ sanitizedBasename: this.sanitizedBasename })
   );
+  this._useSizeHints = config.useSizeHints ?? false;
 }
 
 JSONFile.prototype = {
@@ -423,11 +424,15 @@ JSONFile.prototype = {
     }
 
     try {
-      await IOUtils.writeJSON(
+      if (this._useSizeHints && this._lastSavedSize) {
+        this._options.lengthHint = this._lastSavedSize;
+      }
+      const result = await IOUtils.writeJSON(
         this.path,
         this._data,
         Object.assign({ tmpPath: this.path + ".tmp" }, this._options)
       );
+      this._lastSavedSize = this._useSizeHints ? result.jsonLength : null;
     } catch (ex) {
       if (typeof this._data.toJSONSafe == "function") {
         // If serialization fails, try fallback safe JSON converter.
