G41 shifts the tool left of the programmed path. G42 shifts the tool right. G40 cancels the shift. Cutter compensation (also called tool radius compensation) automatically adjusts the tool path by the tool radius so the machine cuts to the programmed size regardless of the actual tool diameter.
Without cutter compensation, if your actual tool measures 0.480 inches instead of the programmed 0.500 inches, every part feature comes out 0.020 inches oversize. With compensation, you change one number in the offset register and all parts come out correct. I learned this the hard way early in my career when I scrapped an entire batch of parts because I forgot to account for a reground end mill that was 0.015 inches smaller than nominal. Cutter compensation would have easily saved all of those scrapped parts with a single offset value edit on the control.
G41 vs G42: Which One to Use
The direction depends on the cutting direction and profile type. The rule is simple: G41 offsets to the left of the tool path. G42 offsets to the right.
| Code | Direction | When to Use |
|---|---|---|
| G41 | Left of path | Climb milling external profiles (program clockwise) |
| G42 | Right of path | Conventional milling or climb milling internal pockets |
| G40 | Cancel | After finishing the contour, before next operation |
Quick Reference by Profile
| Profile Type | Milling Method | Direction | G-Code |
|---|---|---|---|
| External (boss) | Climb | Clockwise | G41 |
| External (boss) | Conventional | Counterclockwise | G42 |
| Internal (pocket) | Climb | Counterclockwise | G41 |
| Internal (pocket) | Conventional | Clockwise | G42 |
Climb milling (tool rotates same direction as feed) is the standard for CNC. Use G41 for most external profiles.
The Three-Step Process
Cutter compensation always follows the same three steps:
Step 1: ACTIVATE — Move to start position, then call G41/G42 with a linear feed move
Step 2: CUT — Program the part geometry using actual print dimensions
Step 3: CANCEL — Move away from part, call G40 with a linear move
Critical Rules
| Rule | Why It Matters |
|---|---|
| Lead-in move must be ≥ tool radius | If too short, control alarms — cannot calculate offset |
| Activate on linear move only (G00/G01) | G02/G03 arcs cause alarm |
| Cancel on linear move only | Same rule — must use G00 or G01 with G40 |
| Activate before entering material | Tool needs room to shift by the offset amount |
Complete Programming Example
Here is a complete program milling the outside of a 1.5 × 1.75 inch rectangle with a 0.500 inch end mill using G41:
N10 G90 G54 G00 X-0.5 Y-0.5 ; Position to start, clear of part
N20 S1500 M03 ; Start spindle
N30 G43 H01 Z0.1 M08 ; Tool length offset, coolant on
N40 G01 Z-0.25 F50 ; Plunge to depth
N50 G41 D01 X0 F12 ; ACTIVATE comp (tool radius in D01)
N60 Y1.75 ; Cut bottom → top
N70 X1.5 ; Cut right
N80 Y0 ; Cut top → bottom
N90 X-0.5 ; Cut left (past edge)
N100 G40 X-0.75 ; CANCEL comp while moving away
N110 G00 Z1 M09 ; Retract
N120 M30 ; End program
What happens at the machine:
| Line | Tool Position | What’s Happening |
|---|---|---|
| N50 | Moves from X-0.5 to X0 | Control shifts tool left by 0.250“ (D01 value) |
| N60-N90 | Follows rectangle path | Tool stays 0.250“ outside the programmed coordinates |
| N100 | Moves past X-0.5 to X-0.75 | G40 removes the offset, tool returns to center path |
If the tool wears from 0.500 to 0.480 inches, change D01 from 0.250 to 0.240 — no G-code editing needed. This is the primary benefit of cutter compensation.
How Compensation Works and D Offset Registers
When G41 or G42 is activated, the control does not simply shift every move by the D value. It recalculates the entire tool path using a parallel curve algorithm. The controller looks ahead multiple blocks to determine the correct position at each transition between moves.
At inside corners where the direction changes toward the offset side, the control inserts an arc equal to the tool radius. This arc prevents the tool from gouging into the corner. The radius of the inserted arc matches the D offset value exactly. At outside corners where the direction changes away from the offset side, the tool follows a path that maintains the offset distance perpendicular to the programmed geometry.
This calculation is why the lead-in move must be linear and at least as long as the tool radius. The control needs a straight reference segment to establish the direction of the offset before it encounters any direction changes in the programmed contour.
The D word tells the control which offset register holds the tool radius.
| Control Brand | H and D Shared? | D Value Is | Max Value |
|---|---|---|---|
| Haas | Yes (H01 = D01) | Tool radius | 0.9999 in |
| Fanuc | Typically separate | Radius or diameter (parameter) | Varies |
| Siemens | Separate (tool mgmt) | Radius | Unlimited |
flowchart LR
A[Program part geometry] --> B{CAM compensation mode?}
B -->|Computer| C[CAM offsets toolpath<br/>No G41/G42 output]
B -->|Control| D[CAM outputs G41/G42<br/>D = full tool radius]
B -->|Wear| E[CAM offsets toolpath + outputs G41/G42<br/>D = difference from theoretical tool]
C --> F[Adjust at machine?]
D --> F
E --> F
F -->|Yes| G[Edit D offset register<br/>no program change]
F -->|No| H[Run as-is]
Wear compensation is the recommended mode for production. The CAM generates the toolpath for the theoretical tool and outputs G41/G42. The D register contains zero for a new tool, or a small value to compensate for wear. This gives you both accurate CAM toolpaths and the ability to adjust at the machine.
Common Mistakes (and How to Fix Them)
| Mistake | Symptom | Fix |
|---|---|---|
| Lead-in too short | Control alarms when G41/G42 activated | Make the linear move ≥ tool radius |
| Arc move on activation | Alarm on G02/G03 with G41 | Use G00 or G01 to activate |
| Forgot G40 | Next operation cuts in wrong position | Always add G40 before moving to next feature |
| Wrong direction (G41 vs G42) | Tool cuts on wrong side of profile | Check: climb external = G41 clockwise |
| Activated inside pocket | Alarm — no room to shift | Activate compensation before entering material |
| D offset = 0 on first run | No visible offset — hard to verify | Test with D = 0.010 first, then use actual value |
How to Test Safely
- Dry run — Run program with no tool, no D offset active. Verify path is correct.
- Small offset test — Set D to 0.010 inches, run again with no tool. Watch for smooth shift at the lead-in move.
- Above part test — Run at safe Z height with actual D offset. Verify direction is correct.
- Scrap test — Cut in scrap material. Measure result. Adjust D offset if needed.
This 15-minute testing sequence catches every common cutter compensation error before it scraps a real part.
Cutter Compensation vs Tool Length Offset
| Feature | G-Code | Offset Register | Axis | What It Compensates |
|---|---|---|---|---|
| Tool length offset | G43 | H | Z | Different tool lengths |
| Cutter compensation | G41/G42 | D | X, Y | Different tool diameters |
These are independent features. Most production programs use both: H for Z positioning (tool length), D for XY positioning (cutter radius). On Haas controls, H01 and D01 share the same register. On Fanuc, they are typically separate.
When to Use Cutter Compensation
| ✅ Use It | ❌ Skip It |
|---|---|
| Finishing passes where final dimensions matter | Roughing operations |
| Same program with different tool sizes | Simple drilling/tapping cycles |
| Adjusting for tool wear without reprogramming | Programs where CAM handles all offsets |
| Multi-pass finishing with decreasing offsets | Ultra-high-speed machining where control processing time matters |
CAM Compensation Modes
Most CAM software supports three modes for handling cutter compensation. Choosing the right mode affects how the program runs at the machine.
Computer compensation is the simplest mode. The CAM software calculates the offset toolpath and outputs standard G-code without G41 or G42. The machine runs the path as programmed with no compensation active. This works well for roughing but does not allow any adjustment at the machine. If the tool wears, you must regenerate the toolpath in CAM.
Control compensation outputs G41 and G42 in the G-code and expects the D register to contain the full tool radius. The CAM software outputs the part geometry coordinates directly. The control handles all offset calculations. This gives full adjustability at the machine but requires the D register to be set correctly for every tool.
Wear compensation is the recommended mode for most production work. The CAM software calculates the offset toolpath and also outputs G41 and G42. The D register contains zero for a new tool, or a small value to compensate for tool wear or thermal growth. This combines the benefits of both approaches: the CAM handles the complex toolpath geometry and you can make fine adjustments at the machine without regenerating the CAM program.
| Mode | CAM Output | D Register | Adjustable at Machine? |
|---|---|---|---|
| Computer | Offset coordinates, no G41/G42 | Not used | No — must re-post |
| Control | Part geometry + G41/G42 | Full tool radius | Yes — change D value |
| Wear | Offset coordinates + G41/G42 | Zero or small wear value | Yes — fine adjustments |
Advanced Tip: One Program for Roughing and Finishing
Set D01 = 0.260 for roughing (leaves 0.010 stock), then set D01 = 0.250 for finishing. The same program cuts both operations — no separate roughing and finishing programs needed. This technique is especially useful for small shops where program storage and setup time are limited.
Cutter compensation is one of the most valuable and useful G-code features for production machining. The ability to adjust part size at the machine by changing a single offset value saves time, reduces scrap, and makes programs reusable with different tool sizes. Every CNC programmer should understand how G41, G42, and G40 work and use them appropriately in their programs.
The key points to remember are: activate compensation on a linear move with enough distance, use climb milling with G41 for most external profiles, cancel with G40 after finishing the contour, and always test with a small offset value before cutting material. Following these rules prevents the common mistakes that crash tools and scrap parts.
Testing Cutter Compensation Safely
Cutter compensation errors can crash tools and damage parts if not tested carefully. A systematic four-step testing approach catches errors before they cause damage.
Step 1: Dry run without offset. Load the program and run it with no tool in the spindle and no D offset active. Watch the tool path on the control display. Verify that all movements stay within the expected area and there are no unexpected rapid moves into clamp or fixture locations.
Step 2: Small offset test. Set the D register to a small value such as 0.010 inches and run the program again at the machine with no tool. Watch for any sudden movements when G41 or G42 is activated. The tool path should shift smoothly by the offset amount at the lead-in move. A jerky or unexpected movement indicates a problem with the lead-in geometry.
Step 3: Above-part test. Load the actual tool and set the correct D offset value. Raise the tool to a safe Z height well above the workpiece. Run the program and verify that the offset amount and direction are correct. Check that the tool stays on the correct side of the profile throughout the entire contour.
Step 4: Scrap test cut. Cut the program in a piece of scrap material that matches the actual workpiece material. Measure the resulting part dimensions with calipers or a micrometer. Compare the measured dimensions to the programmed dimensions. The difference should match the expected offset behavior. Adjust the D offset value if needed to achieve the correct size.
This four-step testing process takes about 15 minutes and catches every common cutter compensation error before it can damage a real part.
Summary and Key Rules
Cutter compensation with G41 and G42 is a powerful feature that every CNC programmer should understand and use. The ability to adjust part dimensions at the machine by editing a single offset value saves significant time on the shop floor, reduces material scrap from tool wear, and makes programs reusable with different tool sizes without reprogramming in CAM.
| Rule | Why |
|---|---|
| Activate on linear move only | Arcs cannot establish the offset direction |
| Lead-in distance ≥ tool radius | Control needs room to calculate the offset |
| Cancel with G40 after every contour | Otherwise offset applies to next operation |
| Use climb milling with G41 for externals | Standard CNC cutting practice |
| Test with small D value first | Catches direction errors before they crash the tool |
Cutter compensation effectively turns a rigid program that cuts one exact part size into a flexible program that cuts any desired size by simply changing one number in the offset register. That flexibility and time-saving capability is why G41 and G42 are essential tools in every CNC programmer’s skill set and daily workflow.
Once you are comfortable and confident with G41 and G42, try adding cutter compensation to your very next finishing program. Start with a simple external profile on a test part. Use wear compensation mode in your CAM software. Set the D offset to zero for the first run, verify the size, and then adjust the offset to fine-tune the dimension. The ability to precisely dial in the exact part size at the machine without modifying or reposting the program is one of the most satisfying and productive skills in CNC machining.
The ability to control part size at the machine by changing a single number is one of the most valuable skills in CNC programming. Practice with simple external profiles first, then move on to internal pockets and multi-pass operations as your confidence grows.
For more G-code programming guides see our G-Code for Beginners guide and our Common G-Code Mistakes guide. For more on tooling see our CNC End Mill Selection Guide.

G02 and G03: Circular Interpolation for CNC ProgrammingJune 26, 2026 · Tutorials
CNC Conversational Programming Guide: A Beginner's IntroductionJune 27, 2026 · Tutorials