The M06 code tells your CNC machine to perform a tool change. When the machine reads M06, it swaps the tool waiting in the ready position of the automatic tool changer (ATC) into the spindle.
That’s the short version. Here’s everything else you need to know to use it correctly.
Key Takeaways
- M06 triggers a tool change on CNC machines with an automatic tool changer (ATC)
- Always pair M06 with a T code — the T code selects the tool, M06 executes the swap
- The machine must be in a safe position (usually home or tool change position) before M06 runs
- M06 and M6 are identical — the leading zero is optional
- Without an ATC, use M00 to pause the program and change tools manually
| M06 – At A Glance | |
|---|---|
| Function | Automatic tool change |
| Format | T## M06 (or T## M6) |
| Type | Non-modal |
| Machine type | Machining centers with ATC |
| Common pairing | T code, G43 (tool length compensation) |
How M06 Works
When the controller reads M06, several things happen in sequence. The spindle stops, the machine moves to the tool change position (often the same as the home position), and the ATC rotates the carousel to place the called tool into the spindle. The previous tool gets returned to its pocket.

All of that is automatic. Your job is to set it up correctly in the program.
Pairing M06 with the T Code
M06 doesn’t know which tool to grab on its own. You have to tell it using a T code.
The T code selects the tool number. M06 executes the swap. They’re almost always written on the same line:
T02 M06
This calls Tool #2 from the carousel and puts it in the spindle. On some machines, you can put the T code on the line before M06 — the T code stages the tool in the ready position, and M06 swaps it in. Check your machine’s control manual for the exact behavior.
After a tool change, you’ll typically follow up with G43 to apply tool length compensation:
T02 M06
G43 H02 Z1.0
H02 calls offset #2, which stores the length of Tool #2. Without this, the machine has no idea how long the new tool is.
Try It: See How the Tool Change Works
The best way to understand M06 is to watch it happen. Use the simulator below to see exactly how the T code and M06 work together.
Here’s what to do:
- Click any pocket on the ATC wheel to call the T code — the carousel rotates to bring that tool to the ready position
- Press Execute M06 to pull the staged tool into the spindle
- Then try the red button — run M06 without a T code and see what happens
That last step is the one worth remembering. The T code tells the machine which tool to load. M06 just says do it. Skip the T code and the controller either loads whatever was staged from the last program or throws an alarm. Either way, it’s not the tool you wanted.
Preparing for a Safe Tool Change
Before M06 runs, the machine needs to be in a safe position. On most machines, this means moving to the tool change position — usually Z home or a designated safe height.
If the spindle is still near the part when M06 fires, you risk a collision. Most post-processors handle this automatically, but if you’re writing code by hand, make sure you’ve retracted first.
Also think about your tool’s physical size before loading it:
- Diameter — Large-diameter tools (face mills, large boring heads) may need to be placed near empty pockets in the carousel so they don’t hit adjacent tools during rotation.
- Length — Usually less of an issue, but extra-long tools can cause clearance problems with the spindle head or tool changer arm on some machines.
- Weight — Every machine has a maximum tool weight rating. That number includes the tool, holder, and any extensions — not just the cutter. Check the spec sheet.
COMMON MISTAKE – Calling M06 Without Retracting First
Running M06 while the tool is close to the part or a fixture is one of the fastest ways to cause a crash. The machine moves to the tool change position automatically — but it takes the most direct path to get there.
If you haven’t cleared the work area first, something’s getting hit.
Performing a Tool Change Without an ATC
Not every machine has an automatic tool changer. Knee mills, older VMCs, hobby CNCs, and some small production machines require manual tool changes.
In that case, M06 isn’t needed — and on many controls, calling it will just trigger an alarm.
Instead, use M00 (Program Stop) to pause the program at the right moment. The machine stops, the spindle shuts off, and the operator changes the tool manually. When ready, they press Cycle Start to resume.
Write it like this:
M00 (CHANGE TO T02 — 1/2" END MILL)
The comment in parentheses tells the operator exactly what to do. Don’t skip the comment — whoever’s running the machine shouldn’t have to guess.
Performing a tool change without an automatic tool changer
If your machine doesn’t have an automatic tool changer, then the operator (probably you) will need to change the tools manually.
The best way to do this is to put a program stop in your program using the M00 code. You should include comments in your program at the program stop to tell the operator what they are expected to do.
M6 vs M06 — Is the Zero Required?
No. M6 and M06 are the same command. The CNC controller reads them identically.
The leading zero is just a formatting convention. Textbooks and reference materials tend to use M06. In practice, plenty of programmers write M6 to save a keystroke.
If you’re working solo, use whichever format you prefer. If you’re in a shop environment, match whatever format is already in use — consistency makes programs easier to read and troubleshoot.
FAQS
Do I need to use M06 if I don’t have an automatic tool changer?
No. Without an ATC, M06 either does nothing or triggers a control alarm depending on your machine. Use M00 to stop the program and change tools manually instead.
Can I use M06 to switch to an empty spindle?
Yes. Call up a tool pocket that has no tool loaded in it, then run M06. The machine will swap in the empty holder, leaving the spindle bare. This is sometimes useful when you need the spindle out of the way.
What happens if I forget the T code before M06?
The machine will either pull whatever tool was previously staged in the ready position, or it won’t execute the change at all — behavior varies by control. Always include the T code on the same line or immediately before M06.
Does M06 stop the spindle automatically?
Yes. The spindle must be stopped for a tool change. Most controls will stop it automatically when M06 runs. In hand-coded programs, some programmers add an explicit M05 before M06 just to be safe.