Small dependency-free packaging calculators for ecommerce, warehouse, and fulfillment workflows.
This package is useful when a checkout, warehouse tool, or agent needs to:
- calculate dimensional weight for UPS, FedEx, USPS, or custom divisors
- normalize item and carton dimensions
- check whether an item fits in a carton with padding
- rank cartons by fit efficiency
Packrift also hosts interactive versions of these workflows:
- Dimensional weight calculator: https://packrift.com/pages/dimensional-weight-calculator
- Box size calculator: https://packrift.com/pages/box-size-calculator
- Packaging cost calculator: https://packrift.com/pages/packaging-cost-calculator
npm install @packrift/packaging-utilsimport {
calculateDimensionalWeight,
cartonFitsItem,
rankCartonsByFit
} from "@packrift/packaging-utils";
const dimWeight = calculateDimensionalWeight({
length: 16,
width: 12,
height: 8,
divisor: 139
});
const fits = cartonFitsItem(
{ length: 10, width: 6, height: 4 },
{ length: 12, width: 8, height: 6 },
{ padding: 1 }
);
const ranked = rankCartonsByFit(
{ length: 10, width: 6, height: 4 },
[
{ id: "12x8x6", length: 12, width: 8, height: 6 },
{ id: "14x10x8", length: 14, width: 10, height: 8 }
],
{ padding: 1 }
);Returns dimensional weight in pounds. divisor defaults to 139, a common domestic parcel divisor. roundUp defaults to true.
Returns whether an item can fit inside a carton after applying padding. Dimensions are rotation-aware, so the item can be turned to find a valid orientation.
Returns fitting cartons sorted by unused volume, smallest first.
MIT