G-Code and M-Code Reference List for Milling

A list of g-codes and m-codes for milling in the Fanuc, LinuxCNC, GRBL, and Haas dialects.  We give a quick definition of each g-code 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 the g-code.

Pssst! Hey, if you’re here looking up g-codes, maybe you’d like to find an easier way. What could be better than software that tells you exactly what each g-code does in plain English?

That’s what G-Wizard Editor is like.

GCode is complicated. G-Wizard Editor makes it easy.

Code
Category
Function

Notes

G00
Motion
Move in a straight line at rapids speed. XYZ of endpoint
G01
Motion
Move in a straight line at last speed commanded by a (F)eedrate XYZ of endpoint
G02
Motion
Clockwise circular arc at (F)eedrate XYZ of endpoint IJK relative to center R for radius
G03
Motion
Counter-clockwise circular arc at (F)eedrate XYZ of endpoint IJK relative to center R for radius
G04
Motion
Dwell: Stop for a specified time. P for milliseconds X for seconds
G05
Motion
FADAL Non-Modal Rapids
G09
Motion
Exact stop check
G10
Compensation
Programmable parameter input
G15
Coordinate
Turn Polar Coordinates OFF, return to Cartesian Coordinates
G16
Coordinate
Turn Polar Coordinates ON
G17
Coordinate
Select X-Y plane
G18
Coordinate
Select X-Z plane
G19
Coordinate
Select Y-Z plane
G20
Coordinate
Program coordinates are inches
G21
Coordinate
Program coordinates are mm
G27
Motion
Reference point return check
G28
Motion
Return to home position
G29
Motion
Return from the reference position
G30
Motion
Return to the 2nd, 3rd, and 4th reference point
G32
Canned
Constant lead threading (like G01 synchronized with spindle)
G40
Compensation
Tool cutter compensation off (radius comp.)
G41
Compensation
Tool cutter compensation left (radius comp.)
G42
Compensation
Tool cutter compensation right (radius comp.)
G43
Compensation
Apply tool length compensation (plus)
G44
Compensation
Apply tool length compensation (minus)
G49
Compensation
Tool length compensation cancel
G50
Compensation
Reset all scale factors to 1.0
G51
Compensation
Turn on scale factors
G52
Coordinate
Local workshift for all coordinate systems: add XYZ offsets
G53
Coordinate
Machine coordinate system (cancel work offsets)
G54
Coordinate
Work coordinate system (1st Workpiece)
G55
Coordinate
Work coordinate system (2nd Workpiece)
G56
Coordinate
Work coordinate system (3rd Workpiece)
G57
Coordinate
Work coordinate system (4th Workpiece)
G58
Coordinate
Work coordinate system (5th Workpiece)
G59
Coordinate
Work coordinate system (6th Workpiece)
G61
Other
Exact stop check mode
G62
Other
Automatic corner override
G63
Other
Tapping mode
G64
Other
Best speed path
G65
Other
Custom macro simple call
G68
Coordinate
Coordinate System Rotation
G69
Coordinate
Cancel Coordinate System Rotation
G73
Canned
High speed drilling cycle (small retract)
G74
Canned
Left hand tapping cycle
G76
Canned
Fine boring cyle
G80
Canned
Cancel canned cycle
G81
Canned
Simple drilling cycle
G82
Canned
Drilling cycle with dwell (counterboring)
G83
Canned
Peck drilling cycle (full retract)
G84
Canned
Tapping cycle
G85
Canned
Boring canned cycle, no dwell, feed out
G86
Canned
Boring canned cycle, spindle stop, rapid out
G87
Canned
Back boring canned cycle
G88
Canned
Boring canned cycle, spindle stop, manual out
G89
Canned
Boring canned cycle, dwell, feed out
G90
Coordinate
Absolute programming of XYZ (type B and C systems)
G90.1
Coordinate
Absolute programming IJK (type B and C systems)
G91
Coordinate
Incremental programming of XYZ (type B and C systems)
G91.1
Coordinate
Incremental programming IJK (type B and C systems)
G92
Coordinate
Offset coordinate system and save parameters
G92 (alternate)
Motion
Clamp of maximum spindle speed S
G92.1
Coordinate
Cancel offset and zero parameters
G92.2
Coordinate
Cancel offset and retain parameters
G92.3
Coordinate
Offset coordinate system with saved parameters
G94
Motion
Units per minute feed mode. Units in inches or mm.
G95
Motion
Units per revolution feed mode. Units in inches or mm.
G96
Motion
Constant surface speed
G97
Motion
Cancel constant surface speed
G98
Canned
Return to initial Z plane after canned cycle
G99
Canned
Return to initial R plane after canned cycle
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

Mazatrol Training Classes

Fanuc CNC Training Classes

 

Software that will make anyone a better CNC'er

Get Better Tool Life, Surface Finish, and Material Removal Rates Fast.

It's that easy. You can install and get results in a matter of minutes.

 

Start Now, It's Free!

G-Code and M-Code Reference List for CNC Mills
3.9 (77.58%) 33 votes

Home

Software

  GW Calculator

  GW Editor

  Thread Calculator

  Gearotic

  Conversational

CNC Programming / GCode

  Free Training

  G-Code Simulator

  G-Code / M-Code List

 

Feeds & Speeds

     Calculator

     Free Calculator   

     

CNC Machining & Manufacturing

 

Resources

     CNC Dictionary

     Hall of Fame

     Free Calculators

 

About

     Customers

     Partners

     Our History

     Privacy Policy

 
All material © 2018, CNCCookbook, Inc.