CNC turning machines use a unique programming language known as G-Code and M-Code to control every movement and function of the machine.
These codes are the backbone of CNC machining β they tell the machine when to move, how fast to cut, when to start or stop the spindle, and much more.
In this article, youβll find the complete list of G-Codes and M-Codes used in CNC turning, along with explanations and examples that help you master CNC programming easily.
G-Codes are also called preparatory functions.
They control how the machine tool moves β including straight cuts, circular movements, coordinate modes, and speed settings.
| G-Code | Function | Description |
| G00 | Rapid Traverse | Moves the tool at maximum speed (non-cutting movement). |
| G01 | Linear Interpolation | Moves the tool in a straight line at feed rate (used for cutting). |
| G02 | Circular Interpolation CW | Circular cutting in a clockwise direction. |
| G03 | Circular Interpolation CCW | Circular cutting in a counter-clockwise direction. |
| G04 | Dwell | Pauses tool movement for a set time. |
| G20 | Inch Programming | Programs and dimensions in inches. |
| G21 | Metric Programming | Programs and dimensions in millimeters. |
| G28 | Return to Home Position | Sends tool back to reference or home position. |
| G32 | Thread Cutting | Used for single-pass threading operations. |
| G40 | Cancel Cutter Compensation | Disables any cutter compensation. |
| G41 | Cutter Compensation Left | Enables tool compensation to the left. |
| G42 | Cutter Compensation Right | Enables tool compensation to the right. |
| G50 | Spindle Speed Limit | Sets maximum spindle speed. |
| G96 | Constant Surface Speed (CSS) | Maintains constant cutting surface speed automatically. |
| G97 | Cancel CSS | Switches back to fixed RPM mode. |
| G98 | Feed per Minute | Feedrate measured in mm/min or inch/min. |
| G99 | Feed per Revolution | Feedrate measured per spindle revolution. |
M-Codes are called miscellaneous functions.
They control the machineβs auxiliary actions β like spindle start/stop, coolant control, program stop, and tool change
| M-Code | Function | Description |
| M00 | Program Stop | Stops program until manually restarted. |
| M01 | Optional Stop | Stops only if optional stop is enabled on control panel. |
| M02 | Program End | Ends the program without rewind. |
| M03 | Spindle ON (Clockwise) | Turns spindle on in clockwise direction. |
| M04 | Spindle ON (Counter-Clockwise) | Turns spindle on in counter-clockwise direction. |
| M05 | Spindle Stop | Stops spindle rotation. |
| M06 | Tool Change | Changes to specified tool number. |
| M08 | Coolant ON | Turns coolant ON. |
| M09 | Coolant OFF | Turns coolant OFF. |
| M30 | Program End & Rewind | Ends program and returns to start. |
| M98 | Subprogram Call | Calls subprogram. |
| M99 | Subprogram Return | Returns from subprogram. |
O1000;
G21 G40 G99;
G50 S2000;
G96 S180 M03;
G00 X50.0 Z2.0;
G01 Z0.0 F0.25;
G01 X0.0 F0.15;
G00 X100.0 Z100.0;
M05;
M30;
Understanding G and M codes gives you complete control of the CNC machine.
Even if you use advanced CAM software, having manual knowledge helps you:
If you want to learn CNC Programming from basic to advanced, the TSRCNC E-Learning App is designed just for you.
You can explore:
G-Codes and M-Codes form the language of CNC turning.
By mastering them, you can confidently create, read, and modify CNC programs for any turning operation.
Keep practicing and refer to this list whenever you write new programs β itβs the foundation for every CNC machinist.