CNC programming · Tool offsets

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.

Vertical machining centre with the enclosure open, showing a tool holder seated in the spindle, the tool magazine behind it and a clamped workpiece on the table
Quick Answer

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.

TermWhat it does
H addressSelects a tool length offset entry in a common mill-programming convention. It identifies which row of the offset table is used.
Tool length offset valueThe stored compensation data associated with that entry. This is the measured or calculated length the control works with — it is not the H number.
G43A tool length compensation command on many mill controls, used together with an H entry to apply the length offset in the positive sense.
G44The corresponding negative-direction command where a control supports it. Not every program or machine needs it.
G49The 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.

ElementWhat it isWhat it is not
The H addressA selector: it tells the control which offset entry to use, for example entry 1 in H01It is not a length, a measurement or a compensation value
The stored valueThe data in the offset table for that entry — measured or calculated according to the machine’s conventionIt is not part of the program text, and it does not travel with the program
The compensation commandG43 on many mill controls, which applies the selected offset; G44 where the opposite direction is supported; G49 to cancelIt is not a measurement instruction, and it does not itself contain the tool length
The tool number TSelects which tool is called to the spindle, with the change action defined by the machineIt does not guarantee that a matching offset entry is applied automatically
Why the distinction has practical consequences. Because the program only carries the entry number, a program can be perfectly correct and still machine the wrong depth: the program is asking for entry 1, and entry 1 holds a value that was never measured, was measured for a different tool, or was replaced during setup. The program is not wrong — the data it depends on is. That is why the offset table, rather than the program listing, is where tool-length problems usually start.

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.

Program → offset table → machine: the three parts of a tool length offset 1. Program block G43 H01 Z50.0 H01 selects entry 01. The block does not contain a tool length value. 2. Offset table in the control Entry Stored value 01 measured value 02 measured value 03 no usable value The value, not the entry number, is what the control applies. 3. Tool in the spindle programmed Z workpiece The program carries only the entry number. The control holds the value. Nothing in the program tells you what that value is. Entry 03 shows the failure mode: a program can name an entry that has no usable value, and the program itself is still valid.

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.

ElementWhat it selects or holdsExampleWhere that comes from
T01Which tool is called to the spindleTool 1The machine’s tool-change configuration and the tool loaded in the magazine
H01Which offset entry is selectedEntry 01The program text
Value in entry 01The compensation data the control applies128.412 mm — example value onlyThe machine’s measurement method and setup convention, entered in the offset table
Resulting tool tip positionWhere the tool tip actually goesDetermined by the controlThe combination of the coordinate, the stored value and how that value was referenced
The value in that table is an example of the form of the data, not a measured value from any machine. It is written as a decimal length because that is a common form of storage, but the same entry could hold a value referenced differently, and the number itself means nothing without the reference it was measured from.

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.

Tool presetting and measuring device holding a tool holder with an end mill, with a digital readout unit on the bench and hand measuring tools beside it
Whether the length is established in the machine, on a presetter or by a defined manual method, the stored value is only meaningful together with the reference it was measured from. That reference is defined by the machine documentation and the shop procedure, not by the article describing the method.
MethodWhat happensWhat the stored value representsWhat to watch
Touch probe or tool setter in the machineThe tool is brought into contact with a probe or setting surface and the control performs the routine that calculates the lengthA value referenced according to the control’s routine and the machine’s referenceThe 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 presetterThe tool is measured in a separate measuring device and the value is entered into the offset tableA value referenced to the measuring device’s datumThe datum has to correspond to what the machine expects; a correct measurement against the wrong datum is still wrong
Defined manual methodA height gauge, setting block, or a documented touch-off establishes the length by a shop-defined methodA value in the shop’s conventionMost sensitive to method drift and to operator variation; it depends on the method being written down and followed
Pre-set tooling assembliesHolders are built to known lengths and the value comes from the assemblyA nominal value derived from how the tool was assembledRequires discipline in assembly and in verifying that the assembly matches the record
Why this page quotes no accuracy figure for tool measurement

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.

ItemCommon role in mill programmingThe boundary that matters
H01Selects tool length offset entry 1It is an entry selector. It is not a length value, and the number carries no measurement information
G43Applies positive tool length compensation on many mill controlsThe activation rules, the syntax and the effect on the current position belong to the control documentation
G44Applies negative-direction tool length compensation where a control supports itNot every machine or program needs it, and it should not be described as the standard way to handle short tools
G49Cancels tool length compensation where this convention is usedWhen cancellation is required, and what it does to the active position, has to be verified per control and per approved program structure
T01Selects tool 1; the change action itself is defined by the machineIt does not guarantee that a matching offset entry is selected or applied on every control
D01Selects a tool radius or diameter compensation entry in common mill programmingD 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
G54Selects a work coordinate systemIt positions the work, not the tool. It is not a tool length offset and should never be discussed as one
A one-line way to keep them apart: 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 variesWhy it mattersWhere to establish it
Whether an H address selects a length offset at allSome environments address tool data through a different model entirely, so an H-based program is not portable as writtenThe programming manual for the control and for the dialect being used
Offset numbering and how far it runsA 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 acceptThe control’s own documentation for the model in question
Whether tool and offset numbers are linkedOn some controls the pairing is the default; on others it is a setting, and the behaviour when they differ is not the same everywhereThe control’s settings documentation, plus the machine builder’s configuration
How tool data is addressedThe Siemens SINUMERIK tool-management model, for example, addresses tools and their cutting edges through a T and D scheme rather than through an H addressThe controller manufacturer’s documentation for that control family
Activation and cancellationCommands that apply or remove compensation differ between families, and a machine builder’s tool-change macro may also act on the compensation stateThe programming manual and the machine builder’s documentation
Where offsets are physically storedAn offset may live in a table, in parameters, or in a tool database, and the internal organisation is version and model specificThe control’s documentation. Parameter maps circulated in forums and general articles are not a substitute for it
What this page deliberately does not contain

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
What this page cannot do for you

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

RoleThe question this page answersWhere to go next
Machine operatorWhat the H value in the offset table is, and how to check that the active entry matches the toolThe verification list above, then the machine’s own offset display and manual
CNC programmerHow a block such as G43 H01 relates to the offset table, and what G49 does and does not guaranteeThe program example and its caveats, then the programming manual for the control
Manufacturing engineerWhy a multi-tool program can produce a repeatable depth error, and where the process — not the program — is at faultThe troubleshooting section and the measurement methods
Student or apprenticeHow the H, D and G54 addresses differ, in one tableThe comparison table above, then the cited manufacturer documentation
Buyer or supplier-quality engineerWhether a supplier controls tool measurement and offset data as a process, rather than relying on the operator’s memoryAsk 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.

SourceWhat it is used for here
Haas Automation — Mill Operator’s ManualThe 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.
Technical review. The explanations on this page were checked against the manufacturer documentation cited above, and the page deliberately avoids claims that cannot be traced to it — no parameter addresses, no numbering ranges, no accuracy figures and no program presented as ready to run. Reviewed October 2026 for the version of this page published here.

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.

GuideWhat it covers
Work coordinate systems and offsetsG54–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 flowSetup, execution and verification as a sequence, including trial run and program verification.
How to adjust the CNC coordinate offsetThe coordinate offset side of machine setup, next to the tool length side covered here.
Auto zero touch probingMachine-based probing, which is one of the ways the values discussed here get established.
CNC tool selection for beginnersChoosing the tool in the first place, before its length becomes a number in a table.
How to do CNC programming step by stepThe wider programming sequence this article sits inside.
CNC machining servicesHow 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.

Recommended Reading