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
G00Rapid positioning — moves tool at maximum traverse speed to target coordinates (non-cutting move)
G01Linear interpolation — controlled feed-rate straight-line cutting move
G02Circular interpolation clockwise (CW arc) — requires I/J/K or R
G03Circular interpolation counter-clockwise (CCW arc) — requires I/J/K or R
G04Dwell — pause for a specified time (P = seconds or milliseconds depending on control)
G05High-speed machining mode (control-specific, e.g. AICC on Fanuc)
G05.1AI contour control / nano smoothing for high-speed finishing
G09Exact stop check — decelerates to zero at end of block before next move
G10Programmable data input — set offsets, parameters, and work coordinates from the program
G11Cancel programmable data input mode
Plane Selection
G17XY plane selection — default plane for arcs and canned cycles (milling)
G18XZ plane selection — used for turning or side-milling arcs
G19YZ plane selection — used for arcs in the YZ plane
Units
G20Programming in inches (imperial)
G21Programming in millimeters (metric)
Reference Points
G27Reference point return check — verifies machine is at home
G28Return to machine home position via optional intermediate point
G29Return from reference point — moves from G28 intermediate point to specified position
G30Return to 2nd/3rd/4th reference point (P2, P3, P4)
G31Skip function (touch probe feed) — feeds until signal triggers, records position
Cutter Compensation
G40Cancel cutter radius compensation
G41Cutter compensation left — tool offsets left of programmed path
G41.1Cutter compensation left (D value input directly)
G42Cutter compensation right — tool offsets right of programmed path
G42.1Cutter compensation right (D value input directly)
G43Tool length compensation positive direction (H offset)
G43.1Dynamic tool length compensation
G44Tool length compensation negative direction
G49Cancel tool length compensation
Coordinate Systems
G52Local coordinate system setting (temporary shift)
G53Machine coordinate system — moves in absolute machine coordinates (non-modal)
G54Work coordinate system 1 — most commonly used fixture offset
G55Work coordinate system 2
G56Work coordinate system 3
G57Work coordinate system 4
G58Work coordinate system 5
G59Work coordinate system 6
G54.1Additional work coordinate systems P1–P48 (extended offsets)
Canned Cycles
G73High-speed peck drilling cycle — shallow pecks with partial retract for chip breaking
G74Left-hand (reverse) tapping cycle — CCW tap with CW retract
G76Fine boring cycle — orients spindle, shifts, and retracts to avoid drag mark
G80Cancel canned cycle — returns to normal drilling/boring mode
G81Standard drilling cycle — drill to depth, rapid retract (no dwell)
G82Spot drilling / counterboring cycle — drill to depth with dwell at bottom
G83Deep-hole peck drilling cycle — full retract pecks to clear chips
G84Right-hand tapping cycle — CW tap with CCW retract (rigid or floating)
G84.2Rigid tapping cycle (synchronous spindle/feed)
G85Boring cycle — feed in, feed out (smooth finish both ways)
G86Boring cycle — feed in, spindle stop, rapid retract
G87Back boring cycle — approach from back side of workpiece
G88Boring cycle — feed in, dwell, manual retract (spindle on)
G89Boring cycle — feed in, dwell, feed out
Positioning Mode
G90Absolute positioning mode — all coordinates measured from work zero
G90.1Absolute arc center mode (I/J/K are absolute)
G91Incremental positioning mode — coordinates relative to current position
G91.1Incremental arc center mode (I/J/K are incremental) — default on most controls
G92Work coordinate position register (legacy offset shift)
G92.1Cancel G92 offset
Feed Rate
G93Inverse time feed rate mode — F value = 1/time in minutes
G94Feed per minute mode (default for milling)
G95Feed per revolution mode (common in turning)
Spindle Control
G96Constant surface speed (CSS) — spindle RPM varies with diameter (turning)
G97Constant RPM mode — fixed spindle speed (cancel CSS)
G98Canned cycle return to initial point (R-level)
G99Canned cycle return to R-point (rapid retract to R level only)
Turning
G32Thread cutting — single-pass threading (lathe)
G33Constant-pitch threading (single pass per block)
G34Variable-pitch (increasing lead) threading
G35Variable-pitch (decreasing lead) threading
G36Automatic tool compensation X (turning)
G37Automatic tool compensation Z (turning)
G50Set coordinate / max spindle speed clamp (turning)
G70Finishing cycle — finishes profile defined by G71/G72 rough pass (turning)
G71Longitudinal (OD/ID) rough turning cycle — removes material in passes along Z
G72Facing rough turning cycle — removes material in passes along X
G75OD/ID grooving cycle (turning)
G76Multi-pass threading cycle — automatic multi-pass thread cutting (turning)
G77OD/ID threading cycle (canned, turning)
G78Single-pass threading cycle (turning)
Advanced
G12Circular pocket milling CW (Haas/Fanuc)
G13Circular pocket milling CCW (Haas/Fanuc)
G15Cancel polar coordinate command
G16Polar coordinate command — program in radius and angle
G46Tool position compensation (turning nose radius)
G47Engraving cycle (Haas) — cut text characters on workpiece
G50.1Cancel mirror image
G51Scaling function on — scale programmed path by factor
G51.1Mirror image on
G61Exact stop mode — decelerates to zero at every block end
G64Normal cutting mode / continuous path mode (cancel exact stop)
G65Macro call — call a custom macro subprogram with arguments
G66Macro modal call — macro repeats every block until cancelled
G67Cancel macro modal call
G68Coordinate rotation on — rotate coordinate system by angle
G69Cancel coordinate rotation
G100Disable mirror image (Haas)
G101Enable mirror image (Haas)
G103Block lookahead limit — limits number of buffered blocks
G107Cylindrical mapping — wraps XY onto rotary axis (4th axis engraving)
G112XY to XC polar interpolation mode (turning with live tooling)
G113Cancel polar interpolation
G114Cancel Y-axis mode (mill-turn)
G115Enable Y-axis mode (mill-turn)
G154Additional work offsets P1–P99 (Haas)
G187Surface 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 →