What Does Item Class Mean in Stacking Rules?
If you are reading the RSJ 3D Packer API docs and you hit the itemClass field, the description is short: an integer you attach to an item. That brevity is the problem. Nothing in the field name tells you what the number does, whether higher means heavier, whether it is required, or what happens if you leave it out.
Here is the short answer: an item class is a stacking permission. It is an integer label you assign to a type of item, and the solver will only ever place an item on top of items of a lower or equal class. That is the whole rule. Everything else — heavy at the bottom, fragile on top, keeping drums away from each other — is a pattern you build on top of that single comparison.
This article explains what that means in practice, how the solver applies it, and where people usually get it wrong.
The Plain-Language Answer: What Is an Item Class?
An item class is an integer label you assign to each item type in a packing request. It is not a measurement. It is not a category you read off the carton. It is a declaration you make: this item may be stacked on items of class N or lower.
The core rule, stated exactly as the solver applies it:
- An item may only be placed on items of a lower or equal class.
- A class 1 item can sit on class 0 or class 1 items. It cannot sit on class 2.
- A class 0 item can sit directly on the container floor, and it can sit on other class 0 items — but nothing can be placed on top of it by a higher-class rule violation… rather, nothing of a higher class can be placed on it. Wait, that is backwards.
Let me restate it cleanly, because this is exactly where readers get confused:
- A class 2 item (typically the fragile top-layer box) can only be placed on class 0, class 1, or class 2 items — anything at or below its own class.
- A class 0 item is unrestricted in the downward direction, but if you put a class 0 item on top of a class 2 item, you would be placing it on an item of a higher class, which the rule forbids.
So the ordering is: low class = goes at the bottom, high class = goes at the top. The solver walks upward through the class numbers as it stacks.
Two more things worth stating plainly:
- Class is not a physical property. Weight, width, height, depth, and
verticaldescribe the item.itemClassdescribes where the item is allowed to be placed. You could have two items of identical dimensions and weight and give them different classes if one is structurally stronger. - If you omit
itemClass, the solver treats the item as class 0. Class 0 is the default, which means it can go on anything and anything can go on it, subject to the other constraints in the request.
A Real-World Analogy: Why Stacking Order Needs Rules
Picture a warehouse pallet. Someone loads it by hand: steel plate on the bottom, wooden crates in the middle, cardboard cartons on top. Nobody wrote that down as an instruction, but everyone loading the pallet applies it, because a carton under a steel plate is a damaged product and a wasted pallet.
Now hand the same job to a solver that only knows dimensions. From a pure geometry standpoint, a box is a box. If the fragile carton happens to fit on the floor and the steel plate happens to fit on top of it, that is a perfectly valid packing plan — and a terrible one.
Item classes encode the instruction that the pallet loader carries in their head, without forcing you to model every physical interaction between every pair of items. You are not describing “this 12 kg box can support 40 kg but not 60 kg, and only if the load is centred.” You are describing “class 1 goes on class 0.”
That is deliberately coarse. It is also why it is useful: a two-digit field captures a stacking hierarchy that would otherwise take a table of pairwise compatibility rules.
Classes also compose with the dangerous-goods fields. If you have drums that must not be loaded together, that is handled by riskTypes and riskPoints — not by classes. But if one of those drums must also never end up underneath a pallet of something else, that is a class assignment. The two mechanisms are independent, and the solver respects both.
How Item Class Works in RSJ 3D Packer
itemClass is an optional integer field on each item in a POST /solve request. It sits alongside weight, vertical, riskPoints, and riskTypes in the optional item fields.
Because every packed item in a result is supported by the item below it — the plan contains no floating items — the class rule directly governs vertical placement. There is no “support” constraint separate from the class constraint that might let a class 2 item hover above a class 0 item with a gap; the solver builds the stack geometrically and applies the class comparison at each level.
A concrete hierarchy looks like this:
- class 0 — heavy base items. Steel, palletised base goods, anything that goes on the container floor.
- class 1 — medium items. Crates that can carry a load but should not sit on the floor if heavier goods are available.
- class 2 — light top items. Cartons that can be stacked on anything but must never have anything placed on them.
Notice the direction: the fragile carton is class 2, not class 0. Higher means higher in the stack. If you have spent time with priority systems where 0 is the most important value, this is worth reading twice.
Containers have an itemClass field too, and it works differently: it restricts which items may be loaded into that container at all. If a container is declared with a class, only items of that class or lower are eligible for it. That is useful when you are mixing container types and one of them — a lighter-duty container, for example — simply should not receive your heaviest class of item.
Why Item Class Matters for Your Packing Results
The tempting goal in container packing is maximum fill percentage. Classes are the counterweight to that instinct. A 76% fill that arrives intact beats a 94% fill that arrives as scrap, and the class field is how you tell the solver which of those two outcomes you want.
Where classes earn their keep:
- Structural safety. Items with different stacking strengths get placed in the right vertical order without you modelling load paths.
- Stability. A stack that respects a weight hierarchy from bottom to top is more likely to survive transit than one that merely fits.
- Combination with weight limits. Container
weightcaps the total load. ItemitemClasscontrols the vertical arrangement andvertical: falseprevents an item from being rotated out of its upright position. These three constraints stack independently, and a plan can satisfy all of them at once. - Mixed item sets. The more heterogeneous your load — different sizes, different weights, different fragility — the more a class hierarchy helps.
- Solve time. The solver works within a 240-second time budget per request. Classes are extra constraints, which sounds like they should slow things down, but a well-defined hierarchy prunes the space of valid arrangements and helps the solver converge on a feasible plan rather than exploring stacks you would reject anyway. The 240-second budget applies on every request, on every plan.
Common Misconceptions About Item Class
“Item class is the same as item type or SKU.”
No. Item class is a stacking permission, not an identifier. Two completely different products can share a class if they stack the same way, and one product line can span two classes if you stock it in a heavy variant and a light one. If you need to track your own identifiers, use the optional id field on items — it travels through to the result. See How to Verify a Container Load Plan Before Shipping for how those identifiers come back out.
“Higher class means heavier.” Higher class means higher in the stack. In the conventional pattern heavy items are class 0, so the correlation holds — but it is a convention you chose, not a rule the solver enforces. You could invert the numbering if you wanted to, as long as you are consistent. What matters is the ordering, not the values themselves.
“Classes are only for dangerous goods.”
Dangerous goods are handled by riskTypes, riskPoints, allowedRiskPoints, and the risks array that declares which risk type pairs must not be loaded together. Classes are a separate mechanism that applies to any stacking scenario, hazardous or not. A pallet of brick and a pallet of lightbulbs is a class problem.
“You have to use classes.”
They are optional. Leave itemClass out and everything is class 0, which is permissive. For a single homogeneous item type, that is fine. Classes become worth the five minutes of thought as soon as your load has a vertical hierarchy you care about.
How to Set Item Classes in Practice
Suppose you are packing three kinds of goods into a 48 × 47 × 46 container: heavy base crates, medium cartons, and light fragile boxes. The heaviest items get class 0, the medium ones class 1, and the fragile ones class 2.
{
"containers": [
{ "width": 48, "height": 47, "depth": 46, "count": 1 }
],
"items": [
{
"width": 11, "height": 6, "depth": 6, "count": 51,
"itemClass": 0,
"weight": 40
},
{
"width": 7, "height": 8, "depth": 9, "count": 53,
"itemClass": 1,
"weight": 12
},
{
"width": 8, "height": 9, "depth": 10, "count": 57,
"itemClass": 2,
"vertical": false
}
]
}
Read that request as three instructions:
- Class 0 crates can sit on the floor and on each other. Nothing in the request is classed below them, so they form the base of each stack.
- Class 1 cartons can be placed on class 0 or class 1 items. They will not appear underneath a class 0 crate.
- Class 2 fragile boxes can be placed on anything at class 2 or lower — but nothing at a lower class can be placed on top of them, and because they are class 2 the solver will push them toward the top of the arrangement.
The "vertical": false on the fragile boxes is a separate statement: they must not be rotated out of their upright position. Note that this field is available on the Standard and Pro plans, along with different container sizes and weight limits. If you are on the free 30-day test, you get the full Pro feature set during the trial, so you can experiment with all of it.
Send the request and the response tells you what happened:
packedItemslists each placed item with its container index (c) and itsx,y,zposition — that is your class compliance evidence, item by item.containersreportsusedandfilled, the fill percentage per container.unpackedItemslists anything that did not fit, with counts.- You also get a viewer URL and an API sandbox URL.
You can try this request in the API sandbox against the live service before writing any client code, or work in the web application with its interactive 3D view. Both are part of RSJ 3D Packer — the sandbox is a plain-JavaScript playground, and the web app renders the result so you can see the class ordering in three dimensions rather than inferring it from coordinates. The solution can also be downloaded as a GLB 3D model if you want to inspect it elsewhere.
One practical note on authentication, since you will need it for a scripted test: fetch a session via GET /user/{email}?hmac={hmac} and send it as a bearer token. Sessions last about a day, so fetch a fresh one instead of storing it. The browser application and sandbox authenticate with cookies instead, which is why you can click around without setting up a token.
FAQ
What happens if I don’t specify an itemClass?
If you omit itemClass, the solver treats the item as class 0 by default. This means it can be placed on any other item, and any item can be placed on it, unless other constraints apply.
Can I use itemClass to enforce a specific stacking order? Yes. By assigning lower classes to items that must go at the bottom and higher classes to items that must go on top, you control the vertical stacking order. The solver will only place an item on items of a lower or equal class.
Does itemClass affect horizontal placement?
No. itemClass only restricts vertical stacking — which items can be placed on top of which. Horizontal placement is determined by the solver’s packing algorithm and other constraints like container dimensions.
How does itemClass interact with dangerous goods risk types?
itemClass and risk types are independent constraints. itemClass controls stacking order, while risk types and risk points control which items can be loaded together in the same container. Both are respected by the solver.
Conclusion
An item class is one integer that answers one question: what is this item allowed to sit on? Lower classes form the base of a stack, higher classes sit on top, and the default is 0 when you say nothing. It is optional, it is not a physical property, and it is the cheapest way to stop a solver from building a geometrically valid plan that a warehouse worker would never build by hand.
Start with three classes if your load has an obvious heavy/medium/light split, and use container itemClass when some containers should not receive your heaviest goods at all. Then check the result in the 3D viewer — the packedItems positions tell you exactly how the hierarchy played out.
RSJ 3D Packer solves 3D bin packing on fixed containers and pallets with classes, weight limits, rotation control and dangerous-goods rules as first-class inputs, and it returns positions, fill percentages, unpacked items and a viewer URL in a single call. Every plan can be tested free for 30 days, and the free test exposes the Pro feature set. Try it on your own packing data or compare plans on the pricing page.
Related posts
- 3D Bin Packing vs Manual Loading: Which Gets It Right First?
- How Better Container Packing Reduces Shipping Costs
- How to Verify a Container Load Plan Before Shipping