A quick reference to the G-codes and M-codes you use most. G-codes control geometry and motion; M-codes control machine functions like the spindle and coolant. Exact behavior can vary by controller, so always confirm against your machine post.
Common G-codes
| Code | Function |
|---|---|
| G00 | Rapid positioning (non-cutting move) |
| G01 | Linear feed move (straight cut) |
| G02 | Circular interpolation, clockwise (arc) |
| G03 | Circular interpolation, counterclockwise |
| G04 | Dwell (timed pause) |
| G17 / G18 / G19 | Select XY / XZ / YZ working plane |
| G20 / G21 | Units in inches / millimeters |
| G28 | Return to machine home |
| G40 | Cancel cutter compensation |
| G41 / G42 | Cutter compensation left / right |
| G43 | Apply tool length offset |
| G54–G59 | Work coordinate systems (part zero) |
| G80 | Cancel canned cycle |
| G81 | Standard drilling cycle |
| G83 | Peck drilling cycle |
| G90 / G91 | Absolute / incremental positioning |
Common M-codes
| Code | Function |
|---|---|
| M00 | Program stop |
| M01 | Optional stop |
| M03 / M04 | Spindle on clockwise / counterclockwise |
| M05 | Spindle stop |
| M06 | Tool change |
| M08 / M09 | Coolant on / off |
| M30 | Program end and rewind |
Reference set for milling controls. Lathe and multi-axis machines add codes (constant surface speed, tool nose comp); check your controller manual.
For the spoken vocabulary behind the codes, see the Machining Glossary, and run setup numbers in G-code & CNC calculators.
How to use the cheat sheet
G-codes set geometry and motion, such as rapid moves, straight cuts, arcs, units, and work offsets, while M-codes handle machine functions such as the spindle, coolant, and program stop. The codes here are the common ones, but controls differ, so use this as a reminder and confirm anything unusual in the manual for your machine.
Safe programming habits
Start a program with a safe line that sets units, absolute mode, the work offset, the plane, and cancels any compensation or canned cycles left from the previous job. Many crashes come from modal codes that stayed active unexpectedly. Prove out new programs with a dry run, reduced rapids, and single block mode before cutting parts.
