Spur gear generator: print gears, pairs and racks
Spur gears that mesh on the first print
A spur gear is the simplest way to transmit a rotation: a disc with teeth on its rim that engage the teeth of a second gear. This generator builds printable spur gears with a true involute tooth profile, the same shape that steel gears have. You can make a single gear, a pair of meshing gears with a ratio of your choice, or a rack with a matching pinion that turns rotation into a straight movement. Helical and herringbone teeth are included, as are bores for motor shafts and a hub with a set screw. Look through the examples to see what is possible, for instance the 20-tooth gear with module 1.5, the 1:2 gear pair or the rack and pinion.
How the generator works
Everything runs in your browser. Nothing is uploaded, and the whole design is stored in the link behind “Share”. You pick the kind of part, set module and teeth, adjust the bore and download an STL or a 3MF file. The preview updates while you type, and the generator tells you when it had to correct a value, for example when a bore would cut into the tooth gaps.
The editor has four sections:
- Gear: module, teeth, face width, cutouts and, for pairs and racks, the second part.
- Tooth form: pressure angle, helix angle, profile shift, backlash, root clearance, left-out teeth and tooth smoothness.
- Bore: shape and size of the shaft hole.
- Hub and set screw: a raised hub with a radial set screw.
“Part” switches between “Gear”, “Pair” and “Rack”. The gear math follows the involute gear library of BOSL2, an OpenSCAD library; the tooth shape, profile shift, center distance and tip shortening are ported from it and checked against the original (see the credits below).
Module, teeth and size
The most important number is the “Module” (0.3–6 mm, default 1.5). It is the pitch diameter divided by the number of teeth, so it fixes the size of a tooth. A gear with module 1.5 and 20 teeth has a pitch diameter of 30 mm. Gears only mesh when they share the same module. “Teeth” runs from 4 to 200 and is 20 by default.
| Module | Typical use |
|---|---|
| 0.5 | fine clockwork-style gears, 0.25 mm nozzle recommended |
| 1 | small motor gears, toys, 28BYJ-48 |
| 1.5 | all-round default |
| 2 | gearboxes under load, large gears with cutouts |
| 3–6 | demonstration gears, thick and strong teeth |
Below module 0.8 mm the teeth get so fine that a 0.4 mm nozzle reaches its limits, and the editor warns you. The fine-pitch example with module 0.5 and 40 teeth shows the limit. “Face width” (1–100 mm, default 10) is the thickness along the axle. A wider gear carries more load but needs more filament.
Small gears with fewer than 18 teeth would have undercut tooth roots at the standard 20° pressure angle. “Automatic profile shift” shifts the profile so the roots stay strong, the way BOSL2 does it. Turn it off to enter a “Profile shift” of your own between −1 and 1 modules. The 8-tooth pinion uses the automatic shift.
Pairs and ratios
In “Pair” mode “Teeth of gear 2” sets the second gear. The ratio is teeth of gear 2 divided by teeth of gear 1, so 20 and 40 teeth give 1:2. The generator lays both gears out side by side at the right center distance and shows that distance under the preview. For 20 and 40 teeth with module 1.5 it is about 45 mm. Use this number when you design the housing or the motor mount.
Both gears get the same tooth height, and their tips are shortened a little so that the tip of one tooth never touches the root of the other. “Root clearance” controls that gap; −1 means automatic, a quarter of the module. “Backlash” is the play between the flanks measured on the pitch circle. The default 0.1 mm suits most printers, and 0.15–0.2 mm helps if the gears feel tight. If the layout is wider than the 180 mm bed, the generator reduces the module and tells you so. The 1:3 pair with module 2 is a good starting point for a stronger reduction.
Rack and pinion
“Rack” builds a pinion and a straight rack with “Rack teeth” (2–120). One tooth of the rack equals one circular pitch, so the length follows from the module. “Rack backing” is the material below the tooth roots; −1 gives one tooth height. The pinion axis sits at the distance shown under the preview, above the pitch line of the rack. A rack longer than the bed is shortened with a note. See the rack and pinion and the herringbone version.
Helical and herringbone teeth
With “Helix angle” (−40 to 40°) the teeth twist around the axle. Helical teeth engage gradually, so they run more quietly than straight teeth, and a 30° twist is a good value. The mating gear and the rack get the opposite hand automatically, so you do not have to think about it. The price is an axial force: a helical gear pushes sideways along its shaft, so it needs a thrust bearing or a collar.
“Herringbone” prints two mirrored halves on top of each other. The sideways forces cancel, and the two gears even center each other on their axes. Herringbone teeth are a classic for printing because both halves are one part and no supports are needed. Look at the 24-tooth herringbone gear and the helical pair at 30°. “Pressure angle” stays at 20° unless you want to match an old 14.5° gear; both gears of a pair need the same value.
Bore, hub and set screw
Under “Bore” you choose the shape of the shaft hole: “None”, “Round”, “D shaft”, “Double-D” or “Hexagon”. “Shaft diameter” is the round diameter, or for a hexagon the width across the flats. “Width across the flat” sets the D or double-D flat. “Bore clearance” is added to the hole so the shaft slides in; 0.15 mm gives a snug fit. For a stepper motor with a 5 mm D shaft use 5 mm, 4.5 mm and the default clearance. The 5 mm D-shaft pinion is ready for that, and the 28BYJ-48 gear fits the double-D shaft of the small geared motor.
A gear on a smooth shaft needs a way to grip. “Hub height” raises a hub above the gear (0 = none) and “Hub diameter” sets its width (0 = automatic). “Set screw” offers M2, M2.5, M3 and M4. The generator adds a radial hole and, where the hub wall is thick enough, a slot for a captive nut that is open at the top of the hub, so you can push the nut in from above. If the wall is too thin, the screw cuts its own thread into the plastic. On a D shaft the screw presses on the flat. If the hub is too low for the screw, the generator raises it.
Large gears waste filament in a solid web. “Cutouts” (0–12) adds round weight-saving holes between hub and rim, as in the 60-tooth gear with cutouts. “Left-out teeth” removes teeth for a sector gear that only turns part of a revolution.
Colors and multi-color printing
The generator has two color slots, “Gear 1 / rack” and “Gear 2 / pinion” in the color panel. If gear 2 has no color of its own, both gears are one part. A second color turns gear 2 or the pinion into a separate part, which is useful to tell the gears apart in a pair.
- PrusaSlicer (MMU3, XL, Core One): download “Multi-color 3MF (PrusaSlicer)” and each gear lands on its extruder.
- Bambu Studio / OrcaSlicer (AMS): download “3MF (Bambu Studio / OrcaSlicer)”.
- Other slicers: “STL per color (ZIP)” gives one STL per gear.
- One extruder: print the two gears one after another in two filaments, or use a single color.
The two gears of a pair do not overlap, so the multi-color file keeps both at the correct center distance. Keep multi-color layouts below about 165 mm in width because of the prime tower of some printers.
Printing tips
Gears lie flat on the bed, so no supports are needed. A slicing check with PrusaSlicer on a Prusa MINI, 0.20 mm SPEED profile and Prusament PLA gave these numbers:
| Example | Filament | Time |
|---|---|---|
| 20-tooth gear, module 1.5 | 4.3 g | 17 min |
| Gear pair 1:2 | 18.3 g | 56 min |
| Rack and pinion | 7.1 g | 29 min |
| Herringbone gear, 24 teeth | 8.3 g | 27 min |
| Large 60-tooth gear with cutouts | 40.0 g | 1 h 50 min |
| 28BYJ-48 gear | 2.0 g | 9 min |
For strong teeth use at least three perimeters, so that the tooth is mostly wall, and 20–30 % infill. PLA is fine for light loads; PETG and nylon are better for gears that run a lot, because they wear less. Check that the gear spins on a test shaft before you print a whole set. If the gears bind, raise “Backlash” by 0.05 mm. Lubricate with a little PTFE or silicone grease, not with oil that softens PLA.
Use cases
Printed gears are useful for a first reduction gearbox on a stepper motor, a camera slider with a rack and pinion, a hand crank, a clock or music box, a rotating display, a turntable or a robot joint. Herringbone gears suit gearboxes that need quiet and stable running. A sector gear is the heart of a lever mechanism. If you want another mechanical part, try the bolt and nut generator.
Origin and license
The involute tooth profile, rack, profile shift, center distance and tip shortening are ported from the gear functions of BOSL2 by Revar Desmera, a library for OpenSCAD licensed under BSD-2-Clause. The port was checked against BOSL2 spur_gear() for volume and bounding box. New are the browser editor, the bore and set screw options, the layout of pairs and racks on the bed and the multi-color export. The generated gears are yours to use. More details are on the license page. Ready to start? Open the generator or browse the examples.
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 |
|---|---|---|---|
| Gear | |||
| Module | 1.5 mm | 0.3 – 6 mm | Tooth size: pitch diameter divided by the number of teeth. Gears only mesh with the same module. Below 0.8 mm a 0.4 mm nozzle reaches its limits. |
| Teeth | 20 | 4 – 200 | Number of teeth. Below 18 teeth the profile is shifted automatically so the roots are not undercut. |
| Teeth of gear 2 | 40 | 4 – 200 | Teeth of the second gear; the ratio is teeth 2 : teeth 1. |
| Rack teeth | 20 | 2 – 120 | Teeth on the rack; this sets its length (one tooth per circular pitch). |
| Face width | 10 mm | 1 – 100 mm | Thickness of the gear, the width of the teeth along the axle. |
| Cutouts | 0 | 0 – 12 | Round weight-saving holes between hub and rim, 0 = solid web. |
| Rack backing | -1 mm | -1 – 30 mm | Material below the tooth roots of the rack, −1 = automatic (one tooth height). |
| Tooth form | |||
| Pressure angle | 20 ° | 14.5 – 30 ° | 20° is standard. Both gears of a pair need the same angle; 14.5° is found on old gears. |
| Helix angle | 0 ° | -40 – 40 ° | 0 = straight teeth. Helical teeth run more quietly; the mating gear and the rack get the opposite hand automatically. |
| Profile shift | 0 | -1 – 1 | Shift of the tooth profile in modules: positive values make stronger roots and move the gears apart. |
| Backlash | 0.1 mm | 0 – 1 mm | Play between the flanks on the pitch circle. 0.1 to 0.2 mm keeps printed gears from binding. |
| Root clearance | -1 mm | -1 – 2 mm | Gap between a tooth tip and the root of the other gear, −1 = automatic (module / 4). |
| Left-out teeth | 0 | 0 – 199 | Removes teeth for a sector gear, 0 = full gear. |
| Tooth smoothness | 16 | 8 – 32 | Points per tooth flank. 16 is plenty for printing; more only makes the file bigger. |
| Bore | |||
| Shaft diameter | 5 mm | 1 – 60 mm | Diameter of the shaft (hexagon: width across the flats). |
| Width across the flat | 4.5 mm | 0.5 – 60 mm | D shaft: measured from the flat to the opposite side; double-D: between both flats. |
| Bore clearance | 0.15 mm | 0 – 0.6 mm | Added to the bore diameter so the shaft slides in. 0.1 to 0.2 mm for a snug fit. |
| Hub and set screw | |||
| Hub diameter | 0 mm | 0 – 80 mm | Diameter of the hub on top of the gear, 0 = automatic. |
| Hub height | 0 mm | 0 – 40 mm | Height of the hub above the gear, 0 = no hub. A set screw needs a hub. |
Frequently asked questions
Do I need supports?
No. A gear lies flat on the bed and the teeth are straight walls, so nothing overhangs. A PrusaSlicer check of all 13 examples, including the helical and herringbone ones, found no need for automatic supports.
Which module and backlash should I pick?
Module 1.5 is a good start for a 0.4 mm nozzle; below 0.8 the teeth get very fine. Keep the default backlash of 0.1 mm and raise it to 0.15–0.2 mm if your printer is not well calibrated and the gears bind.
Why do two gears have to share the same module?
The module is the tooth size, pitch diameter divided by the number of teeth. Only gears with the same module and the same pressure angle mesh. In “Pair” mode the generator uses one module for both gears and computes the center distance for you.
How do I fit the gear on a motor shaft?
Choose “D shaft” or “Double-D” under “Bore”, enter the shaft diameter and the “Width across the flat”, and add a hub with a set screw. For a 5 mm shaft the defaults are 5 mm and 4.5 mm, with 0.15 mm “Bore clearance”.
Can I print the two gears of a pair in different colors?
Yes. Gear 1 and gear 2 have their own color slots. Give gear 2 a color and it becomes a second part in the multi-color 3MF, or a separate STL in the ZIP. On a single-extruder printer you print them one after another.
Origin & license
- BOSL2 by Revar Desmera · BSD-2-Clause · code ported – involute tooth profile, rack, profile shift, center distance and tip shortening ported from gears.scad to TypeScript