FREE CNC TOOL · Code quick lookup

G-code / M-code List (Common FANUC Codes)

The functions and usage notes for common G / M codes—type a code or keyword to filter instantly. Dialect differences are flagged.

Common G codes (preparatory functions)

CodeFunctionDescription
G00Rapid positioningMoves at the machine's maximum speed, no cutting; slow down and plan the approach before reaching the workpiece
G01Linear cutting feedStraight-line cutting at the feed rate set by F
G02Circular interpolation (clockwise)Define the arc with R or I/J/K
G03Circular interpolation (counterclockwise)Same as above, opposite direction
G04DwellX/P sets the number of seconds; commonly used for a pause at the hole bottom
G17XY plane selectionDefault milling plane
G18ZX plane selectionCommon in turning
G19YZ plane selection
G20Inch unitsSwitch input units to inches
G21Metric unitsSwitch input units to mm
G28Return to machine homeReturns to the reference point via an intermediate point; mind path safety
G40Cutter radius compensation cancel
G41Cutter radius compensation leftTool on the left of the contour along the direction of travel
G42Cutter radius compensation rightTool on the right of the contour along the direction of travel
G43Tool length compensation (positive)Used with the H offset number
G49Tool length compensation cancel
G52Local coordinate system
G53Machine coordinate system positioningUnaffected by the work coordinate system
G54Work coordinate system 1G54–G59 provide six sets
G59Work coordinate system 6
G61Exact stop modePrecise corners, slower speed
G64Cutting modeContinuous, smooth feed
G65Macro single call
G68Coordinate rotationUsed with the R angle
G69Coordinate rotation cancel
G73High-speed peck drilling cycleFast pecking with a small retract
G74Left-hand tapping cycleReverse-rotation tapping
G76Fine boring cycleOriented retract to clear the bore
G80Canned cycle cancel
G81Drilling cycleStraight to depth in one pass
G82Drilling cycle (dwell at hole bottom)Counterbores; improves hole-bottom quality
G83Peck drilling cycleFull retract to clear chips
G84Tapping cycleWith M29 for rigid tapping
G85Boring cycle (feed out)
G90Absolute commandCoordinates referenced to the workpiece origin
G91Incremental commandCoordinates referenced to the current position
G92Coordinate system settingLegacy approach, use with care
G94Feed per minutemm/min (milling default)
G95Feed per revolutionmm/rev
G98Cycle end, return to initial planeUse when clearing fixtures
G99Cycle end, return to R planeFaster for consecutive holes

Common M codes (miscellaneous functions)

CodeFunctionDescription
M00Program stopPress start to continue
M01Optional stopStops only when the panel OP Stop is on
M02Program endNo return
M03Spindle CWUsed with the S speed
M04Spindle CCW
M05Spindle stop
M06Automatic tool changeUsed with the T tool number
M08Coolant on
M09Coolant off
M19Spindle orientationFine boring, tool-change orientation
M29Rigid tapping modeTakes effect on the following G84 line
M30Program end and rewindMost commonly used ending
M98Call subprogramUsed with the P program number
M99Subprogram end/returnUsed at the end of a main program it creates an infinite loop

This table is based on FANUC conventions. Mitsubishi, Siemens, Heidenhain, Syntec and other controllers have dialect differences (lead-in codes, cycle parameters, differing definitions for some M codes), so before running on the machine defer to the machine builder's original manual—this is exactly why AI-generated G-code must go through simulation and machinist sign-off.

FAQ

What is the difference between G00 and G01?

G00 is rapid positioning, moving at the machine's maximum speed with no guarantee of a straight-line path (on some controllers each axis moves independently); G01 is linear cutting at the F feed rate. Always use G01 to slow down and feed in when approaching the workpiece.

How do I choose between G73 and G83?

G73 uses a small retract and is fast, suited to shallow holes and free-cutting materials; G83 fully retracts clear of the hole each time to clear chips, so use G83 for deep holes (roughly 3× diameter and up) and hard-to-evacuate materials.

What is the difference between M02 and M30?

Both end the program; M30 additionally returns the cursor to the top of the program, which is used for production cycles—M30 is the conventional choice for a normal ending.

Further reading: What is G-code? A complete introduction · Touch-off and G54 work coordinates · Crash prevention | More tools: Tools hub

BEYOND LOOKUP

More than a code lookup—AI generates a complete, verifiable program for you

BestAI CAM outputs G-code in the format matching your shop's controller, then runs cutting simulation and AI dimensional verification before handing it to the machinist for sign-off.

See how to get started