What Is the H Code in CNC? Tool Length Offset Explained
In common CNC milling programming, the H address selects a tool length offset entry stored in the machine control. The entry it selects is used together with a tool length compensation command — G43 on many mill controls — so that the programmed path accounts for the measured length of the tool in the spindle.
The H number is not the tool length value. H01 refers to an entry; the value inside that entry lives in the controller’s offset table, in whatever form the machine’s measurement and setup convention produces. This article separates those two ideas, then covers the offset table, G43, G44, G49, D, G54, and the errors that follow from mixing them up.
The H address selects a tool length offset entry. The value inside that entry — not the H number — is the compensation data the control applies so that a tool of a particular length reaches the programmed position. On many mill controls the compensation is applied with G43 and removed with G49, but the syntax, the numbering and the activation rules are conventions of a control family, not universal rules of CNC.
Everything below is written that way on purpose: the mechanism is general, the specific behaviour belongs to your control and your machine documentation.
| Term | What it does |
|---|---|
H address | Selects a tool length offset entry in a common mill-programming convention. It identifies which row of the offset table is used. |
| Tool length offset value | The stored compensation data associated with that entry. This is the measured or calculated length the control works with — it is not the H number. |
G43 | A tool length compensation command on many mill controls, used together with an H entry to apply the length offset in the positive sense. |
G44 | The corresponding negative-direction command where a control supports it. Not every program or machine needs it. |
G49 | The cancel command for tool length compensation on controls that use this convention. |
Scope of this page. The explanations here follow common CNC milling programming practice and the manufacturer documentation cited at the end. They are not a substitute for the operator’s and programming manuals of the machine in front of you, and they are not a statement about every control, machine type or tool-management system.
H, Tool Length Offset and G43: Key Differences
Short answer: three different things are being described when people say “the H code”. Separating them removes most of the confusion around tool length compensation.
| Element | What it is | What it is not |
|---|---|---|
| The H address | A selector: it tells the control which offset entry to use, for example entry 1 in H01 | It is not a length, a measurement or a compensation value |
| The stored value | The data in the offset table for that entry — measured or calculated according to the machine’s convention | It is not part of the program text, and it does not travel with the program |
| The compensation command | G43 on many mill controls, which applies the selected offset; G44 where the opposite direction is supported; G49 to cancel | It is not a measurement instruction, and it does not itself contain the tool length |
The tool number T | Selects which tool is called to the spindle, with the change action defined by the machine | It does not guarantee that a matching offset entry is applied automatically |
How H Codes Work in a CNC Program
Short answer: the program names an entry and asks for compensation; the control supplies the value and does the arithmetic. The three parts are in three different places, which is the whole reason tool-length mistakes are so repeatable.
A schematic program fragment looks like this. It is included to show the shape of the relationship between tool call, offset selection and compensation — it is not a program to run.
T01 M06 (call tool 1 — change action is machine-specific) S2500 M03 (spindle on) G43 H01 Z50.0 (apply length compensation for entry 01, move to Z) G01 Z-2.0 F150.0 (cut) G49 (cancel length compensation)
Before you take anything from this block: the syntax, the availability of each command, the coordinates and the cancellation behaviour all depend on your control and on how the machine is configured. Confirm each line against the programming documentation for the specific machine, confirm the active tool and the value in the offset entry it will use, and verify the program by the machine’s approved procedure before cutting metal. An article cannot validate a program for your machine.
What the Z value in the block does and does not mean
- The Z value is the position the tool tip is sent to in the active coordinate frame; the length offset is what makes that position correct for the tool currently in the spindle.
- It is not accurate to read the block as arithmetic on the number — as though the offset were simply “added to Z50”. How the control combines the coordinate and the offset, and where the tool tip physically ends up, follows from how the offset was measured and from the control’s convention.
- Customary measurement and symbol conventions differ between machine types; a lathe and a machining centre do not necessarily treat the same letter the same way.
Modal behaviour, and why it is not a safety net
On many controls these commands are modal: once a compensation is active it can remain active until it is replaced or cancelled. That is convenient, and it is also why an unintended state can persist. Whether a tool change cancels length compensation, replaces it, or leaves it untouched is a property of the control and of the tool-change sequence as configured. Treat “the tool change handles it” as a hypothesis to verify on your machine, not as a general rule.
H Code and the Tool Offset Table: A Worked Example
Short answer: three different things line up in a worked example — what the program names, what the table stores, and where the stored value came from. Keeping those columns separate is what makes the example useful.
| Element | What it selects or holds | Example | Where that comes from |
|---|---|---|---|
T01 | Which tool is called to the spindle | Tool 1 | The machine’s tool-change configuration and the tool loaded in the magazine |
H01 | Which offset entry is selected | Entry 01 | The program text |
| Value in entry 01 | The compensation data the control applies | 128.412 mm — example value only | The machine’s measurement method and setup convention, entered in the offset table |
| Resulting tool tip position | Where the tool tip actually goes | Determined by the control | The combination of the coordinate, the stored value and how that value was referenced |
Two edits that are not program edits
Change the entry number in the program and the control reads a different row of the table. Change the measurement, and the same row holds a different value while the program text is untouched. Both are routine, both change where the tool goes, and neither appears in the program listing. This is why “the program was not changed” is never a complete answer to a depth error.
Does the H number have to match the tool number?
Matching them — tool 1 with entry 01 — is the common convention, and on many controls it is the default. It is not a law of CNC. Whether a mismatch is permitted, silently ignored, or prevented depends on the control and on settings that the machine builder or the shop can change; the manufacturer documentation is where that is established for a given machine. Practically, keeping the pairing deliberate is what makes a program readable and auditable, and it is worth stating the pairing on the setup sheet.
Do not assume a two-digit numbering range
Offset numbering is a control property, not a two-digit convention. Manufacturer documentation for mill controls, for example, shows H values used for tool group offsets that run well beyond two digits. Where documentation lists a range, that range belongs to the control it documents — it does not transfer to another machine, and it should never be presented as the general range for H codes.
How Tool Length Offsets Are Measured and Set
Short answer: there are several accepted methods, and the method decides what the stored value actually represents. The value and the reference it was measured from travel together; separating them is how a consistent part becomes a wrong part.
| Method | What happens | What the stored value represents | What to watch |
|---|---|---|---|
| Touch probe or tool setter in the machine | The tool is brought into contact with a probe or setting surface and the control performs the routine that calculates the length | A value referenced according to the control’s routine and the machine’s reference | The probe or setting surface must be in a known, maintained state; the routine must be the one the shop’s procedure calls for |
| Off-machine presetter | The tool is measured in a separate measuring device and the value is entered into the offset table | A value referenced to the measuring device’s datum | The datum has to correspond to what the machine expects; a correct measurement against the wrong datum is still wrong |
| Defined manual method | A height gauge, setting block, or a documented touch-off establishes the length by a shop-defined method | A value in the shop’s convention | Most sensitive to method drift and to operator variation; it depends on the method being written down and followed |
| Pre-set tooling assemblies | Holders are built to known lengths and the value comes from the assembly | A nominal value derived from how the tool was assembled | Requires discipline in assembly and in verifying that the assembly matches the record |
Achievable accuracy depends on the device and its calibration state, the measurement strategy, how the tool is mounted, the environment, and how the value is transferred into the control. A single precision number attached to “automatic tool setting” describes a device under ideal conditions, not the process in a specific shop. Where a measurement capability has to be stated, it belongs to the machine’s documentation and to the shop’s calibration records — and it can be demonstrated on your own tools rather than asserted on a web page.
Measurement and entry are procedure, not preference. The method, the reference, the stored form and the check that follows are defined by the machine manual and by the shop’s procedure. Where a factory uses more than one method, the risk is not that either method is wrong — it is that a value from one reference is entered as though it came from the other.
H Code vs D Code vs G54
Short answer: these are the three items most often confused with the H address, and they answer three different questions: which length offset is used, which radius offset is used, and where the workpiece is.
| Item | Common role in mill programming | The boundary that matters |
|---|---|---|
H01 | Selects tool length offset entry 1 | It is an entry selector. It is not a length value, and the number carries no measurement information |
G43 | Applies positive tool length compensation on many mill controls | The activation rules, the syntax and the effect on the current position belong to the control documentation |
G44 | Applies negative-direction tool length compensation where a control supports it | Not every machine or program needs it, and it should not be described as the standard way to handle short tools |
G49 | Cancels tool length compensation where this convention is used | When cancellation is required, and what it does to the active position, has to be verified per control and per approved program structure |
T01 | Selects tool 1; the change action itself is defined by the machine | It does not guarantee that a matching offset entry is selected or applied on every control |
D01 | Selects a tool radius or diameter compensation entry in common mill programming | D is not a length offset by default, and how radius data is stored and addressed varies by control. Some tool-management models, such as the Siemens SINUMERIK T and D scheme, use D for cutting-edge data as part of a different addressing model |
G54 | Selects a work coordinate system | It positions the work, not the tool. It is not a tool length offset and should never be discussed as one |
H chooses a length entry, D chooses a radius or cutting-edge entry in common milling practice, G54 chooses where the workpiece is. Work coordinate systems are a separate subject with their own setup and verification steps, and they are covered in the guide linked below rather than repeated here.H Code Differences Across CNC Controllers
Short answer: the H address as a tool length offset selector is a convention of a control family, not a rule of CNC. Every controller-specific detail belongs to the documentation for that controller, and general articles are the worst place to get it from.
| What varies | Why it matters | Where to establish it |
|---|---|---|
| Whether an H address selects a length offset at all | Some environments address tool data through a different model entirely, so an H-based program is not portable as written | The programming manual for the control and for the dialect being used |
| Offset numbering and how far it runs | A range quoted in one manual does not transfer to another machine, and treating it as a general range produces numbering that the control may not accept | The control’s own documentation for the model in question |
| Whether tool and offset numbers are linked | On some controls the pairing is the default; on others it is a setting, and the behaviour when they differ is not the same everywhere | The control’s settings documentation, plus the machine builder’s configuration |
| How tool data is addressed | The Siemens SINUMERIK tool-management model, for example, addresses tools and their cutting edges through a T and D scheme rather than through an H address | The controller manufacturer’s documentation for that control family |
| Activation and cancellation | Commands that apply or remove compensation differ between families, and a machine builder’s tool-change macro may also act on the compensation state | The programming manual and the machine builder’s documentation |
| Where offsets are physically stored | An offset may live in a table, in parameters, or in a tool database, and the internal organisation is version and model specific | The control’s documentation. Parameter maps circulated in forums and general articles are not a substitute for it |
No parameter addresses. No fixed numbering ranges. No statement about what a particular control does by default, and no claim that a command sequence which runs on one machine is safe on another. Each of those details is real and documented — in the manufacturer’s manual for a specific model, not in a general article about H codes. Copying a parameter address or an offset range from the wrong source is how a machine ends up behaving differently from the setup sheet in the operator’s hand.
What the page does instead is show the mechanism and point at the two sources that actually settle the question: the manufacturer’s programming documentation for your control, cited below, and the machine builder’s documentation for your machine.
Common H Code Errors and Troubleshooting
Short answer: tool-length problems are almost always data problems that look like program problems. Work through what the machine currently believes — active tool, active entry, value in that entry, and the reference it was measured from — before changing a single line of the program.
Depth is consistently wrong after a tool change
SymptomThe tool cuts to a depth that is off by a repeatable amount, and the error appears on every part.
Likely causesThe intended offset was never applied for the new tool; the entry holds a value measured for a different tool; the value was measured from a different reference than the control expects; or the value was entered in the wrong unit.
How to verifyConfirm the active tool, confirm which entry is active, read the value in that entry, and compare it with the setup sheet and the measurement record for that tool. A repeatable error points at data; an erratic error points at measurement or clamping.
The first tool is correct and later tools are wrong
SymptomOperation one is good, subsequent operations with other tools are not, and the pattern repeats.
Likely causesThe compensation state carried over between tools differently than intended; the program selects an entry that does not correspond to the tool in the spindle; or the tool-change sequence and the program disagree about who sets the compensation.
How to verifyTrace the compensation state through the tool changes with the machine’s own display of active offsets, and check the pairing between tool numbers and entries in the setup sheet against what the program actually names.
A program behaves differently on another machine
SymptomThe same program, the same tooling, a different result after moving it to another machine of the same nominal type.
Likely causesDifferent offset numbering or offset tables between controls; a different default for linking tool and offset numbers; a different tool-change macro; or offsets that were measured against a different reference on each machine.
How to verifyTreat it as a portability question and establish each machine’s conventions from its own documentation before transferring programs. Do not assume that identically named machines are identically configured.
The offset value looks correct but the result is off by a constant
SymptomEvery part is out by the same amount, which does not change when the program is rerun.
Likely causesA reference mismatch between how the value was measured and how the control expects it; a wrong unit or a units mode change; or a tool assembly that differs from the assembly the value was recorded for.
How to verifyRe-establish one tool by the documented method and check whether the constant disappears. If it does, the method and the reference are the finding — not the program.
The program names an entry that holds nothing usable
SymptomThe result suggests no compensation at all was applied, or a compensation of zero.
Likely causesThe entry was never set; the entry was cleared during setup; or the program names an entry that the setup sheet never assigned.
How to verifyRead the offset table before the run and confirm that every entry the program names holds a value that matches a measured tool. An entry number in a program proves nothing about the value behind it.
“We fixed it in the program”
SymptomA depth error was corrected by editing a coordinate or adding a temporary offset, and the same problem returns later.
Likely causesThe underlying data problem was never found, so the program now carries a compensation that only makes sense while the wrong offset is active.
How to verifyAny change made to work around an offset problem should be recorded as a temporary measure with an owner and a close-out date, and the offset data should be corrected at source. An undocumented program edit is how a machine-shop problem becomes a recurring one.
Safe Verification Before Machining
Short answer: verify what the machine currently believes before it moves. Every item below is a fact you can read from the control, the setup sheet or the measurement record — none of them require you to trust the program listing.
- The tool in the spindle is the tool the setup sheet intends for this operation
- The active offset entry is the one the program intends for that tool
- The value in that entry matches the measurement record for that tool
- The measurement was taken by the documented method, against the documented reference
- The control’s convention for linking tool and offset numbers is the one the setup sheet assumes
- The compensation state at the start of each operation is the state the program intends
- The program has been verified by the machine’s approved procedure before the first cut
- The first cut is checked before the run is allowed to continue
No article — this one included — replaces the operator’s manual for the machine, the machine builder’s documentation, your facility’s procedures, or the program-verification steps your shop requires. The intent here is to make the mechanism clear enough that the documentation answers your question faster, and to make the failure modes recognisable before they happen.
What each role can take from this page
| Role | The question this page answers | Where to go next |
|---|---|---|
| Machine operator | What the H value in the offset table is, and how to check that the active entry matches the tool | The verification list above, then the machine’s own offset display and manual |
| CNC programmer | How a block such as G43 H01 relates to the offset table, and what G49 does and does not guarantee | The program example and its caveats, then the programming manual for the control |
| Manufacturing engineer | Why a multi-tool program can produce a repeatable depth error, and where the process — not the program — is at fault | The troubleshooting section and the measurement methods |
| Student or apprentice | How the H, D and G54 addresses differ, in one table | The comparison table above, then the cited manufacturer documentation |
| Buyer or supplier-quality engineer | Whether a supplier controls tool measurement and offset data as a process, rather than relying on the operator’s memory | Ask for the measurement method, the reference used and the verification step — the questions in this page are the ones worth asking |
FAQ
What is H01 exactly?
H01 is a reference to offset entry number 1 in the control’s tool offset table. It is not a length and it does not contain a measurement. When a program names it in a compensation block, the control reads whichever value currently sits in that entry — which is why the same program can produce different results after setup.
Does the H number have to match the tool number?
Matching is the common convention and on many controls it is the default. Whether a mismatch is permitted, ignored or rejected depends on the control and on settings that the machine builder or the shop can change, so the pairing should be confirmed from the machine’s documentation. Deliberately keeping the pairing — and writing it on the setup sheet — is what makes a program auditable.
What is the difference between G43 and G49?
G43 is the tool length compensation command on many mill controls, used with an H entry to apply the length offset. G49 is the cancel command for that compensation. Both are conventions of a control family: the exact syntax, when each takes effect, and whether a tool-change macro also acts on the compensation state should be confirmed in the programming documentation for the machine.
Why is the Z depth wrong after a tool change?
The usual causes are data, not code: compensation was never applied for the new tool, the entry holds a value measured for another tool, the value was measured against a different reference than the control expects, or the value was entered in the wrong unit. Confirm the active tool, the active entry and the value in it before editing the program — and re-establish one tool by the documented method to see whether the error disappears.
Are H codes the same on every CNC control?
No. The H address as a length-offset selector is a common mill-programming convention rather than a universal rule. Controls differ in offset numbering, in how tool data is addressed, in whether tool and offset numbers are linked, and in how compensation is applied and cancelled. The Siemens SINUMERIK tool-management model, for example, addresses tools and cutting edges through a T and D scheme rather than an H address, and Haas documentation presents the H address as the selector for an offset entry.
Should G49 be used after every tool change?
Not as a universal rule. Whether compensation is cancelled explicitly, replaced by the next compensation command, or handled by the machine’s tool-change sequence depends on the control and on how the program is structured. What matters is that the compensation state at the start of each operation is the state the program intends, and that this is verified against the machine documentation and an approved program structure rather than assumed.
Is the H number used for anything other than tool length?
It depends on the control. On some mill controls the H address is also used with tool-group or similar offset functions, and documentation for those controls shows H values used that way. That is exactly why a general article should not state a two-digit range or a single purpose as though it were universal: the purpose and the range are properties of the control you are standing in front of.
How accurate is automatic tool setting?
There is no meaningful single figure. Achievable accuracy depends on the device and its calibration state, the measurement strategy, how the tool is mounted, the environment, and how the value is transferred into the control. Where a capability figure matters, it belongs to the machine’s documentation and the shop’s calibration records, and it can be demonstrated on your own tools — which is a better answer than a number quoted from a web page.
Sources and Technical Review
How this page was written. The general mechanism described here — an address that selects an offset entry, and a compensation command that applies it — is common to milling practice and is documented by the controller manufacturers themselves. Where this page touches a control-specific behaviour, it either cites the manufacturer documentation or states plainly that the behaviour is control-specific.
| Source | What it is used for here |
|---|---|
| Haas Automation — Mill Operator’s Manual | The H address as the selector for a tool length offset entry, and the use of G43 / G44 to apply and G49 to cancel tool length compensation. The manual’s own examples include H values used for tool group offsets beyond two digits, which is why this page does not present a two-digit range as a rule. |
| Siemens — SINUMERIK documentation on tool compensation and tool management (available from the Siemens Industry Support portal) | The T and D addressing model used in the SINUMERIK tool-management environment, cited here to show that a different addressing model exists and to justify describing controller behaviour as control-specific. The portal is not linked directly because it serves its documents through a session-gated support interface. |
Related CNC Guides
Each of these pages answers a neighbouring question, and they are deliberately kept separate so that the H address, the work coordinate system and the machine reference do not become one long article.
| Guide | What it covers |
|---|---|
| Work coordinate systems and offsets | G54–G59, work offset setting and verification, and the glossary around offsets. This page covers the tool length side of the same subject. |
| What is the code G28 in CNC? | Return to the machine reference point and program positioning. Relevant here because G28 is sometimes mistaken for an offset reset — it is not one. |
| CNC process flow | Setup, execution and verification as a sequence, including trial run and program verification. |
| How to adjust the CNC coordinate offset | The coordinate offset side of machine setup, next to the tool length side covered here. |
| Auto zero touch probing | Machine-based probing, which is one of the ways the values discussed here get established. |
| CNC tool selection for beginners | Choosing the tool in the first place, before its length becomes a number in a table. |
| How to do CNC programming step by step | The wider programming sequence this article sits inside. |
| CNC machining services | How we work from customer drawings and approved samples, if you are looking for a manufacturing partner rather than an explanation. |
Further reading from our CNC library: custom CNC mechanical transmission · custom CNC milling parts manufacturing · the four types of metal stamping · what stepped turning is · the steps to follow when using a CNC machine. These are the guides that were already linked from this page, kept here rather than dropped in the rewrite.
Where this fits on our side of the work
We are a contract manufacturer, so the tool measurement and offset discipline described above is something we run every day rather than write about. If you are evaluating a supplier, the useful questions are the ones in the verification list: which measurement method, against which reference, and what the verification step is before the first cut.
Technical article · not a service page · corrected and reviewed October 2026
What this page does and does not claim
- No parameter addresses, no numbering ranges, no controller defaults. Those details are real, and they live in the manufacturer documentation for a specific control and model. This page explains the mechanism and points at that documentation instead of reproducing fragments of it.
- No accuracy figures for tool measurement. Achievable accuracy depends on the device, its calibration state, the strategy, the mounting, the environment and the transfer into the control.
- No program presented as ready to run. The example is a schematic showing the relationship between a tool call, an offset entry and a compensation command. It carries its own warning for that reason.
- No claim that H is universal. The H address is described as a common mill-programming convention, and the existence of a different addressing model is cited from manufacturer documentation.
- This is a manufacturer’s technical page, not machine documentation. Nothing here overrides the operator’s manual, the machine builder’s documentation or your facility’s procedures.
Published by Xiamen Goldcattle Plastic & Metal Products Co., Ltd., a contract manufacturer founded in 1998 working from customer drawings and approved samples. Technical review for this article was carried out against the controller documentation cited above and is recorded with the October 2026 revision. Corrections to the technical content are welcome from operators, programmers and engineers — a technical page is only as good as its accuracy.
