diff --git a/geomagio/api/ws/algorithms.py b/geomagio/api/ws/algorithms.py
index eaf58451a4cc27c17ef1d3c4a2396e32a2fc7cfc..1ee093dcbc4e89b7661ef0890355248c4eade8fc 100644
--- a/geomagio/api/ws/algorithms.py
+++ b/geomagio/api/ws/algorithms.py
@@ -47,6 +47,11 @@ def calculate_residual(reading: Reading, adjust_reference: bool = True):
         calculated = calculate(
             reading=reading, adjust_reference=adjust_reference
         ).json()
-        return json.loads(calculated.replace("NaN", "null"))
+        return json.loads(
+            # replace non-JSON compliant float values with null string
+            calculated.replace("NaN", "null")
+            .replace("-Infinity", "null")  # must replace "-Infinity" before "Infinity"
+            .replace("Infinity", "null")
+        )
     except ValueError as e:
         raise HTTPException(status_code=400, detail=str(e))