G-code and M-code list

G and M codes for machining centers and lathes, centered on the common FANUC-type assignments. The same number can mean different things on different machines (M codes in particular are assigned by the machine builder). Always confirm against your machine’s manual before running a program.

Same number,
different machine?
Check the manual!

Chips, the Kezuriba mascot

GG codes

CodeMachining centerLathe (system A)Modal
G00Rapid positioning (rapid traverse)Rapid positioning (rapid traverse)Modal (01)
G01Linear interpolation (cutting feed)Linear interpolation (cutting feed)Modal (01)
G02Circular interpolation, clockwise (CW) / helical interpolationCircular interpolation, clockwise (CW) / helical interpolationModal (01)
G03Circular interpolation, counterclockwise (CCW) / helical interpolationCircular interpolation, counterclockwise (CCW) / helical interpolationModal (01)
G04Dwell (pause)Dwell (pause)One-shot (00)
G09Exact stop (this block only)Exact stop (this block only)One-shot (00)
G10Programmable data input (writes offset values and work coordinates from the program)Programmable data input (writes offset values and work coordinates from the program)One-shot (00)
G17XY plane selectionXY plane selection (used on lathes with milling capability)Modal (02)
G18ZX plane selectionZX plane selection (lathe standard)Modal (02)
G19YZ plane selectionYZ plane selection (lathes with a Y axis and live tooling)Modal (02)
G20Inch inputInch inputModal (06)
G21Metric (mm) inputMetric (mm) inputModal (06)
G28Automatic return to reference point (zero return)Automatic return to reference point (zero return)One-shot (00)
G302nd (3rd, 4th) reference point return2nd (3rd, 4th) reference point returnOne-shot (00)
G40Cutter compensation cancel (lathe: tool nose radius compensation cancel)Tool nose radius compensation cancelModal (07)
G41Cutter compensation left (tool is on the left of the direction of travel)Tool nose radius compensation, leftModal (07)
G42Cutter compensation right (tool is on the right of the direction of travel)Tool nose radius compensation, right (used for typical OD turning toward –Z)Modal (07)
G43Tool length compensation + (adds the offset)(Not used on typical FANUC-type lathes. The tool offset is selected by the last 2 digits of the T code)Modal (08)
G44Tool length compensation – (subtracts the offset)—Modal (08)
G49Tool length compensation cancel—Modal (08)
G50Scaling cancelMaximum spindle speed setting (also sets the coordinate system in system A)Modal (11)
G52Local coordinate system settingLocal coordinate system settingOne-shot (00)
G53Machine coordinate system selection (positioning in machine coordinates)Machine coordinate system selection (positioning in machine coordinates)One-shot (00)
G54–G59Work coordinate systems 1–6 selectionWork coordinate systems 1–6 selectionModal (14)
G61Exact stop modeExact stop modeModal (15)
G64Cutting mode (continuous cutting; cancels exact stop)Cutting mode (continuous cutting; cancels exact stop)Modal (15)
G65Macro call (simple call, with arguments)Macro call (simple call, with arguments)One-shot (00)
G66Modal macro callModal macro callModal (12)
G67Modal macro call cancelModal macro call cancelModal (12)
G68Coordinate rotationMeaning differs by machine (see variants below)Modal (16)
G69Coordinate rotation cancelMeaning differs by machine (see G68)Modal (16)
G70—Finishing cycle (finishes the profile rough-cut with G71–G73)One-shot (00)
G71—OD/ID rough turning cycle (cuts along Z)One-shot (00)
G72—Face rough turning cycle (cuts along X)One-shot (00)
G73High-speed peck drilling cycle (chip breaking, small retract)Pattern repeating (closed-loop cutting) cycle (cuts following the stock shape, e.g. castings)Modal (09)
G74Left-hand tapping cycle (reverse tapping)End face grooving cycle / Z-direction deep hole peck drillingModal (09)
G75—OD/ID grooving (cut-off) cycleOne-shot (00)
G76Fine boring cycleMultiple thread cutting cycle (compound thread cutting cycle)Modal (09)
G80Canned cycle cancelDrilling canned cycle cancel (for live tooling, face drilling)Modal (09)
G81Drilling cycle (spot drilling)—Modal (09)
G82Drilling cycle (counter boring, dwell at hole bottom)—Modal (09)
G83Deep hole drilling cycle (peck drilling, full retract to the R point each time)End face deep hole drilling cycle (live tooling, lathe with C axis)Modal (09)
G84Tapping cycle (right-hand thread)Face tapping cycle (lathe with live tooling)Modal (09)
G85Boring cycle (feed in, feed out)Face boring (drilling) cycle (live tooling)Modal (09)
G86Boring cycle (spindle stops at the hole bottom, rapid out)—Modal (09)
G87Back boring cycle (reverse spot facing)Side deep hole drilling cycle (live tooling, systems A/B)Modal (09)
G88Boring cycle (dwell at the hole bottom, spindle stop, manual retract)Side tapping cycle (live tooling, systems A/B)Modal (09)
G89Boring cycle (dwell at the hole bottom, feed out)Side boring (drilling) cycle (live tooling)Modal (09)
G90Absolute commandOD/ID cutting cycle (single canned cycle, G-code system A)Modal (03)
G91Incremental command(Not used in system A. Incremental values are written with U/W)Modal (03)
G92Coordinate system setting (assigns coordinate values to the current position)Thread cutting cycle (single canned cycle, G-code system A)One-shot (00)
G94Feed per minute (mm/min)Face cutting cycle (single canned cycle, G-code system A)Modal (05)
G95Feed per revolution (mm/rev)—Modal (05)
G96Constant surface speed controlConstant surface speed controlModal (13)
G97Constant surface speed control cancel (constant spindle speed)Constant surface speed control cancelModal (13)
G98Canned cycle: return to initial pointFeed per minute (mm/min) (G-code system A)Modal (10)
G99Canned cycle: return to R pointFeed per revolution (mm/rev) (G-code system A)Modal (10)

Yellow underline = the meaning differs between machining centers and lathes.

MM codes

CodeMeaningMachine
M00Program stopMachining center, Lathe
M01Optional stop (conditional stop)Machining center, Lathe
M02Program endMachining center, Lathe
M03Spindle on, clockwise (CW)Machining center, Lathe
M04Spindle on, counterclockwise (CCW)Machining center, Lathe
M05Spindle stopMachining center, Lathe
M06Tool change (ATC)Machining center
M08Coolant (cutting fluid) ONMachining center, Lathe
M09Coolant OFFMachining center, Lathe
M19Spindle orientation (oriented spindle stop)Machining center, Lathe
M29Rigid tapping (switches the spindle to position control) *machine-dependent*Machining center, Lathe
M30Program end and rewind (end of tape)Machining center, Lathe
M98Subprogram callMachining center, Lathe
M99Subprogram end (return to the caller)Machining center, Lathe