G-Code and M-Code List for CNC [Easy, With Examples & Tutorials]
Complete g code list with m-codes for milling in the Fanuc, LinuxCNC, GRBL, and Haas dialects. We give a quick definition for all g code commands along with a link to tutorials and examples of how to use it. Click the g-code link (if any) to visit a tutorial from our popuplar Online Free G-Code Training that shows examples and teaches how to program CNC machines using the g-code.
G Codes
Get a Powerful G-Code Simulator and Editor to Simplify G-Code Work
M Codes
|
|||||
Code
|
Category
|
Function
|
Notes |
||
M00 |
M-Code
|
Program Stop (non-optional) | |||
M01 |
M-Code
|
Optional Stop: Operator Selected to Enable | |||
M02 |
M-Code
|
End of Program | |||
M03 |
M-Code
|
Spindle ON (CW Rotation) | |||
M04 |
M-Code
|
Spindle ON (CCW Rotation) | |||
M05 |
M-Code
|
Spindle Stop | |||
M06 |
M-Code
|
Tool Change | |||
M07 |
M-Code
|
Mist Coolant ON | |||
M08 |
M-Code
|
Flood Coolant ON | |||
M09 |
M-Code
|
Coolant OFF | |||
M17 |
M-Code
|
FADAL subroutine return | |||
M29 |
M-Code
|
Rigid Tapping Mode on Fanuc Controls | |||
M30 |
M-Code
|
End of Program, Rewind and Reset Modes | |||
M97 |
M-Code
|
Haas-Style Subprogram Call | |||
M98 |
M-Code
|
Subprogram Call | |||
M99 |
M-Code
|
Return from Subprogram |
Bonus: Check Out our Other CNC Cookbooks for More In-Depth CNC Information!
If you’re a CNC Beginnner, check out our CNC Beginner’s Cookbook. It’ll get you up to speed with a solid CNC foundation fast.
We also have Cookbooks for Feeds and Speeds, G-Code Programming, CNC Manufacturing and Shop Management, DIY CNC, and don’t forget the CNC Cookbook Blog–with over 4 million visitors a year it’s the most popular CNC blog by far on the web.
More Resources
G Code Commands FAQ
How many G codes are there?
There are about 100 g code commands, give or take. There are many dialects of g-code, and some have proprietary g-codes.
What are G Codes in CNC Machines?
This page lists all the G code commands and tells what they do and also gives a link to tutorials and examples. G codes are single letter commands that tell the CNC machine what to do. They may command motion (i.e. tell the machine where to cut) or do things like turn the spindle on or off.
Is learning G-Code hard?
Learning g-code isn’t very hard. We have a complete free online g-code tutorial to teach you as well as a g-code simulator that makes learning easy.
Why are G Codes used?
G Codes make CNC Machines programmable, which gives them the flexible to make almost any part.
What is the difference between G codes and M codes?
G-Codes are about Geometry while M-Codes are about Machine functions.
Do all CNC machines use G-code?
Not all CNC machine use G-Code. Some may have both g-code and other ways of programming, for example alternate languages such as Mazak’s Mazatrol or Conversational Programming. Others, may have an alternate language and no ability to execute g-code at all.
Recently updated on October 29th, 2023 at 08:11 am