---
title: "How to Read G-Code to Find the Next Tool Change"
description: "Finding the next tool change is a search skill: look for the T word and M06, read the preamble that re-establishes the tool, and use it as a safe restart point."
url: https://gcodepractice.com/journal/how-to-read-g-code-to-find-the-next-tool-change/
canonical: https://gcodepractice.com/journal/how-to-read-g-code-to-find-the-next-tool-change/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-06-07
updated: 2026-06-07
category: "Guides"
tags: ["reading code", "tool change", "navigation", "m06"]
lang: en
---

# How to Read G-Code to Find the Next Tool Change

> **TL;DR** Finding the next tool change in a program is a fast, specific reading skill: search forward for the T word paired with M06 (T stages the tool, M06 executes the change), which marks the boundary, then read the few lines after it that re-establish the tool, the G43 H length-offset call, the spindle speed and start, the work offset, the first approach move. Tool changes are the natural chapter breaks of a program, which is why finding them matters for three jobs: navigating a long program, choosing a safe restart point (tool changes are the gold standard), and staying oriented during a run. Program search beats scrolling, and recognizing the tool-change signature on sight is core fluency.

Tool changes are a program's chapter breaks, and finding the next one is a navigation skill every machinist uses constantly, to jump around a long program, to pick a safe place to restart, to stay oriented during a run. It is also fast and specific once you know the signature, which turns a wall of code into a sequence of clearly marked sections.

## A worked glimpse of the shape

A tool-change block in a real program reads like a small stanza: a line carrying T05, an M06 to swap it in, then G43 H05 to pick up tool five's length, S2400 M03 to start the spindle, G54 confirming the work offset, and a G00 rapid to the first hole. Six or seven lines, the same shape every time, only the numbers changing. Once that stanza is a single recognized object to your eye, scanning a program for tool changes is like flipping through a book for its chapter headings, you are not reading the words, you are spotting the format, and the format is what the search below targets.

## The signature to search for

A tool change has a recognizable shape: the [T word and M06](https://linuxcnc.org/docs/html/gcode/m-code.html) mark the boundary (T stages the tool in the [magazine](https://en.wikipedia.org/wiki/Automatic_tool_changer), M06 executes the physical exchange), and a short preamble after it re-establishes the new tool's context. Search for the boundary, then read the preamble.

| Element | What it looks like | What it tells you |
| --- | --- | --- |
| The boundary | T-word with M06 | A tool change happens here |
| Length offset | G43 H-number | Which offset register this tool uses |
| Spindle | S-word with M03/M04 | The new tool is spinning up |
| Context | Work offset, first rapid | Where the new tool starts cutting |

That preamble is the fingerprint: when [G43 H](/journal/g43-tool-length-offset-explained/), a spindle start, and an approach move cluster together, you are reading the opening of a tool's section, the same recognizable shape on every Fanuc-shaped control, documented in the [standard reference](https://linuxcnc.org/docs/html/gcode/g-code.html). Use the control's program search for T or M06 rather than scrolling, search lands exactly on the boundary, scrolling drifts past it.

## The three jobs it serves

**Navigation.** A long program is a sequence of tool sections, and jumping between tool changes is how you move through it, to the roughing tool, the finish tool, the drill. The chapter-break model makes a forty-tool program legible: each change is a heading, each section a chapter.

**Restart safety.** Tool changes are the [gold-standard restart points](/journal/how-to-safely-restart-a-cnc-program-from-the-middle/) because they freshly re-establish the tool, the offset, the spindle, and often the work offset within a few lines, which shrinks the state you must reconstruct to almost nothing. Finding the next (or previous) tool change is the first move in any safe mid-program restart, and the reason a [skipped tool change](/journal/cnc-program-skipped-a-tool-change-why/) contaminates everything downstream, every section after it inherited the wrong tool.

**Orientation.** Knowing which tool's section you are in tells you what the surrounding code is doing, a deep plunge in the drill section reads differently from the same move in the finish section. During a run, glancing to the next tool change tells you what is coming.

## Reading it like a chapter, not a line

The skill is recognizing the signature as one shape rather than decoding it word by word. The T-and-M06 pair, the G43 H, the spindle start, the approach, become a single recognized pattern once the vocabulary is automatic, so your eye jumps to tool changes the way a reader's eye finds paragraph breaks. That recognition is recall, drilled free in the 60-second rounds on the [G-code practice page](/g-code-practice/), and it compounds with the [broader reading-for-errors discipline](/journal/how-to-read-g-code-to-find-errors/): fluent readers navigate by tool change, scan each section for its species of error, and never lose their place in a long program. Narrating a few real programs, calling out each tool change aloud as you reach it, turns the recognition into a reflex within a week.

## Sources

- [LinuxCNC: M-code reference](https://linuxcnc.org/docs/html/gcode/m-code.html)
- [LinuxCNC: G-code reference](https://linuxcnc.org/docs/html/gcode/g-code.html)
- [Wikipedia: Automatic tool changer](https://en.wikipedia.org/wiki/Automatic_tool_changer)

## Frequently asked questions

### How do you find the next tool change in a G-code program?

Search forward for the signature: a T word with M06, where T stages the tool and M06 executes the change. Use program search rather than scrolling, then read the few lines after it, the G43 H call, spindle start, work offset, first approach, that re-establish the new tool.

### What does a tool change look like in the code?

A T word naming the tool, an M06 to execute it, then a preamble: G43 with an H number, an S word and M03 for the spindle, often the work offset and a rapid to the first position. That preamble cluster is the fingerprint.

### Why is finding tool changes useful?

Navigation (they are a program's chapter breaks), restart safety (the gold-standard re-entry points, since they re-establish tool, offset, and spindle), and orientation (knowing which tool's section you are in).

### What is the fastest way to get good at spotting tool changes?

Recognize the signature on sight through recall practice: the T-and-M06 pair plus the preamble become one recognized shape. The free G-Code Sprint app drills the core, and narrating real programs turns it into a reflex.

---

Source: https://gcodepractice.com/journal/how-to-read-g-code-to-find-the-next-tool-change/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
