G-code and M-code basics for CNC beginners
G-codes tell a CNC machine how to move (rapid move, straight cut, arc, plane, units). M-codes switch machine functions (spindle, coolant, tool change, program end). Controls differ, so always check the manual for your machine, but the common codes below are widely used on Fanuc-style controls.
Common G-codes
| Code | Meaning |
|---|---|
| G00 | Rapid move (not for cutting) |
| G01 | Straight-line cutting move at the set feed rate |
| G02 / G03 | Circular arc, clockwise / counter-clockwise |
| G17 / G18 / G19 | Select the XY / XZ / YZ plane |
| G20 / G21 | Inch / millimetre units |
| G54 to G59 | Work coordinate systems (work offsets) |
| G90 / G91 | Absolute / incremental positioning |
Common M-codes
| Code | Meaning |
|---|---|
| M03 / M04 | Spindle on clockwise / counter-clockwise |
| M05 | Spindle stop |
| M06 | Tool change |
| M08 / M09 | Coolant on / off |
| M30 | Program end and rewind |
Do you still need G-code if CAM writes it?
Yes. CAM generates the code, but the person at the machine must be able to read it: to find where a program stopped, to edit a feed, to check an offset or to spot a wrong move before it crashes the tool. Reading G-code is a safety skill as much as a programming one.
Need help or a quotation?
CAD CAM Galaxy supplies licensed CAD/CAM software and trains engineers across India, with centres in Mumbai, Palghar and Vapi. Use the form below or see the related pages.