Free G-Code Cheat Sheet

🛠️ G-Code & M-Code Cheat Sheet for CNC Machinists

This is a more complete list of standard G- and M-codes commonly used on CNC mills and lathes. These codes are compatible with most Fanuc, Haas, and similar controllers.

🟦 G-Codes

Code Description
G00 Rapid move
G01 Feedrate move
G02 Clockwise arc
G03 Counter-clockwise arc
G04 Dwell (L# = time)
G08 Spline smoothing on
G09 Exact stop (smoothing off)
G10 / G11 Decelerated feed stops
G17 / G18 / G19 Plane selection: XY / XZ / YZ
G20 / G21 Units: Inch / Millimeter
G28 Return to machine home
G33 Threading (Lathe)*
G35 Bypass error check next line
G40 / G41 / G42 Tool comp: off / left / right
G43 / G44 / G49 Tool length offset (+ / - / cancel)
G53 Cancel work coordinate offsets
G54–G59 Work coordinate offsets 1–6
G61 / G64 Buffering off / on
G65 – G68 Pocket and flycut milling cycles
G70 Inch mode
G71 Millimeter mode
G74 Lathe peck drilling
G81 – G89 Drill & boring cycles
G84 Tapping cycle
G90 / G91 Absolute / Incremental positioning
G92 Home coordinate reset
G94 / G95 Feedrate modes: IPM / IPR
G96 / G97 Constant surface speed on / off (Lathe)
*G33 and G33.1 will not work on Sherline CNC machines, as they lack synchronized spindles.

🟨 M-Codes

Code Description
M00 Program stop
M01 Optional stop
M02 / M30 End program
M03 / M04 / M05 Spindle on CW / CCW / stop
M06 Tool change
M08 / M09 Coolant on / off
M10 Reserved for tool height offset
M13 Spindle and coolant on
M91 / M92 Readout display: Incremental / Absolute
M97 / M98 / M99 Subroutine jumps / returns
M100 Machine zero reset
M199 Mid-program start

🟥 Symbols & Parameters

Symbol Description
F Feedrate (in/min or mm/min)
S Spindle speed (RPM)
T Tool number
H Tool length offset number
D Diameter offset number
N Line number label
; Comment line

💡 Pro Tips

  • Always cancel cutter comp (G40) before a tool change.
  • Use G43 H01 to apply tool length offset #1.
  • G41/G42 require a linear feed move (G01).
  • Use G28 U0. W0. to return via intermediate axes.