M-codeTool ChangeMill · Lathe · 3D printer
M06: Tool Change
M06 runs the machine's tool change. The T word says which tool, and on most machining centres it sits on the same block: T11 M06. What happens after that belongs to the machine builder rather than to the control, which is why one machine lifts the head for you and the one beside it changes tools wherever the last move left the spindle. M06 swaps the taper and stops there. The tool's length offset arrives separately, on the G43 block you write yourself.
Syntax
T__ M06 Load the tool the T word names
T__ Select a tool without changing it, on a changer that pre-stages
M06 Change to the tool selected on an earlier blockParameters
| Address | Meaning | Notes |
|---|---|---|
T | Tool number | Required, on the same block or an earlier one. On a fixed pocket changer the number is the pocket; on a random access changer the control looks the tool up in its table and the pocket varies |
M06 takes no other address. Nothing in the block says where the change happens or how fast the spindle gets there: the tool change position is machine data, and the sequence that reaches it is the builder's, not the program's.
Example
O0007 (COVER PLATE, 200 X 50 X 20 IN 6082)
G21 G17 G40 G49 G80 G90 (safe start block)
T04 M06 (63mm face mill, five inserts)
G54 (part zero at the top left corner)
S1500 M03 (300m/min in aluminium)
G00 X-50. Y-25. (clear of the plate, on the centreline)
G43 H04 Z50. M08 (tool 4 length, flood coolant)
G01 Z0. F900 (down to the finished face)
X250. F1500 (one pass across, 0.2mm per tooth)
G00 Z50. M09 (clear of the job, coolant off)
M05 (spindle stopped for the change)
G49 (drop the face mill's length first)
G91 G28 Z0. (Z to machine home, X and Y stay put)
G90 T11 M06 (8.5mm cobalt stub drill)
S3200 M03 (85m/min)
G00 X20. Y-25. (first hole)
G43 H11 Z50. M08 (tool 11 length, not tool 4's)
G81 Z-23. R3. F450 (through 20mm of plate plus the drill point)
X100. (the cycle repeats at each position)
X180.
G80 M09 (cycle off)
G00 Z50.
G49
G91 G28 Z0.
M30Controller differences
| Control | Behaviour |
|---|---|
| Fanuc | The control does not define M06. Parameter 6071 holds the M code that calls program O9001, so with 6 written into it M06 and M98 P9001 are the same call, and the retract, orient and arm sequence in that program is the builder's. Not every builder works that way: some run the whole change in the PMC ladder instead. A turret lathe has no tool change block to write: T0101 indexes the turret and applies offset 01 in the same word. |
| Haas | M06 stops the spindle and switches coolant off on its own, through-spindle coolant included, before the changer moves. Setting 81, Tool At Power Up, is the tool the changer loads when Power Up/Restart is pressed, and at 0 no tool change happens. |
| Siemens 840D | T selects and M6 activates, and the tool offset arrives with the change rather than from a G43 block. With tool management the tool is named, not numbered: T="DRILL85" M6, then D1 for the cutting edge. ISO dialect mode accepts T11 M06. |
| Mazak | Mazatrol conversational programs need no M06. Each tool sequence in a unit names its tool and the control selects it, and a unit can hold several tool sequences, so the change is not tied to the unit boundary. On a machining centre an EIA/ISO program uses T__ M06 as on Fanuc. |
| Grbl | No tool changer and no M6 in the v1.1 supported list, so the block stops the stream with error:20. T is accepted as a non-command word, stored and acted on by nothing. A multi-tool job has to be posted as one file per tool. |
| Marlin | Tools are selected with the T word on its own: T0 and T1 switch between hotends and run the toolchange script set by the Universal Tool Change Settings in Configuration_adv.h. There is no M06 in the g-code index. |
What goes wrong
Nothing in an M06 block loads the new tool's length. The changer swaps the taper and the control carries on with whatever offset was live, so a Z move straight after the change drives the drill to where the face mill's H04 said the tip was. Call G43 H11 on the first Z move of the new tool, every time, and the two numbers stay together.
Next is where the spindle stands when the block runs. On a Fanuc the whole sequence is the builder's, a subprogram called through parameter 6071 on one machine and ladder logic on the next, so one lifts to machine zero on its own and the other swings an arm at whatever height the last move left. A Haas stops the spindle and shuts the coolant off for you, through-spindle included, but that is a Haas convenience, not a rule. Retract yourself and the program is right on both.
Third is the control's record of what sits in the taper. Pull a cutter out by hand to look at an edge, then leave it in the rack, and the changer tries to load a pocket that is already full. On a Haas, Setting 81 names the tool the changer loads when Power Up/Restart is pressed, and that button is usually the moment the mismatch turns into bent geometry.
Last is posting a multi-tool job for a control with no changer. Grbl has no M6 in its v1.1 list, so the stream stops at error:20 with the first tool still in the spindle and half the holes cut.
Updated 11 Oct 2026