Pouring concrete is expensive.
If you order too little, the pour fails and you have to start over. If you order too much, you're throwing money away on a heavy truckload.
Let's look at how to automate the calculation for slabs and post holes using JavaScript.
The Math (Step-by-Step)
-
Calculate Volume for Slabs:
Length (ft) Γ Width (ft) Γ Thickness (ft) = Cubic Feet(Divide thickness in inches by 12 to get feet) -
Calculate Volume for Post Holes:
Ο Γ RadiusΒ² Γ Depth = Cubic Feet(Divide diameter in inches by 2, then by 12 to get radius in feet) -
Divide by Bag Yield:
- 40 lb bag = ~0.30 cu ft
- 60 lb bag = ~0.45 cu ft
- 80 lb bag = ~0.60 cu ft
The JavaScript Solution
Here is how you write a function to calculate this automatically, including a 10% waste factor for uneven ground and spillage:
function calculateConcrete(shape, options) {
let cubicFeet = 0;
if (shape === 'slab') {
const { length, width, thicknessInches } = options;
const thicknessFt = thicknessInches / 12;
cubicFeet = length * width * thicknessFt;
}
else if (shape === 'postHole') {
const { diameterInches, depthFt, quantity } = options;
const radiusFt = (diameterInches / 2) / 12;
const volumePerHole = Math.PI * Math.pow(radiusFt, 2) * depthFt;
cubicFeet = volumePerHole * quantity;
}
// Add 10% waste factor
cubicFeet *= 1.10;
// Bag yields in cubic feet
const yields = { 40: 0.30, 60: 0.45, 80: 0.60 };
return {
cubicFeet: Number(cubicFeet.toFixed(2)),
bags40: Math.ceil(cubicFeet / yields[40]),
bags60: Math.ceil(cubicFeet / yields[60]),
bags80: Math.ceil(cubicFeet / yields[80]),
};
}
// Example: 10x10 slab, 4 inches thick
const result = calculateConcrete('slab', { length: 10, width: 10, thicknessInches: 4 });
console.log(`You need ${result.bags80} bags of 80lb concrete.`);
// Output: You need 61 bags of 80lb concrete.
Common Gotchas
-
Floating Point Math:
Math.ceil()is critical. You cannot buy half a bag of concrete. If the math says55.1, you must buy56. - Water Ratio: The yield estimates assume you mix with the exact right amount of water. Adding too much water to make it easier to pour will weaken the concrete and cause it to shrink.
- Weight Limits: 61 bags of 80lb concrete weigh 4,880 lbs. This will destroy the suspension of a standard pickup truck. Have it delivered or rent a heavy-duty trailer.
The Visual Way
Calculating cubic feet for slabs, converting inches to feet, and figuring out cylindrical volume for post holes can get confusing.
If you want to calculate cubic yards and pre-mix bag counts (40lb, 60lb, 80lb) for slabs, post holes, and cylindrical footings, I built a free Concrete Slab & Footing Calculator.
100% client-side. Nothing uploaded.
Have you ever run out of concrete halfway through a pour? Let me know in the comments.
Top comments (0)