Magnets in a 3D-printed lid: pocket fit, glue and holding force
By Sina Esfahani, OmniTechs · Published 30 November 2026
A magnetic lid needs three decisions: how each magnet stays in its pocket, which way round it goes, and how much plastic sits between the two magnets. The last one catches most people out: every tenth of a millimetre of wall costs holding force. Before you print the real box, print a small test strip with three pocket sizes and try your magnets in it. Then mark the polarity of every magnet while they are stacked together, before any glue comes out.
Do it in this order:
Measure several magnets with a calliper; the listed size has a tolerance.
Print a test strip with three pockets: magnet diameter + 0, + 0.15 and + 0.3 mm.
Choose press fit, glue or pause-and-embed from what the strip shows.
Stack all magnets, mark the top face of each and keep that face up in box and lid.
Find the gap that gives the closing force you want with paper shims, then set the wall thickness.
Glue with a magnet-friendly adhesive (not hot glue) and let it cure for 24 hours.
Keep loose magnets away from young children, and make sure none can fall out of the finished box.
Press fit, glued pocket or embedded: which suits your lid?
Three ways to hold a disc magnet in a printed lid
| Method | Gap between magnets | Choose it when | Watch out for |
|---|---|---|---|
| Press fit in an open pocket | Smallest: faces can sit flush | You want maximum force and can press magnets in after printing | Too tight cracks the wall; too loose lets the partner magnet pull it out |
| Glued in an open pocket | Smallest, if no glue rises above the magnet | The pocket is a loose fit, or the box must survive knocks | The wrong glue harms the coating or lets go; 24 hours curing |
| Embedded with a pause | Adds the printed skin over each embedded magnet | The magnet must be hidden or must never come out | Costs force; the print head can attract the magnet during the pause |
One thing to know about open pockets: when you lift the lid, the pull between the two magnets tries to drag each one out of its pocket. A flush magnet must therefore be held more firmly than the pair attract each other. An embedded magnet cannot be pulled out, which is why it costs force but never comes loose.
For embedding, follow the pause-at-height guide for magnets and nuts: it covers the layer that closes the pocket, the slicer menus and the right pause command. Two extra checks for magnets. Pass a magnet near the print head before you start, because people on the 3D Printing Stack Exchange report magnets jumping to steel bearings and a bed probe. And run the whole pause sequence once on a test strip, so a failed resume costs you a strip and not the box.
Side-loaded slots and printed retention clips avoid both glue and a pause. This video shows press-fit pockets, side-loaded slots and retention clips, with design rules at the end:
Print a three-pocket test strip first
Your printer decides the right pocket size. Holes in FDM prints usually come out smaller than modelled, and the magnets vary too: supermagnete lists its 10 × 3 mm disc (article S-10-03-N) at ±0.1 mm, so a "10 mm" magnet can measure 9.9 to 10.1 mm.
Measure five magnets and note the largest diameter (D) and the thickness.
Model a strip with three round pockets of D + 0, D + 0.15 and D + 0.3 mm, each 0.2 mm deeper than the magnet is thick. The + 0.3 mm pocket matches the 0.15 mm per side that the pause-at-height guide uses as a starting clearance.
Print it in the same material, layer height and orientation as the real lid.
Press a magnet into each pocket by hand, then turn the strip over and tap it on the table.
Reading the test strip
| What you see | What it means | What to do |
|---|---|---|
| Will not go in, or needs a clamp | Too tight; forcing it can crack the wall or chip the magnet | Use the next size up |
| Goes in with firm thumb pressure and stays when tapped | Press fit | Use it for open pockets, after the pull-out check |
| Drops in and falls out when tapped | Clearance fit | Use it for glued or embedded magnets |
| The wall around the pocket cracks or bulges | Wall too thin for a press fit | Thicken the wall or glue into a looser pocket |
Pull-out check: hold a second magnet against the press-fitted one and pull it away. If the pocketed magnet follows, glue it or embed it. A Stack Exchange answer suggests thin ribs inside a slightly oversized pocket instead of an undersized hole: they flex and grip without stressing the whole wall. The guide to tolerances and clearance shows how to measure holes and correct a model that prints them undersize.
Neodymium is brittle: supermagnete warns that colliding magnets can crack and throw sharp splinters. Press magnets in with a clamp or a flat block, not a hammer, and keep your fingers out from between two magnets.
Which glue for magnets in PLA or PETG?
supermagnete recommends UHU MAX REPAIR, an elastic polymer adhesive, for most hobby and workshop jobs, and two-part epoxy where strength matters more than flexibility. It advises against hot glue, because at roughly 150 to 200 °C it can demagnetise neodymium for good. It does not recommend superglue for a lasting bond either: many formulas attack the nickel coating, and cured superglue is no longer elastic, so a knock or a sideways pull can break the bond. A drop that stops an embedded magnet jumping out during a pause, as in the pause-at-height guide, is a different job: the printed skin holds the magnet after that. For printed parts glued to each other, superglue is a good choice, as the glue guide for PLA, PETG, ABS and TPU explains. Ordinary adhesives do not bond polypropylene, so test on an offcut if your box is not PLA or PETG.
Clean the magnet and the pocket of dust and grease.
Put a little glue in the pocket, not on the magnet's face.
Press the magnet in with its marked face the right way up (next section).
Wipe off any glue that rises above the magnet: it adds gap.
Keep magnets apart while the glue is wet, or they jump out and snap together.
Load the lid only after 24 hours of curing.
Check the polarity before the glue goes in
A lid whose magnets repel cannot be fixed once the glue has cured. You do not need to know which pole is north; every magnet only has to face the lid with the same pole.
Let all the magnets snap into one stack.
Put a marker dot on the top face of each magnet while it is still in the stack.
Fit every magnet, in box and lid, with the dot facing up when the lid is closed: the way it sat in the stack.
Dry-fit without glue, close the lid and feel that every pair attracts.
For embedding, mark the magnets before the print starts, so you can drop them in quickly during the pause.
How much holding force is left after the plastic wall?
Holding force falls steeply with distance. In supermagnete's words: "Even a small gap of half a millimetre can reduce the adhesive force by half." Its page for the 10 × 3 mm disc (S-10-03-N, grade N42) lists about 1.8 kg, measured against a 2 cm thick steel sheet, and includes a chart of force against air gap:
Holding force of a 10 × 3 mm N42 disc on a steel plate, by air gap
| Air gap | Approx. holding force | Share of the force at contact |
|---|---|---|
| 0 mm | 1.6 kg | 100 % |
| 1 mm | 0.5 kg | about a third |
| 2 mm | 0.2 kg | about a seventh |
| 3 mm | 0.1 kg | about 6 % |
| 5 mm | close to 0 | almost nothing |
Three things change these numbers for a lid:
Magnet to magnet. The chart is for a magnet on steel. supermagnete's free adhesive force calculator has a magnet-to-magnet mode for your own size, grade and gap.
Sideways force is far weaker. The same disc resists only about 360 g of sliding force. Give the lid a rim or lip that locates it, so the magnets only hold it down.
Listed values are maximums. supermagnete calls them theoretical maximums under ideal conditions; a slightly misaligned lid holds less.
Tune the gap with paper first
A Stack Exchange answer suggests the simplest method: put sheets of paper between the two magnets until the force feels right, then measure the stack.
Hold one magnet in the box and one in the lid, or simply in your fingers.
Add sheets of paper until opening the lid takes the effort you want.
Measure the stack with a calliper: that is your total gap budget.
Subtract the gap the lid's own fit leaves, then split the rest over the skins, rounded to whole layers.
Worked example: a box lid with 10 × 3 mm magnets (hypothetical)
These numbers are invented to show the method; use your own measurements.
Magnets: four 10 × 3 mm N42 discs, two in the box rim and two in the lid, measuring 10.05 mm.
Test strip: pockets of 10.05, 10.20 and 10.35 mm. The 10.20 mm pocket is a firm press fit, but a second magnet pulls the pocketed one out. The 10.35 mm pocket is a clean drop-in.
Paper test: the lid feels right with a 0.8 mm stack between the magnets.
Gap budget: the lid sits 0.2 mm above the rim, which leaves 0.6 mm for plastic: three layers at 0.2 mm.
Decision: the box magnets are embedded under a 0.6 mm skin in 10.35 mm pockets. The lid magnets are glued flush into 10.35 mm open pockets, dot up.
Check: after 24 hours, open and close the lid 20 times and tap it upside down. Nothing moves, and the lid opens with the effort from the paper test.
Contrasting case. Had the paper test called for 1.4 mm, both sets would be embedded under 0.6 mm skins, with the 0.2 mm fit gap making up the rest. Nothing would be exposed or glued, which also suits a box that small children can reach.
Damp rooms, heat and the coating
Most small neodymium discs are nickel-plated (Ni-Cu-Ni). supermagnete says standard neodymium magnets are not suitable for bathrooms or other damp rooms, and that moisture under the coating starts corrosion. Do not count on a printed skin as a seal: for a bathroom or outdoor box, use the fully coated neodymium or ferrite magnets that supermagnete suggests for damp places, and avoid scratching the coating when pressing magnets in.
Heat rarely limits the magnet in a printed box, because the plastic softens first: see the guide to PLA heat resistance. supermagnete rates grade N (such as N42) at 80 °C, M at 100 °C, H at 120 °C and SH at 150 °C, calls these reference points, and rates N52 at 65 °C. Flat discs lose strength sooner: it gives a 10 × 1 mm disc an actual limit of about 60 °C, while discs less than four times as wide as they are thick are not affected this way. No magnet supplier publishes data for printing hot plastic over a magnet, so compare the pull of an embedded magnet in your test strip with a loose one from the same batch.
Small magnets and children
This is general safety information, not medical advice. The UK Office for Product Safety and Standards (OPSS) warns that small, high-powered magnets present a risk of serious injury or death if two or more are swallowed, and advises keeping such products away from children. supermagnete's safety sheet says: "Children could swallow small magnets."
Keep loose magnets and test strips out of reach of young children while you work.
Make sure no magnet can come out of the finished box. Embedding is the most secure; repeat the pull-out check on glued or press-fitted magnets after curing and after a drop onto a hard floor.
OPSS names vomiting and stomach pain as possible signs. If you think a child has swallowed a magnet, get medical help immediately.
If the box is a toy or will be sold, more rules apply: the guide to product safety rules for selling 3D prints explains when toy safety law applies.
When to stop, and the next step
Redesign rather than reach for stronger magnets when:
the press-fit pocket cracks at every size: thicken the wall or switch to glue;
glued magnets come loose after 24 hours of curing: check the glue type, the cleaning and full contact under the magnet, as supermagnete advises;
the lid only holds at zero gap: use a larger or thicker magnet, or add a printed snap fit as a catch.
If you need a run of magnetic boxes, the OmniTechs small-batch page prints 10 to 500 pieces in PLA or PETG, asks how you want them delivered (loose, as sets, with agreed hardware or assembled) and makes a trial piece first where fit or function is uncertain.
Sources
supermagnete: Disc magnet Ø 10 mm × 3 mm, S-10-03-N (data and air-gap chart)
supermagnete: What factors affect the adhesive force of a magnet?
GOV.UK (OPSS): Product Safety Alert, small high-powered magnetic products
3D Printing Stack Exchange: How to add magnets to 3D print mid-print?
3D Printing Stack Exchange: Magnet strength for a tight seal on a box

