---
title: "M06 Tool Change in G-Code, Explained for Beginners"
description: "M06 executes a tool change while the T word selects the tool. Here is how T6 M06 works, the safe sequence around it, and why G43 always follows."
url: https://gcodepractice.com/journal/m06-tool-change-explained/
canonical: https://gcodepractice.com/journal/m06-tool-change-explained/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-06-04
updated: 2026-06-04
category: "Code reference"
tags: ["m-code", "m06", "tool-change", "beginner", "reference"]
lang: en
---

# M06 Tool Change in G-Code, Explained for Beginners

> **TL;DR** M06 commands a tool change. The T word selects (and on many machines pre-stages) the tool, and M06 performs the swap, often written together as T6 M06. The safe routine stops the spindle, sends Z home, then changes the tool, and afterward you re-apply tool length offset with G43 because the new tool is a different length.

`M06` is the code that changes the tool. It is short, it appears in almost every program with more than one operation, and the safe way to use it is a small routine, not a single line. Get that routine right and tool changes are uneventful.

## M06 and the T word work together

Two words do the job. The `T` word **selects** the tool, and `M06` **changes** to it. You usually see them on the same line:

```
T6 M06   (select tool 6, then change to it)
```

On most machines with an automatic tool changer, `T` does more than name the tool: it pre-stages it by rotating the carousel to that pocket. That lets the changer stage the next tool while the current one is still cutting, then `M06` performs the swap when you reach it. The behavior is defined in the [LinuxCNC M-code reference](https://linuxcnc.org/docs/html/gcode/m-code.html), and `M06` is a classic example of an M-code being a machine action rather than a motion command, which is the heart of the [G-code vs M-code](/journal/g-code-vs-m-code-difference/) distinction.

## The safe tool-change routine

A bare `M06` is not enough on most setups. You want the spindle stopped and the tool clear of the part before anything swaps. The standard routine looks like this:

| Block | What it does |
| --- | --- |
| `M05` | Stop the spindle |
| `G91 G28 Z0` | Send Z to home, clear of the part |
| `G90` | Reset to absolute |
| `T6 M06` | Select and change to tool 6 |
| `G54` | Confirm the work offset |
| `S2000 M03` | Start the new tool spinning |
| `G43 Z25. H06` | Apply tool 6 length, rapid to safe Z |

Stopping the spindle uses the [M05 spindle stop](/journal/m03-m04-m05/), and clearing the tool uses a [G28 return to home](/journal/g28-return-to-home-position-explained/). Some controls automate parts of this and retract to a fixed change position on their own; others need every line. Always check your machine's manual, because tool-change behavior varies more between controls than almost any other code, a point the [Wikipedia G-code overview](https://en.wikipedia.org/wiki/G-code) makes about machine-specific differences.

## Why G43 always follows

The single rule beginners forget: after a change, re-apply the tool length offset. The new tool is a different length, so its Z depths are wrong until the control applies the right value. That is the job of [G43 tool length offset](/journal/g43-tool-length-offset-explained/) with the matching `H` register, normally on the first Z move after the change. Matching the numbers (tool 6 uses `H06`) is the standard habit that prevents mix-ups.

## Automatic vs manual tool change

What `M06` actually does depends on the machine:

| Machine type | What M06 does |
| --- | --- |
| Automatic tool changer (ATC) | Swaps the spindle tool for the staged tool |
| Manual mill, no changer | Pauses and prompts the operator to change the tool by hand |

Either way, `M06` is a one-shot action: it runs once and is done, unlike the modal G-codes that stay active. It is one of the most common M-codes you will read, so it belongs on every list of the [common M-codes for CNC beginners](/journal/common-m-codes-for-cnc-beginners/) and on any good [code cheat sheet](https://www.cnccookbook.com/g-code-m-code-cnc-list-cheat-sheet/).

## Bottom line

`M06` performs the tool change and the `T` word selects the tool, often written together as `T6 M06`. Wrap it in a safe routine: stop the spindle, send Z home, change the tool, then re-apply tool length offset with `G43`. The exact moves depend on the control, so confirm the tool-change behavior in your machine's manual.

## Sources

- [LinuxCNC M-code reference (M6 tool change)](https://linuxcnc.org/docs/html/gcode/m-code.html)
- [Wikipedia: G-code](https://en.wikipedia.org/wiki/G-code)
- [CNCCookbook: G-code and M-code cheat sheet](https://www.cnccookbook.com/g-code-m-code-cnc-list-cheat-sheet/)

## Frequently asked questions

### What is M06 in CNC?
`M06` is the M-code that performs a tool change. It works with the `T` word that selects the tool, so `T6 M06` selects tool 6 and changes to it. On an automatic changer it swaps the tool; on a manual machine it prompts the operator.

### What is the difference between T and M06?
`T` selects the tool and, on many controls, pre-stages it by rotating the carousel. `M06` is the action that swaps it into the spindle. Splitting them lets the carousel stage the next tool while the current one is still cutting.

### Why do you need G43 after M06?
The new tool is a different length, so the control must apply its length offset for Z depths to stay correct. `G43` with the matching `H` register does that, usually on the first Z move after the change.

### What is the best way to learn M-codes like M06?
Drill them with active recall. A free app like G-Code Sprint quizzes `M06` and the rest of the everyday codes as quick timed questions and repeats whichever ones you miss.

*G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.*

---

Source: https://gcodepractice.com/journal/m06-tool-change-explained/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
