When it comes to CNC machining, two terms you’ll often hear are G code and M code. These codes control different functions within the CNC machine. While both are important for the proper operation of the machine, they each serve a distinct role.
What is G Code in CNC Manufacturing?

G code, also known as “Geometric Code,” is used to control the movement of the CNC machine tool. It tells the machine exactly where to move, how fast, and in what direction. G codes control the cutting paths, such as linear motion, circular motion, and positioning of the tool. These instructions are crucial for performing precise machining operations.
Some common G codes include:
- G00: Rapid positioning (moving the tool quickly to a designated point)
- G01: Linear interpolation (tool moves along a straight line)
- G02: Circular interpolation (tool moves in a clockwise circular path)
- G03: Circular interpolation (tool moves in a counterclockwise circular path)
What is M Code in CNC Manufacturing?

M code, which stands for “Miscellaneous Code,” controls other non-cutting functions of the CNC machine. While G code deals with the movement of the tool, M code manages machine operations like starting and stopping the spindle, turning the coolant on or off, and even changing tools. These are essential for supporting the main machining process.
Some common M codes include:
- M03: Spindle on (clockwise rotation)
- M05: Spindle stop
- M08: Coolant on
- M09: Coolant off
How Do G Codes and M Codes Work Together?
While G and M codes are separate, they work together to complete the machining process. G codes control how the tool moves, while M codes ensure that the machine’s auxiliary functions, like the spindle and coolant system, are operating correctly. For instance, during a machining process, G codes might instruct the tool to cut along a specific path, while M codes could turn on the coolant to keep the tool cool or stop the spindle when the job is done.
Conclusion

G code and M code are both vital to CNC machining. G codes direct the tool’s movements, while M codes control machine functions like the spindle and coolant system. Together, they ensure precise and efficient operation of CNC machines, which is crucial for high-quality manufacturing.

