Reference

    G-Code & M-Code Reference

    Comprehensive G-code and M-code commands for CNC milling and turning. Covers ISO 6983 standard commands used by Fanuc, Haas, Mazak, Okuma, and most CNC controls.

    105 G-codes · 78 M-codes

    Motion

    G00

    Rapid positioning — moves tool at maximum traverse speed to target coordinates (non-cutting move)

    G01

    Linear interpolation — controlled feed-rate straight-line cutting move

    G02

    Circular interpolation clockwise (CW arc) — requires I/J/K or R

    G03

    Circular interpolation counter-clockwise (CCW arc) — requires I/J/K or R

    G04

    Dwell — pause for a specified time (P = seconds or milliseconds depending on control)

    G05

    High-speed machining mode (control-specific, e.g. AICC on Fanuc)

    G05.1

    AI contour control / nano smoothing for high-speed finishing

    G09

    Exact stop check — decelerates to zero at end of block before next move

    G10

    Programmable data input — set offsets, parameters, and work coordinates from the program

    G11

    Cancel programmable data input mode

    Plane Selection

    G17

    XY plane selection — default plane for arcs and canned cycles (milling)

    G18

    XZ plane selection — used for turning or side-milling arcs

    G19

    YZ plane selection — used for arcs in the YZ plane

    Units

    G20

    Programming in inches (imperial)

    G21

    Programming in millimeters (metric)

    Reference Points

    G27

    Reference point return check — verifies machine is at home

    G28

    Return to machine home position via optional intermediate point

    G29

    Return from reference point — moves from G28 intermediate point to specified position

    G30

    Return to 2nd/3rd/4th reference point (P2, P3, P4)

    G31

    Skip function (touch probe feed) — feeds until signal triggers, records position

    Cutter Compensation

    G40

    Cancel cutter radius compensation

    G41

    Cutter compensation left — tool offsets left of programmed path

    G41.1

    Cutter compensation left (D value input directly)

    G42

    Cutter compensation right — tool offsets right of programmed path

    G42.1

    Cutter compensation right (D value input directly)

    G43

    Tool length compensation positive direction (H offset)

    G43.1

    Dynamic tool length compensation

    G44

    Tool length compensation negative direction

    G49

    Cancel tool length compensation

    Coordinate Systems

    G52

    Local coordinate system setting (temporary shift)

    G53

    Machine coordinate system — moves in absolute machine coordinates (non-modal)

    G54

    Work coordinate system 1 — most commonly used fixture offset

    G55

    Work coordinate system 2

    G56

    Work coordinate system 3

    G57

    Work coordinate system 4

    G58

    Work coordinate system 5

    G59

    Work coordinate system 6

    G54.1

    Additional work coordinate systems P1–P48 (extended offsets)

    Canned Cycles

    G73

    High-speed peck drilling cycle — shallow pecks with partial retract for chip breaking

    G74

    Left-hand (reverse) tapping cycle — CCW tap with CW retract

    G76

    Fine boring cycle — orients spindle, shifts, and retracts to avoid drag mark

    G80

    Cancel canned cycle — returns to normal drilling/boring mode

    G81

    Standard drilling cycle — drill to depth, rapid retract (no dwell)

    G82

    Spot drilling / counterboring cycle — drill to depth with dwell at bottom

    G83

    Deep-hole peck drilling cycle — full retract pecks to clear chips

    G84

    Right-hand tapping cycle — CW tap with CCW retract (rigid or floating)

    G84.2

    Rigid tapping cycle (synchronous spindle/feed)

    G85

    Boring cycle — feed in, feed out (smooth finish both ways)

    G86

    Boring cycle — feed in, spindle stop, rapid retract

    G87

    Back boring cycle — approach from back side of workpiece

    G88

    Boring cycle — feed in, dwell, manual retract (spindle on)

    G89

    Boring cycle — feed in, dwell, feed out

    Positioning Mode

    G90

    Absolute positioning mode — all coordinates measured from work zero

    G90.1

    Absolute arc center mode (I/J/K are absolute)

    G91

    Incremental positioning mode — coordinates relative to current position

    G91.1

    Incremental arc center mode (I/J/K are incremental) — default on most controls

    G92

    Work coordinate position register (legacy offset shift)

    G92.1

    Cancel G92 offset

    Feed Rate

    G93

    Inverse time feed rate mode — F value = 1/time in minutes

    G94

    Feed per minute mode (default for milling)

    G95

    Feed per revolution mode (common in turning)

    Spindle Control

    G96

    Constant surface speed (CSS) — spindle RPM varies with diameter (turning)

    G97

    Constant RPM mode — fixed spindle speed (cancel CSS)

    G98

    Canned cycle return to initial point (R-level)

    G99

    Canned cycle return to R-point (rapid retract to R level only)

    Turning

    G32

    Thread cutting — single-pass threading (lathe)

    G33

    Constant-pitch threading (single pass per block)

    G34

    Variable-pitch (increasing lead) threading

    G35

    Variable-pitch (decreasing lead) threading

    G36

    Automatic tool compensation X (turning)

    G37

    Automatic tool compensation Z (turning)

    G50

    Set coordinate / max spindle speed clamp (turning)

    G70

    Finishing cycle — finishes profile defined by G71/G72 rough pass (turning)

    G71

    Longitudinal (OD/ID) rough turning cycle — removes material in passes along Z

    G72

    Facing rough turning cycle — removes material in passes along X

    G75

    OD/ID grooving cycle (turning)

    G76

    Multi-pass threading cycle — automatic multi-pass thread cutting (turning)

    G77

    OD/ID threading cycle (canned, turning)

    G78

    Single-pass threading cycle (turning)

    Advanced

    G12

    Circular pocket milling CW (Haas/Fanuc)

    G13

    Circular pocket milling CCW (Haas/Fanuc)

    G15

    Cancel polar coordinate command

    G16

    Polar coordinate command — program in radius and angle

    G46

    Tool position compensation (turning nose radius)

    G47

    Engraving cycle (Haas) — cut text characters on workpiece

    G50.1

    Cancel mirror image

    G51

    Scaling function on — scale programmed path by factor

    G51.1

    Mirror image on

    G61

    Exact stop mode — decelerates to zero at every block end

    G64

    Normal cutting mode / continuous path mode (cancel exact stop)

    G65

    Macro call — call a custom macro subprogram with arguments

    G66

    Macro modal call — macro repeats every block until cancelled

    G67

    Cancel macro modal call

    G68

    Coordinate rotation on — rotate coordinate system by angle

    G69

    Cancel coordinate rotation

    G100

    Disable mirror image (Haas)

    G101

    Enable mirror image (Haas)

    G103

    Block lookahead limit — limits number of buffered blocks

    G107

    Cylindrical mapping — wraps XY onto rotary axis (4th axis engraving)

    G112

    XY to XC polar interpolation mode (turning with live tooling)

    G113

    Cancel polar interpolation

    G114

    Cancel Y-axis mode (mill-turn)

    G115

    Enable Y-axis mode (mill-turn)

    G154

    Additional work offsets P1–P99 (Haas)

    G187

    Surface finish accuracy control (Haas) — rough/medium/finish

    Need G-Code integrated into your production tracking?

    JobLine.ai connects your CNC programs directly to work orders and station dashboards, giving supervisors real-time visibility into which program is running on every machine.

    Learn about CNC Operator Tools →