G28 tells your CNC machine to move to a safe intermediate point, then rapid all the way to the machine’s home position. It’s one of the most common safety commands in CNC programming — and one of the easiest to crash a machine with if you use it wrong.
Key Takeaways
- G28 moves the machine to an intermediate point first, then returns to the machine zero position
- Always pair it with G91 (incremental mode) to avoid crashing into your workpiece
- Use it before tool changes, pallet changes, or any time you need the machine out of the way
- It is NOT a modal command — it only runs once on the line it appears
- G28 Z only (Z-axis first) is the safest approach in most programs
| G25 – At A Glance | |
|---|---|
| Function | Machine Zero Return (Reference Point Return) |
| Format | G28 [axis][value] |
| Type | Non-modal (one-shot) |
| Typical Use | Before tool changes, end of program, safe retract |
| Related Codes | G53, G28.1, G29, G30 |
What Does G28 Do?
G28 moves the machine in two steps. First, it rapids to an intermediate point you specify. Then it rapids from that point to the machine’s zero position (also called the home position or reference point).
That intermediate stop is the key. Without it, a direct rapid to machine zero could slam the tool straight through a clamp, a vise jaw, or the part itself.

Think of it like backing a car out of a tight parking spot. You don’t just floor it in reverse — you pull out at an angle first to clear the car next to you, then straighten out.
When to use a G28 code?
G28 shows up near the end of a tool path section, right before the machine needs to do something else — like a tool change or a pallet change.
Common situations where you’ll use it:
- Before an M06 tool change
- At the end of a program (returning the machine to home)
- Before a pallet change on a horizontal machining center
- Any time you need to guarantee the machine is clear of the part and fixtures

G28 and the G91 Pairing — Why It Matters
This is where most beginners get tripped up.
G28 uses whatever positioning mode is currently active — absolute (G90) or incremental (G91). If your program is in absolute mode (which most programs are), the intermediate point values in G28 are interpreted as work coordinates. That means the machine might try to move to X0 Y0 Z0 of your workpiece before going to machine zero — and that’s a crash.
COMMON MISTAKE – Running G28 X0 Y0 Z0 while still in absolute mode (G90)
Why it matters: In absolute mode, X0 Y0 Z0 refers to your work offset zero — which is likely right on top of your part. The machine will try to move there before going to machine zero. This is one of the most common crash scenarios in CNC programming.
The fix is simple: add G91 on the same line as G28.
G91 G28 Z0 (Switch to incremental, move 0 units in Z, then return Z to machine zero)
G90 (Switch back to absolute mode)
With G91 active, the intermediate point values are treated as distances from the current position. A value of Z0 means “move zero units in Z first, then go to machine zero” — so the tool goes straight home without an intermediate detour.
COMMON MISTAKE – Forgetting to restore G90 after using G91 with G28
Why it matters: If absolute mode isn’t restored before the next tool’s program begins, every position in your program will be interpreted as an incremental move. This can cause rapid crashes on the very first move of the next operation.
Always put G90 on the line immediately after your G28 block.
Z First — The Safest Approach
In most programs, you’ll see G28 used on the Z-axis alone before touching X or Y.
G91 G28 Z0 (Retract Z to machine zero first)
G90
G91 G28 X0 Y0 (Then home X and Y — optional, often not needed)
G90
Moving Z first clears the tool out of the part before moving the table. If you home X and Y with the spindle still down in the cut, you’re dragging the tool across the part — or worse.
G28 Code Examples
G28 G91 Z0 — Most Common Usage
G91 G28 Z0 (Incremental mode, Z moves 0 units, then rapids to machine zero)
G90 (Restore absolute mode)
This is the line you’ll see in the vast majority of CNC programs before a tool change. The Z-axis returns to its home position. X and Y are unaffected.
G28 X0 Y0 Z0 — All Axes Home
G91 G28 X0 Y0 Z0 (All three axes move to machine zero simultaneously)
G90
Use this at the end of a program when you want the machine fully homed. Be aware that all three axes move at the same time — so make sure your tool is already clear of the part before running this.
G28 G91 Z35.0 — Clearance Move First
G91 G28 Z35.0 (Move Z up 35mm from current position, then home Z)
G90
When you need guaranteed clearance before homing — for example, if you’re in a deep pocket — specify the clearance distance instead of zero. The tool moves up 35mm first, then rapids to machine zero.
G28 U0 W0 — CNC Lathe Syntax
G28 U0 W0 (Return to machine zero on a CNC lathe)
On many CNC lathes, U and W are the incremental axis designators for X and Z respectively. Using U0 W0 with G28 returns both axes to machine zero with no intermediate move — a common and safe pattern on lathes.

G28 vs G53 — What’s the Difference?
G53 is G28’s close cousin. Both can move the machine to a safe position using machine coordinates.
The key difference: G53 lets you specify exactly where you want to go in machine coordinates, on a single line. G28 always goes all the way to machine zero.
G53 is often more flexible — you can use it to position the spindle at a tool changer or a pallet station without sending everything to machine zero. But not every CNC control supports G53. G28 works on virtually every machine.
Pick one and stick with it consistently. Mixing G28 and G53 in the same shop makes programs harder to read and troubleshoot.
G28 vs G28.1
G28.1 lets you define where G28 goes. When you run G28.1 at a specific position, that position becomes the new reference point for future G28 commands — instead of the default machine zero.
Most shops never need G28.1. It’s useful in specific setups where machine zero isn’t a practical home position. If you’re just getting started, ignore it for now and use G28 the standard way.
Is G28 a modal command?
No. G28 is a one-shot (non-modal) command. It executes once on the line where it appears, and that’s it.
Compare that to something like G90 or G91, which stay active until you change them. G28 doesn’t “stay on” — it runs its two-step move and then the machine does whatever comes next.
FAQs
What is G28 used for in CNC programming?
G28 returns the machine to its home (zero) position. It’s most often used before tool changes and at the end of programs to move the machine clear of the workpiece and any fixtures.
Why do you use G91 with G28?
G91 switches the machine to incremental positioning mode. This makes the intermediate point in G28 a relative move from the current position, not an absolute coordinate. Without G91, if your program is in absolute mode, G28 could try to move to work coordinate zero — which might be right on top of your part.
What’s the difference between G28 and G53?
Both codes can move the machine using machine coordinates. G28 always moves to machine zero (in two steps). G53 lets you specify any machine coordinate position on a single line, making it more flexible. G53 is not supported on all controls; G28 is universal.
Does G28 move all axes at once?
Only the axes you specify. G28 Z0 only moves the Z-axis. G28 X0 Y0 Z0 moves all three. When multiple axes are specified, they all move simultaneously in each step.



















