G-codes select the motion and machine modes; M-codes switch machine functions such as spindle and coolant. Both are modal in most cases: once a G-code is active it stays active until another code in the same group replaces it. The tables below follow the ISO/Fanuc convention used by most machining centres and lathes.
Common G-codes
| Code | Group | What it does |
|---|---|---|
| G00 | Motion | Rapid traverse to the programmed point |
| G01 | Motion | Linear interpolation at the programmed feed |
| G02 / G03 | Motion | Circular interpolation, clockwise / counter-clockwise |
| G04 | Non-modal | Dwell for a set time |
| G17 / G18 / G19 | Plane | Select the working plane: XY / ZX / YZ |
| G20 / G21 | Units | Inch / metric programming |
| G28 | Non-modal | Return to machine home, usually through a reference point |
| G40 / G41 / G42 | Cutter comp | Cancel / radius compensation left / right |
| G43 / G44 / G49 | Tool length | Apply tool length offset + / -, cancel |
| G52 | Offset | Local coordinate system shift |
| G53 | Machine coords | Move in machine coordinates, ignoring work offsets |
| G54–G59 | Work offsets | Select the work coordinate system |
| G73 / G83 | Canned drilling | Peck drilling with chip break / full retract |
| G76 | Canned | Threading cycle (multi-pass, lathe) |
| G80 | Canned | Cancel canned cycle |
| G81–G89 | Canned | Drilling, boring and tapping cycles |
| G90 / G91 | Positioning | Absolute / incremental programming |
| G94 / G95 | Feed mode | Feed per minute / feed per revolution |
| G96 / G97 | Spindle mode | Constant surface speed / constant rpm |
Common M-codes
| Code | What it does |
|---|---|
| M00 | Program stop |
| M01 | Optional stop, active when the panel switch is on |
| M02 / M30 | End of program / end and rewind |
| M03 / M04 / M05 | Spindle clockwise / counter-clockwise / stop |
| M06 | Tool change |
| M08 / M09 | Coolant on / off |
| M98 / M99 | Call subprogram / return from subprogram |
Three practical warnings. Modal groups mean a missing cancel can carry an unintended mode into the next operation — G43 without G49, or G41 without G40, are classic crash sources. Canned cycles remember their parameters, so the R plane and depth from a previous hole set can apply to the next one. And M-code numbering beyond the basics is builder-specific: tool change, pallet change and probe calls differ between controls.
For the arithmetic behind feed and speed values, see the speeds and feeds calculator.