Print a keychain pill box: screw-top capsule with lug
A keychain pill box that stays shut
A small screw-top capsule on your keyring is handy: the emergency pill, a coin for the shopping cart or a spare hearing-aid battery is always with you. This generator prints exactly the size you need. You set the inside diameter and height, choose thread and lug, and can label the cap. For ready-made ideas, browse the examples, from the classic pill box to a tube for toothpicks.
The capsule has two parts: a base with a threaded neck and a cap that screws on. Both sit on one plate, the base on its floor and the cap on its top face. The cap carries the lug for the split ring on its rim. At the default size the whole job is about 2 g of filament and just over ten minutes of printing.
How the generator works
Everything runs in your browser. Nothing is uploaded, and your design lives entirely in the link you copy with “Share”. The preview shows base and cap side by side, just as they print. Change a value, the preview rebuilds in a fraction of a second, and the download button gives you STL or 3MF.
The model is based on the customizable key chain pill box by DrJones, an OpenSCAD design. The layout, the dimensions, the lug and the grip notches come from there. The thread is different: the original turns an eccentric circle, with flanks about 38° from horizontal. Here the thread has a saw-tooth profile whose steep flank is 60° on the side that would otherwise hang in the air. That is why the neck prints without supports.
Finding the right size
Start with what has to go inside. Measure its diameter and height, add about 1 mm of room and enter both as “Inside diameter” and “Inside height”. The ranges are 6–60 mm for the diameter (default 18.5 mm) and 3.5–60 mm for the height (default 6.5 mm). They describe the usable cavity of the closed capsule, not the outside. The outer sizes and the volume in milliliters appear in the “Capsule details” panel.
| Contents | Inside diameter | Inside height | Example |
|---|---|---|---|
| Small pills | 18.5 mm | 6.5 mm | Pill box |
| Five 2-euro coins | 26.5 mm | 11.5 mm | Emergency coins |
| Shopping cart token | 24.5 mm | 3.5 mm | Token capsule |
| microSD cards | 19.5 mm | 5 mm | microSD capsule |
| Hearing aid batteries | 8.5 mm | 22 mm | Battery tube |
| Nano SIM | 16 mm | 3.5 mm | SIM capsule |
The capsule does not have to be flat. With an inside height of 45 mm it becomes a tube for a rolled-up banknote, and with 60 mm a toothpick case. For tall tubes use a longer thread and a taller base so the cap has something to grip.
All settings
Size
Besides the two inside dimensions you set “Base height” (1.5–50 mm, default 1.5 mm), “Wall” (0.8–2.4 mm, default 0.8 mm) and “Floor and top” (0.8–3 mm, default 0.8 mm). A taller base is easier to hold. The cap always keeps room for at least one turn, so the generator limits the base height and tells you when it does. A 0.8 mm wall is two lines with a 0.4 mm nozzle. For heavy contents such as coins, use 1 to 1.2 mm.
Thread
“Pitch” (1.5–3 mm, default 2 mm) is the travel per turn. Large pitches open quickly and forgive inaccuracy; small ones hold better on short necks. “Thread length” (2–10 mm, default 3.5 mm) sets how deep the cap engages. The inside height limits it, and you get a notice if it ends up shorter than you asked for.
The most important knob is “Tolerance” (0.1–0.5 mm, default 0.25 mm), the play between the threads on each side. If the cap binds, raise it; if it wobbles, lower it. On a very well calibrated printer you can lower it a little, and with a material that swells a lot you should raise it.
Keyring
“Keyring lug” switches the lug on the cap on or off. Without it the cap stays round. “Hole diameter” (2–10 mm, default 4 mm) fits the split ring or a cord, and “Lug height” (1.7–10 mm, default 5 mm) sets how thick the lug is. It never gets taller than the cap, and the hole stays smaller than the cap is wide. You see a warning in both cases.
Grip
Under “Grip” you choose “Notches” or “Smooth”. The notches run around the base and help when your fingers are wet or cold. On very small capsules such as the nano SIM capsule, smooth walls look calmer.
Parts
“Parts” prints “Both”, “Base only” or “Cap only”. That is useful for a spare cap, or to test the thread on a small sample first.
Label on the cap
Under “Label” you enter up to 12 characters, pick a “Font” or upload your own font file, which stays in your browser. The text size fits the cap automatically. The cap’s top face lies on the bed while printing, so the lettering sits in a smooth surface. There are two styles:
- Engraved: the text is cut into the cap and stays in the cap’s color. To print without supports, the letters are at most 5 mm tall and only a 0.6 mm band along the outline of the letters is cut out. It looks like a fine outline and reads well for short words such as “SD” or “PILLS”.
- Flush: the letters are filled completely with their own color in the first layers. There is no size limit here. The model for it is the “MEDS” example with white text on a red cap.
“Depth” (0.2–1.2 mm, default 0.4 mm) sets how deep the text goes into the cap top. At least 0.4 mm of material always remains above it, so a deeper label needs a thicker “Floor and top”. That is why the examples with a label use 1 to 1.2 mm.
The idea of putting the label into the face that lies on the bed comes from the TravelTonie capsule by Vanix.
Colors and multi-material
Under “Colors” there are three slots: “Base”, “Cap” and “Label”. If you leave “Cap” empty, it takes the color of the base, and an empty “Label” takes the cap color. For a two-color capsule you only set a second color for the cap. If you have a single extruder, print the base and the cap one after the other: choose “Base only” and then “Cap only” under “Parts” and use a different filament for each run.
For printers with a multi-material setup there are three formats: “Multi-color 3MF (PrusaSlicer)” for MMU3, XL and Core One, “3MF (Bambu Studio / OrcaSlicer)” for the AMS, and “STL per color (ZIP)” as a fallback. A flush label in its own color sits in the first layers of the cap, which is where the printer changes color. Without a multi-material setup the label therefore stays engraved and in the cap’s color.
Printing tips
- Orientation: both parts are already oriented as they print. Don’t rotate them in the slicer.
- Layer height: 0.2 mm is enough, and the measurements below come from that profile. Finer layers make the thread a bit smoother but take longer.
- Nozzle: a 0.4 mm nozzle is ideal. The thread and the walls are designed for it.
- Material: PLA is the easiest; PETG is tougher. For medication and food, check for yourself that the material is suitable.
- Supports: not needed. Turn off automatic supports in the slicer.
- First test: print a flat capsule such as the token capsule and try the tolerance before you print the large version.
- Breaking in: screw the cap on and off once after printing, and it will turn more smoothly.
Measured with PrusaSlicer, Prusa MINI, 0.20 mm SPEED profile, Prusament PLA:
| Example | Filament | Print time |
|---|---|---|
| Pill box | 2.2 g | 10 min |
| Pill capsule “PILLS” | 3.2 g | 14 min |
| Two-color capsule “MEDS” | 3.3 g | 15 min |
| Emergency coins | 5.6 g | 20 min |
| Banknote tube | 9.7 g | 51 min |
| Toothpick tube | 8.9 g | 1 h 2 min |
| Nano SIM capsule | 1.3 g | 6 min |
Origin and licenses
The layout of the capsule (base with threaded neck, cap with keyring lug, grip notches) is a port of the OpenSCAD file “parametric keychain pillbox.scad” from customizable key chain pill box (OpenSCAD) by DrJones. The model page says CC0, the file itself says CC BY; we follow the file header and treat the model as CC BY 4.0. The thread is our own saw-tooth profile, and the geometry is recomputed in TypeScript. The idea of the label on the cap face comes from the TravelTonie model by Vanix (CC0), from which no code was taken.
All license texts, including those of the bundled fonts, are on the licenses page. For more small containers, see the battery case and the card deck box. Open the generator and build your capsule.
All parameters
The numeric settings of the generator with their default values and allowed ranges. Text, fonts, patterns and colors are set directly in the generator.
| Parameter | Default | Range | Meaning |
|---|---|---|---|
| Size | |||
| Inside diameter | 18.5 mm | 6 – 60 mm | Usable diameter of the cavity. Pills up to about 1 mm smaller fit easily. |
| Inside height | 6.5 mm | 3.5 – 60 mm | Usable height of the closed capsule, from the floor of the base to the ceiling of the cap. |
| Base height | 1.5 mm | 1.5 – 50 mm | Outer height of the base below the cap. Higher bases are easier to grip; the cap keeps room for at least one turn. |
| Wall | 0.8 mm | 0.8 – 2.4 mm | Wall of the neck and of the cap outside the thread grooves. 0.8 mm is two lines with a 0.4 mm nozzle. |
| Floor and top | 0.8 mm | 0.8 – 3 mm | Thickness of the base floor and of the cap top. A label needs at least 0.4 mm of it left over. |
| Thread | |||
| Pitch | 2 mm | 1.5 – 3 mm | Travel per turn. Larger pitches open faster and forgive more, smaller ones hold better on short necks. |
| Thread length | 3.5 mm | 2 – 10 mm | Length of the thread on the neck and in the cap. Limited by the inside height. |
| Tolerance | 0.25 mm | 0.1 – 0.5 mm | Radial play between the threads. Raise it if the cap binds, lower it if it wobbles. |
| Keyring | |||
| Hole diameter | 4 mm | 2 – 10 mm | Hole for the split ring or a lanyard. |
| Lug height | 5 mm | 1.7 – 10 mm | Height of the keyring lug on the cap; at most the cap height. |
| Label | |||
| Depth | 0.4 mm | 0.2 – 1.2 mm | How deep the label goes into the cap top. The cap keeps at least 0.4 mm above it. |
Frequently asked questions
Do I need supports?
No. The base stands on the bed, the cap lies on its top face, and the thread has a saw-tooth profile with a steep underside. In all twelve examples the slicer needed no automatic supports.
What inside size do I need for my pills?
Measure the largest pill or the stack of coins and add about 1 mm. The default of 18.5 × 6.5 mm fits small to medium pills; for five 2-euro coins use 26.5 × 11.5 mm.
How do I get a two-color label?
Under “Style” choose “Flush” and give the label its own color under “Colors”. It then fills the letters in the first layers, and you download a 3MF for your slicer.
What if the cap binds or wobbles?
Raise the “Tolerance” in steps of 0.05 mm if the cap binds and lower it if it wobbles. The default of 0.25 mm suits a well-calibrated printer with a 0.4 mm nozzle.
Is the capsule waterproof?
No. The thread keeps the capsule closed reliably, but it is a play thread without a seal. That is fine for pills in a pocket; it does not keep water out.
Can I print it without the keyring lug?
Yes. Turn off “Keyring lug” for a smooth capsule for your pocket, bag or first-aid kit. With “Parts” you can also print only the base or a spare cap.
Origin & license
- customizable key chain pill box (OpenSCAD) by DrJones · CC BY 4.0 · code ported – Layout and dimensions ported from “parametric keychain pillbox.scad”: base with threaded neck, cap with keyring lug, grip notches; saw-tooth thread instead of a twisted circle so it prints without supports.
- TravelTonie - RFID and Magnet capsule with text (OpenScad) by Vanix · CC0 1.0 · idea – Idea taken: lettering in the face that lies on the print bed.