Bin Packing, Explained
After reading this you will know how many boxes, totes or trucks a pile of items needs, why the first-fit-decreasing heuristic almost always matches the true minimum on household-sized jobs, and how to read the fill percentages the calculator gives you.
What bin packing is, with one moving-day example
You have a stack of things to move and a pile of identical boxes. Each box holds a fixed amount: 20 kg, say, or 60 liters. The question is simple to ask and hard to answer well: how few boxes can you get away with, and what goes in each?
Here is a small case. Say six items weigh 8, 6, 4, 15, 7 and 3 kg, and each box holds 20 kg. The total is 43 kg. Divide by 20 and you get 2.15, so no arrangement uses fewer than 3 boxes. The calculator finds a packing into exactly 3 boxes, so 3 is both the answer and the proven best.
The reason this matters is that the gap is not always zero. Awkward sizes leave wasted space, and closing that gap by hand gets slow the moment you have more than a handful of items. That waste has a name: fragmentation.
When to use it, and when not
Reach for capacity mode whenever a single number caps each container: weight per moving box, volume per warehouse tote, payload per delivery run, minutes of talks per conference session. The item's one number is all that matters, and any item can share a bin with any other as long as the total fits.
Use 3D mode when shape decides the fit, not just total volume. A 40 by 30 by 10 board game will not go into a box that is 35 cm on its longest side, even if the box has plenty of volume left. The calculator checks that every item fits in some rotation and stacks by height layers.
The 3D result is an estimate, not a loading plan. Real packing with rotations and interlocking is far harder than any instant calculation. The tool guarantees each item genuinely fits the box in some orientation, but a patient human packer can often beat its box count. Treat the 3D number as an upper bound to sanity-check, not gospel.
Do not use it when items interact in ways a single number cannot capture: fragile things that cannot be stacked, liquids that cannot ride with electronics, or bins with two limits at once (both weight and volume). For those, pack the tighter constraint here and check the other by hand.
The heuristic and why it is close to optimal
Finding the true minimum is NP-hard, which means no known method solves large cases quickly. So the calculator uses first-fit decreasing (FFD): sort items biggest first, then drop each item into the first open bin that still has room. If none has room, open a new bin.
Sorting biggest first is the trick. Large items are the hard ones to place, so you place them while bins are empty and flexible. Small items then trickle into the gaps left behind. The worst-case guarantee is tight and known:
Here B_{FFD} is the bin count FFD produces and B_{OPT} is the true minimum. The ratio 11/9 \approx 1.222 means FFD never needs more than about 22% extra bins, even in a pathological worst case. On everyday inputs it usually hits B_{OPT} exactly.
The theoretical minimum itself is just the total divided by one bin's capacity, rounded up:
where v_i is each item's value and C is the bin capacity. This is a floor, not a promise: it assumes you could pour items like liquid and fill every bin to the brim. The gap between it and the FFD count is the fragmentation cost of real, indivisible items.
A worked example you can reproduce
Six categories into 20 kg boxes
This is the demo data. Capacity is 20, and the items expand by quantity into this list of weights:
Books 8×4, Kitchenware 6×3, Clothes 4×5, Toolbox 15, Lamp 7×2, Bedding 3×3. That is four 8s, three 6s, five 4s, one 15, two 7s and three 3s.
- Total the values.
4×8 + 3×6 + 5×4 + 15 + 2×7 + 3×3 = 32 + 18 + 20 + 15 + 14 + 9 = 108. - Theoretical minimum:
108 / 20 = 5.4, rounded up to6bins. - Sort biggest first:
15, 8, 8, 8, 8, 7, 7, 6, 6, 6, 4, 4, 4, 4, 4, 3, 3, 3. - Place each in the first bin that fits. The 15 opens bin 1 (room left 5). The first 8 opens bin 2, and so on down the list.
Following FFD to the end lands on the packing below. It uses 6 bins, matching the theoretical minimum, so it is provably optimal for this input.
| Bin | Items (weights) | Used | Free | Fill |
|---|---|---|---|---|
| 1 | 15, 4 | 19 | 1 | 95% |
| 2 | 8, 8, 4 | 20 | 0 | 100% |
| 3 | 8, 8, 4 | 20 | 0 | 100% |
| 4 | 7, 7, 6 | 20 | 0 | 100% |
| 5 | 6, 6, 4, 4 | 20 | 0 | 100% |
| 6 | 3, 3, 3 | 9 | 11 | 45% |
Five bins are full or nearly full; the leftover 45% bin is where the slack collects. Total used across bins is 108, which matches the input, so nothing was lost.
Watch capacity reshape the bin count
The single most instructive move is changing the bin size while the items stay fixed. Bigger bins do not always cut the count in proportion, because a large item can waste a large share of a large bin.
Reading the results
- Bin count
- How many containers FFD needed. This is your practical answer: buy this many boxes.
- Theoretical minimum
- The lower bound \lceil \sum v_i / C \rceil. If the bin count equals it, the packing is provably optimal.
- Fill percentage
- How full each bin is. A run of 100% bins and one low bin is normal and fine. It shows the slack collected in one place rather than being spread thin.
- Fragmentation cost
- Bin count minus theoretical minimum. In the demo it is
6 - 6 = 0. When it is 1 or 2, an awkward item mix, not the heuristic, is usually the cause.
A gap of zero does not mean you cannot repack by hand. It means you provably cannot do better. A gap of 1 means FFD might be one bin off the true optimum, though it usually is not; try nudging item sizes or capacity to see if the gap closes.
Common mistakes
Match your unit to one physical limit. If your boxes fill up by bulk long before they hit a weight limit, pack by volume in liters, not by kilograms. Packing the wrong constraint gives a valid answer to the wrong question.
The most frequent error is treating the theoretical minimum as achievable. It assumes items are pourable. With a single 15 kg item and 20 kg bins, that bin can never exceed 95% no matter what, because the only items that fit alongside are 4s and below and one 4 lands there.
A second error is expecting 3D volume to behave like capacity. Two items totaling 60% of a box's volume can still fail to fit if their shapes clash. Always trust the 3D fit check over the volume arithmetic.
A third is forgetting quantity syntax. In capacity mode Books, 8 x 4 means four separate 8 kg items, not one 32 kg item. If you wrote a single item you meant, drop the quantity.
Related planning tools
Packing answers a static question. For questions that unfold over time, other calculators fit better. If you want a probabilistic finish date from your actual weekly output, use the Monte Carlo Project Forecast. To find which tasks set a deadline, see the Critical Path (CPM/PERT) Calculator. To watch how a work-in-progress cap changes flow, the WIP Limits & Little's Law Simulator makes the effect visible. And when the hard part is choosing between options rather than packing them, the Weighted Decision Matrix scores them against your criteria.
Frequently asked questions
Why does the tool sometimes use more bins than the theoretical minimum?
Because items are indivisible. The minimum assumes you can split an item across bins to fill every one exactly. Real items cannot split, so awkward sizes leave gaps. That gap is fragmentation, and it is a property of your item set, not a flaw in the heuristic.
Is first-fit decreasing the best possible method?
No single quick method is best for every input, since the exact problem is NP-hard. FFD is guaranteed within about 22% of optimal and on small everyday jobs it usually hits the exact minimum. For the six-category demo it is provably optimal at 6 bins.
Can I trust the 3D box count for a real shipment?
Trust it as a realistic upper bound. It confirms every item fits the box in some rotation and stacks by height layers, so the count will not be wildly low. A careful packer who interlocks shapes may fit the same items in fewer boxes.
What if one item is bigger than a whole bin?
Then no packing exists, and the tool will tell you. In capacity mode an item heavier than the bin limit cannot go anywhere. In 3D mode an item that does not fit in any rotation is impossible. Increase the container size until every item fits alone.
Does item order in my input change the answer?
No. FFD sorts everything biggest first before packing, so the order you type items in does not affect the result. Only the values and the capacity matter.