DEV Community

Cover image for Under the Hood: Building an Aquarium Volume & Weight Calculator with JavaScript
kandz
kandz

Posted on Originally published at tools.kandz.me

Under the Hood: Building an Aquarium Volume & Weight Calculator with JavaScript

Most aquarium hobbyists think a "55-gallon tank" weighs roughly 460 lbs (55 Γ— 8.34 lbs per gallon). In reality, once you add the glass, substrate, rock work, and equipment, that same tank can easily exceed 700 lbs. If you're placing it on a second-floor joist system, that difference matters.

In this tutorial, we'll build the calculation logic behind an aquarium weight calculator using vanilla JavaScript. We'll cover internal vs. external volume, substrate displacement, material density, and floor load per square foot (PSF).


The Logic

  1. Internal Volume: Subtract wall and bottom thickness from external dimensions to find actual water capacity.
  2. Substrate Displacement: Sand and gravel occupy physical space at the bottom, displacing water. A 3-inch sand bed in a large tank can displace 10+ gallons.
  3. Material Weight: Glass and acrylic have different densities. We approximate panel weight using surface area and average thickness.
  4. Floor Load: Divide total system weight by the tank's external footprint to get PSF. Residential floors are often rated around 40 PSF live load; concentrated aquarium loads frequently exceed 100 PSF.

The Code

const DENSITY = {
  // lbs per cubic inch
  WATER_FRESH: 0.0361, // ~8.34 lbs/gal
  WATER_SALT: 0.0372,  // ~8.55 lbs/gal
  GLASS: 0.094,
  ACRYLIC: 0.043,
  SUBSTRATE: {
    GRAVEL: 0.055, // ~95 lbs/ftΒ³
    SAND: 0.072,   // ~125 lbs/ftΒ³
    AQUASOIL: 0.035,
    NONE: 0
  }
};

const CU_IN_PER_GAL = 231;

function calculateAquariumWeight({
  length,          // external inches
  width,           // external inches
  height,          // external inches
  wallThickness = 0.375,
  bottomThickness = 0.5,
  material = 'GLASS',
  substrateDepth = 2,      // inches
  substrateType = 'GRAVEL',
  waterType = 'FRESH',
  equipmentLbs = 0,
  hardscapeLbs = 0,
  standLbs = 0
}) {
  // 1. Internal dimensions
  const iL = length - 2 * wallThickness;
  const iW = width - 2 * wallThickness;
  const iH = height - bottomThickness;

  // 2. Volumes (cubic inches)
  const internalVol = iL * iW * iH;
  const substrateVol = iL * iW * substrateDepth;
  const waterVol = Math.max(0, internalVol - substrateVol);

  // 3. Tank material weight (approximate panel surface area)
  const panelArea = 2 * (height * length) + 2 * (height * width) + (length * width);
  const avgThickness = (4 * wallThickness + bottomThickness) / 5;
  const tankWeight = panelArea * avgThickness * DENSITY[material];

  // 4. Fluid and substrate weights
  const waterWeight = waterVol * DENSITY[`WATER_${waterType}`];
  const substrateWeight = substrateVol * DENSITY.SUBSTRATE[substrateType];

  // 5. Totals and floor loading
  const totalWeight = tankWeight + waterWeight + substrateWeight + equipmentLbs + hardscapeLbs + standLbs;
  const footprintSqFt = (length * width) / 144;
  const loadPSF = totalWeight / footprintSqFt;

  return {
    breakdown: {
      tank: Math.round(tankWeight),
      water: Math.round(waterWeight),
      substrate: Math.round(substrateWeight),
      extras: Math.round(equipmentLbs + hardscapeLbs + standLbs)
    },
    totalWeightLbs: Math.round(totalWeight),
    waterVolumeGallons: Number((waterVol / CU_IN_PER_GAL).toFixed(1)),
    loadPSF: Number(loadPSF.toFixed(1)),
    isStructuralConcern: loadPSF > 100
  };
}

// Example: 48" x 18" x 21" glass tank, 3" sand bed, saltwater
const myTank = calculateAquariumWeight({
  length: 48,
  width: 18,
  height: 21,
  material: 'GLASS',
  substrateDepth: 3,
  substrateType: 'SAND',
  waterType: 'SALT',
  equipmentLbs: 45,
  hardscapeLbs: 60,
  standLbs: 80
});

console.log(myTank);
// Example output:
// {
//   breakdown: { tank: 145, water: 535, substrate: 140, extras: 185 },
//   totalWeightLbs: 1005,
//   waterVolumeGallons: 64.2,
//   loadPSF: 193.4,
//   isStructuralConcern: true
// }
Enter fullscreen mode Exit fullscreen mode

Key Takeaways

  • Displacement matters: Substrate isn't just added weightβ€”it removes water volume.
  • Material matters: A glass tank weighs more than twice as much as an equivalent acrylic tank.
  • Floor loading: A ~1,000 lb system on a 6 sq ft footprint creates ~193 PSF, well above typical residential live-load ratings.

If you don't want to maintain this math yourself, the production-ready implementation powering these calculations is available here:

πŸ”— Aquarium Tank Volume & Water Weight Calculator
https://tools.kandz.me/aquarium-volume-weight-calculator

Top comments (0)