FREE CNC TOOL · Code quick lookup
G-code / M-code List (Common FANUC Codes)
The functions and usage notes for common G / M codes—type a code or keyword to filter instantly. Dialect differences are flagged.
Common G codes (preparatory functions)
| Code | Function | Description |
|---|---|---|
| G00 | Rapid positioning | Moves at the machine's maximum speed, no cutting; slow down and plan the approach before reaching the workpiece |
| G01 | Linear cutting feed | Straight-line cutting at the feed rate set by F |
| G02 | Circular interpolation (clockwise) | Define the arc with R or I/J/K |
| G03 | Circular interpolation (counterclockwise) | Same as above, opposite direction |
| G04 | Dwell | X/P sets the number of seconds; commonly used for a pause at the hole bottom |
| G17 | XY plane selection | Default milling plane |
| G18 | ZX plane selection | Common in turning |
| G19 | YZ plane selection | — |
| G20 | Inch units | Switch input units to inches |
| G21 | Metric units | Switch input units to mm |
| G28 | Return to machine home | Returns to the reference point via an intermediate point; mind path safety |
| G40 | Cutter radius compensation cancel | — |
| G41 | Cutter radius compensation left | Tool on the left of the contour along the direction of travel |
| G42 | Cutter radius compensation right | Tool on the right of the contour along the direction of travel |
| G43 | Tool length compensation (positive) | Used with the H offset number |
| G49 | Tool length compensation cancel | — |
| G52 | Local coordinate system | — |
| G53 | Machine coordinate system positioning | Unaffected by the work coordinate system |
| G54 | Work coordinate system 1 | G54–G59 provide six sets |
| G59 | Work coordinate system 6 | — |
| G61 | Exact stop mode | Precise corners, slower speed |
| G64 | Cutting mode | Continuous, smooth feed |
| G65 | Macro single call | — |
| G68 | Coordinate rotation | Used with the R angle |
| G69 | Coordinate rotation cancel | — |
| G73 | High-speed peck drilling cycle | Fast pecking with a small retract |
| G74 | Left-hand tapping cycle | Reverse-rotation tapping |
| G76 | Fine boring cycle | Oriented retract to clear the bore |
| G80 | Canned cycle cancel | — |
| G81 | Drilling cycle | Straight to depth in one pass |
| G82 | Drilling cycle (dwell at hole bottom) | Counterbores; improves hole-bottom quality |
| G83 | Peck drilling cycle | Full retract to clear chips |
| G84 | Tapping cycle | With M29 for rigid tapping |
| G85 | Boring cycle (feed out) | — |
| G90 | Absolute command | Coordinates referenced to the workpiece origin |
| G91 | Incremental command | Coordinates referenced to the current position |
| G92 | Coordinate system setting | Legacy approach, use with care |
| G94 | Feed per minute | mm/min (milling default) |
| G95 | Feed per revolution | mm/rev |
| G98 | Cycle end, return to initial plane | Use when clearing fixtures |
| G99 | Cycle end, return to R plane | Faster for consecutive holes |
Common M codes (miscellaneous functions)
| Code | Function | Description |
|---|---|---|
| M00 | Program stop | Press start to continue |
| M01 | Optional stop | Stops only when the panel OP Stop is on |
| M02 | Program end | No return |
| M03 | Spindle CW | Used with the S speed |
| M04 | Spindle CCW | — |
| M05 | Spindle stop | — |
| M06 | Automatic tool change | Used with the T tool number |
| M08 | Coolant on | — |
| M09 | Coolant off | — |
| M19 | Spindle orientation | Fine boring, tool-change orientation |
| M29 | Rigid tapping mode | Takes effect on the following G84 line |
| M30 | Program end and rewind | Most commonly used ending |
| M98 | Call subprogram | Used with the P program number |
| M99 | Subprogram end/return | Used at the end of a main program it creates an infinite loop |
This table is based on FANUC conventions. Mitsubishi, Siemens, Heidenhain, Syntec and other controllers have dialect differences (lead-in codes, cycle parameters, differing definitions for some M codes), so before running on the machine defer to the machine builder's original manual—this is exactly why AI-generated G-code must go through simulation and machinist sign-off.
FAQ
What is the difference between G00 and G01?
G00 is rapid positioning, moving at the machine's maximum speed with no guarantee of a straight-line path (on some controllers each axis moves independently); G01 is linear cutting at the F feed rate. Always use G01 to slow down and feed in when approaching the workpiece.
How do I choose between G73 and G83?
G73 uses a small retract and is fast, suited to shallow holes and free-cutting materials; G83 fully retracts clear of the hole each time to clear chips, so use G83 for deep holes (roughly 3× diameter and up) and hard-to-evacuate materials.
What is the difference between M02 and M30?
Both end the program; M30 additionally returns the cursor to the top of the program, which is used for production cycles—M30 is the conventional choice for a normal ending.
Further reading: What is G-code? A complete introduction · Touch-off and G54 work coordinates · Crash prevention | More tools: Tools hub
BEYOND LOOKUP
More than a code lookup—AI generates a complete, verifiable program for you
BestAI CAM outputs G-code in the format matching your shop's controller, then runs cutting simulation and AI dimensional verification before handing it to the machinist for sign-off.
See how to get started