Reference
G-Code List — Every G-Code Explained with Examples
Complete G-code list for CNC mills and lathes (Fanuc, Haas, Mazak, Siemens ISO). Each code with syntax, parameters, example program and common mistakes.
All common G-codes for CNC mills and lathes, in the Fanuc/ISO dialect used by most controls. Click a code for syntax, parameters and a working example.
Fanuc listHaas listGRBL listSiemens SINUMERIK listM-codesPrintable cheat sheet
| Code | Function | Group | Type | Machine |
|---|---|---|---|---|
G00 | Rapid Positioning | 01 | Modal | Both |
G01 | Linear Interpolation (Feed Move) | 01 | Modal | Both |
G02 | Circular Interpolation Clockwise | 01 | Modal | Both |
G03 | Circular Interpolation Counter-Clockwise | 01 | Modal | Both |
G04 | Dwell | 00 | One-shot | Both |
G05.1 | AI Contour Control / High-Speed Look-Ahead | — | Modal | Mill |
G07.1 | Cylindrical Interpolation | 18 | Modal | Both |
G08 | Advanced Preview Control (Look-Ahead) | 19 | Modal | Mill |
G09 | Exact Stop (one block) | 00 | One-shot | Both |
G10 | Programmable Data Input (Set Offsets) | 00 | One-shot | Both |
G11 | Programmable Data Input Cancel | 00 | One-shot | Both |
G12 | Circular Pocket Milling CW (Haas) / Polar Interpolation (Lathe G12.1) | 00 | One-shot | Mill |
G13 | Circular Pocket Milling CCW (Haas) / Cancel Polar Interpolation (G13.1) | 00 | One-shot | Mill |
G15 | Polar Coordinate Command Cancel | 17 | Modal | Mill |
G16 | Polar Coordinate Command | 17 | Modal | Mill |
G17 | XY Plane Selection | 02 | Modal | Mill |
G18 | XZ Plane Selection | 02 | Modal | Both |
G19 | YZ Plane Selection | 02 | Modal | Mill |
G20 | Inch Input | 06 | Modal | Both |
G21 | Metric Input | 06 | Modal | Both |
G22 | Stored Stroke Check On | 04 | Modal | Both |
G23 | Stored Stroke Check Off | 04 | Modal | Both |
G25 | Spindle Speed Fluctuation Detection Off | 08 | Modal | Lathe |
G26 | Spindle Speed Fluctuation Detection On | 08 | Modal | Lathe |
G27 | Reference Position Return Check | 00 | One-shot | Both |
G28 | Return to Reference Point (Machine Home) | 00 | One-shot | Both |
G28.1 | Set Predefined Position (GRBL / LinuxCNC) | 00 | One-shot | Mill |
G30 | Return to 2nd/3rd/4th Reference Point | 00 | One-shot | Both |
G30.1 | Set Second Predefined Position (GRBL / LinuxCNC) | 00 | One-shot | Mill |
G31 | Skip Function (Probing Move) | 00 | One-shot | Both |
G32 | Thread Cutting (Single Pass, Lathe) | 01 | Modal | Lathe |
G33 | Thread Cutting (Spindle-Synchronised Motion) | 01 | Modal | Mill |
G34 | Variable Lead Thread Cutting | 01 | Modal | Lathe |
G36 | Automatic Tool Compensation X (Lathe) | 00 | One-shot | Lathe |
G37 | Automatic Tool Length Measurement | 00 | One-shot | Both |
G38.2 | Straight Probe Toward Workpiece (Stop on Contact, Error if Not) | 01 | One-shot | Mill |
G38.3 | Straight Probe Toward Workpiece (No Error) | 01 | One-shot | Mill |
G39 | Corner Offset Circular Interpolation | 00 | One-shot | Mill |
G40 | Cutter Radius Compensation Cancel | 07 | Modal | Both |
G41 | Cutter Radius Compensation Left | 07 | Modal | Both |
G41.1 | Normal Direction Control (Left / Right) | 19 | Modal | Mill |
G42 | Cutter Radius Compensation Right | 07 | Modal | Both |
G43 | Tool Length Compensation (+) | 08 | Modal | Mill |
G43.1 | Dynamic Tool Length Offset (GRBL / LinuxCNC) | 08 | Modal | Mill |
G43.4 | Tool Centre Point Control (TCPC) | 08 | Modal | Mill |
G44 | Tool Length Compensation (−) | 08 | Modal | Mill |
G45 | Tool Position Offset (Increase) | 00 | One-shot | Mill |
G49 | Tool Length Compensation Cancel | 08 | Modal | Mill |
G50 | Max Spindle Speed Clamp (Lathe) / Scaling Cancel (Mill) | 00 | One-shot | Both |
G50.1 | Programmable Mirror Image Cancel | 22 | Modal | Mill |
G51 | Scaling | 11 | Modal | Mill |
G51.1 | Programmable Mirror Image | 22 | Modal | Mill |
G51.2 | Polygon Turning | 20 | Modal | Lathe |
G52 | Local Coordinate System | 00 | One-shot | Both |
G53 | Machine Coordinate System (One Block) | 00 | One-shot | Both |
G53.1 | Tool Axis Direction Control | 00 | One-shot | Mill |
G54 | Work Coordinate System 1 | 14 | Modal | Both |
G54.1 | Additional Work Coordinate Systems | 14 | Modal | Mill |
G55 | Work Coordinate System 2 | 14 | Modal | Both |
G56 | Work Coordinate System 3 | 14 | Modal | Both |
G57 | Work Coordinate System 4 | 14 | Modal | Both |
G58 | Work Coordinate System 5 | 14 | Modal | Both |
G59 | Work Coordinate System 6 | 14 | Modal | Both |
G60 | Single Direction Positioning | 00 | One-shot | Mill |
G61 | Exact Stop Mode | 15 | Modal | Both |
G62 | Automatic Corner Override | 15 | Modal | Mill |
G63 | Tapping Mode | 15 | Modal | Mill |
G64 | Cutting Mode (Continuous Path) | 15 | Modal | Both |
G65 | Macro Call (Non-Modal) | 00 | One-shot | Both |
G66 | Modal Macro Call | 12 | Modal | Both |
G67 | Modal Macro Call Cancel | 12 | Modal | Both |
G68 | Coordinate System Rotation | 16 | Modal | Mill |
G68.2 | Tilted Working Plane (3+2) | 16 | Modal | Mill |
G69 | Coordinate Rotation Cancel | 16 | Modal | Mill |
G70 | Finishing Cycle (Lathe) | 00 | One-shot | Lathe |
G71 | Stock Removal in Turning (Roughing Cycle) | 00 | One-shot | Lathe |
G72 | Stock Removal in Facing | 00 | One-shot | Lathe |
G73 | Pattern Repeating (Lathe) / High-Speed Peck Drilling (Mill) | 00/09 | One-shot | Both |
G74 | Left-Hand Tapping (Mill) / Face Peck Drilling (Lathe) | 09 | One-shot | Both |
G75 | Grooving Cycle (Lathe X) | 00 | One-shot | Lathe |
G76 | Threading Cycle (Lathe) / Fine Boring (Mill) | 00/09 | One-shot | Both |
G80 | Cancel Canned Cycle | 09 | Modal | Both |
G81 | Drilling Cycle (Spot Drill) | 09 | Modal | Mill |
G82 | Drilling Cycle with Dwell (Counterbore / Spot) | 09 | Modal | Mill |
G83 | Peck Drilling Cycle (Deep Hole) | 09 | Modal | Mill |
G84 | Tapping Cycle (Right-Hand) | 09 | Modal | Mill |
G85 | Boring Cycle (Feed In, Feed Out) | 09 | Modal | Mill |
G86 | Boring Cycle (Spindle Stop, Rapid Out) | 09 | Modal | Mill |
G87 | Back Boring Cycle | 09 | Modal | Mill |
G88 | Boring Cycle (Dwell, Manual Retract) | 09 | Modal | Mill |
G89 | Boring Cycle (Dwell, Feed Out) | 09 | Modal | Mill |
G90 | Absolute Programming (Mill) / OD Turning Cycle (Lathe) | 03/01 | Modal | Both |
G90.1 | Absolute Arc Centre Mode (IJK) | — | Modal | Mill |
G91 | Incremental Programming | 03 | Modal | Mill |
G92 | Coordinate System Setting (Mill) / Threading Cycle (Lathe) | 00/01 | One-shot | Both |
G92.1 | Cancel G92 Offset / Coordinate Preset | 00 | One-shot | Both |
G93 | Inverse Time Feed | 05 | Modal | Mill |
G94 | Feed per Minute (Mill) / Facing Cycle (Lathe) | 05/01 | Modal | Both |
G95 | Feed per Revolution (Mill) | 05 | Modal | Mill |
G96 | Constant Surface Speed (CSS) | 02 | Modal | Lathe |
G97 | Constant RPM (CSS Cancel) | 02 | Modal | Lathe |
G98 | Initial Plane Return (Mill) / Feed per Minute (Lathe) | 10/05 | Modal | Both |
G99 | R-Plane Return (Mill) / Feed per Revolution (Lathe) | 10/05 | Modal | Both |
G101 | Mirror Image On (Haas) | 11 | Modal | Mill |
G103 | Limit Block Look-Ahead (Haas) | 00 | Modal | Mill |
G107 | Cylindrical Mapping / Interpolation | 00 | One-shot | Both |
G112 | Polar Coordinate Interpolation On (Lathe) | 21 | Modal | Lathe |
G141 | 3D Cutter Compensation (Haas) | 07 | Modal | Mill |
G143 | 5-Axis Tool Length Compensation (Haas) | 08 | Modal | Mill |
G150 | General Purpose Pocket Milling (Haas) | 00 | One-shot | Mill |
G154 | Additional Work Offsets (Haas) | 12 | Modal | Mill |
G187 | Smoothness / Accuracy Control (Haas) | — | Modal | Mill |
G234 | Tool Centre Point Control (Haas TCPC) | 08 | Modal | Mill |
G254 | Dynamic Work Offset (Haas DWO) | 23 | Modal | Mill |
G268 | Feature Coordinate System (Haas Tilted Plane) | 16 | Modal | Mill |