CNC machine programming depends on clearly understanding the Fanuc G- and M-codes that tell your machine how to move, cut, and operate. G-codes define motion, such as tool paths and feed rates, and M-codes control machine functions like spindle direction, coolant, and tool changes.
This reference covers the most common Fanuc M-code list and G-code commands found in most machining centers. While configurations vary between builders, this G-codes and M-codes list provides a solid foundation for understanding how Fanuc-based CNC systems interpret and execute programmed instructions.
How To Use Our Fanuc G-Codes and M-Codes List
We organized this resource for fast reference, ideal for operators, programmers, and maintenance teams working on Fanuc-controlled machines. Use the G-code and M-code sections to look up motion commands or machine functions during program creation, editing, or troubleshooting. If you’re working with custom macros or MDI input, skip to those sections for example formats and function details.
Please remember: All machines may be configured differently, and the examples below may not match your machine perfectly. We based this Fanuc G-codes and M-codes list on common conventions, but always be sure to double-check your machine’s control documentation or contact your machine tool builder for builder-specific variations.
Typical Fanuc G-Code List for Machining Centers
G-codes, which are written by Fanuc, define how and where the tool moves across each axis. The list below outlines the most frequently used commands in modern CNC milling environments.
- G00 Moves the tool in rapid travel (not necessarily a straight line)
- G01 Moves the tool using a set feedrate
- G02 Moves the tool along a clockwise arc path
- G03 Moves the tool along a counter-clockwise path
- G04 Sets a dwell time in seconds or revolutions of the spindle
- G10 Data setting
- G11 Data setting mode cancel
- G17 Establishes axis movement in the X and Y axis planes
- G18 Establishes axis movement in the X and Z axis planes
- G19 Establishes axis movement in the Y and Z axis planes
- G20 Values are in Inches
- G21 Values are in millimeters
- G28 Return to reference position
- G30 Second reference position
- G33 Thread cutting
- G40 Cancel cutter compensation
- G41 Cutter compensation left
- G42 Cutter compensation right
- G43 Tool length compensation positive
- G44 Tool length compensation negative
- G49 Tool length compensation cancel
- G53 Machine Coordinate move
- G54 Use workshift offset #1
- G55 Use workshift offset #2
- G56 Use workshift offset #3
- G57 Use workshift offset #4
- G58 Use workshift offset #5
- G59 Use workshift offset #6
- G60 Single direction positioning
- G65 Macro call
- G66 Macro modal call
- G67 Macro modal call cancel
- G73 Peck drilling cycle
- G76 Fine boring cycle
- G80 Canned cycle cancel
- G81 Drilling cycle or spot boring cycle
- G82 Drilling cycle or counter boring cycle
- G83 Peck drilling cycle
- G84 Tapping cycle
- G85 Boring cycle
- G86 Boring cycle
- G87 Back boring cycle
- G88 Boring cycle
- G89 Boring cycle
- G90 Absolute measurements
- G91 Incremental measurements
- G94 Feed per minute
- G95 Feed per revolution of the spindle
- G96 Constant surface speed control
- G97 Constant surface speed control cancel
- G98 Return to initial point in canned cycle
- G99 Return to R point is canned cycle

Control Systems That Power Your Production
Find the right Fanuc control for your setup, with every unit backed by FanucWorld’s testing and support. When you shop our lineup, you get:
- Full units, power supplies, I/O modules, and more
- Refurbished Fanuc controls at 50% – 75% off of OEM pricing
- Expert assistance from our team
Typical Fanuc M-Code List for Machining Centers
Builders write M-codes, governing functions such as spindle direction and tool changes. As a result, virtually all M-codes above M79 will vary from builder to builder. The following Fanuc M code list covers the most common commands used to manage and sequence machine operations.
- M00 Program stop
- M01 Optional stop
- M02 End of program
- M03 Spindle on Clockwise
- M04 Spindle on Counter-clockwise
- M05 Spindle stop
- M06 Tool change
- M08 Coolant on
- M09 Coolant off
- M10 Clamp
- M11 Unclamp
- M30 End of program and rewind to beginning of program
- M98 Call subprogram
- M99 End subprogram
Typical Manual Data Input (MDI) Commands
MDI commands let you manually enter and execute one line of G-code or M-code at a time, which is helpful for quick setups, testing, or manual overrides. The examples below show how specific G, M, S, and T codes are typically formatted and used through the control panel.
M06 T12; Performs a tool change to tool number 12
S1000 M03; Turns spindle on clockwise to 1000 rpm
G01 X10.5 F10.0: Moves the X axis to position 10.5 at a feedrate of 10.0
G00 X……. Y…….. Z…….. ;
G00 Move in rapid travel
X….. X axis address
Y….. Y axis address
Z….. Z axis address
G01 X……. Y…….. Z…….. F……. ;
G01 Move in a straight line
X….. X axis address
Y….. Y axis address
Z….. Z axis address
F….. Feedrate
G02 X……. Y…….. Z…….. I……. J…….. K…….. F……. ;
G02 Move along a clockwise circular path
X….. X axis address
Y….. Y axis address
Z….. Z axis address
I ….. I axis address
J….. J axis address
K….. K axis address
F….. Feedrate
G03 X……. Y…….. Z…….. I……. J…….. K…….. F……. ;
G03 Move along a counter-clockwise circular path
X….. X axis address
Y….. Y axis address
Z….. Z axis address
I ….. I axis address
J….. J axis addressK….. K axis address
F….. Feedrate
G04 X….… ;
G04 Pause machine operation
X….… ( Specify a time/spindle speed with decimal point)
G04 P….… ; ( Specify a time without decimal point)
G04 Pause machine operation
P….… ( Specify a time/spindle speed without decimal point)
G28 G90 X10.0 Y3.0 ;
G28 Return to reference point
G90 Absolute positioning
X10.0 X axis location
Y3.0 Y axis location
This command sequence can be used to move the tool from point A to an
ABSOLUTE Coordinate first, then move the tool to the Reference Point Zero.
G28 G91 X-4.0 Y-3.0 ;
G28 Return to reference point
G91 Incremental positioning
X-4.0 X axis location
Y-3.0 Y axis location
This command sequence can be used to make an incremental move from point A
then move the tool to the Reference Point Zero
G28 G91 X0.0 Y0.0 ;
This line will take the tool back to the reference position direct from the current
location.
G41 D…. X …… ;
G41 Cutter Comp Left
D….. Assigns Radius Offset number
X…. X axis movement
G42 D….… X …… ;
G42 Cutter Comp Right
D….. Assigns Radius Offset number
X…. X axis movement
G40 X….. ;
G40 Cancel Cutter Comp
X….. Cancels comp on way to Here
G43 H…. Z …… ;
G43 Add offset amount
H….. Offset number
Z…. Z axis movement
G44 H… Z …… ;
G44 Subtract offset amount
H….. Offset number
Z…. Z axis movement
G49 H….. Z…… ;
G49 Cancel Offset
H13 Assigns Offset Number 13
Z0.0 Z axis movement to Zero
G65 P……. L…….. ;
G65 Macro call (Modal)
P….. Macro program Number
L….. Number of repetitions
G66 P……. ;
G66 Macro call (Non-Modal)
P….. Macro program Number
G73 X……. Y…….. Z…….. R……. Q…….. F…….. K……. ;
G73 High speed peck drilling cycle
X….. X axis address
Y….. Y axis address
Z….. Z address location of bottom of hole
R ….. Retract plane
Q….. Distance for each peck stroke
F….. Feedrate
K….. Number of repeats
G74 X……. Y…….. Z…….. R……. P…….. F…….. K……. ;
G74 Left handed tapping cycle
X….. X axis address
Y….. Y axis address
Z….. Z address location of bottom of hole
R …. Retract plane
F….. Feedrate
K….. Number of repeats
G76 X……. Y…….. Z…….. R……. Q…….. P…….. F…….. K……. ;
G76 Fine boring cycle
X….. X axis address
Y….. Y axis address
Z….. Z address location of bottom of hole
R ….. Retract plane
Q….. Distance for each peck stroke
P….. Dwell time at bottom of bore
F….. Feedrate
K….. Number of repeats
G81 X……. Y…….. Z…….. R……. F…….. K……. ;
G81 Spot drilling cycle
X….. X axis address
Y….. Y axis address
Z….. Z address location of bottom of hole
R ….. Retract plane
F….. Feedrate
K….. Number of repeats
G82 X……. Y…….. Z…….. R……. P…….. F…….. K……. ;
G82 Drilling cycle counter boring cycle
X….. X axis address
Y….. Y axis address
Z….. Z address location of bottom of hole
R ….. Retract plane
P….. Dwell time at bottom of bore
F….. Feedrate
K….. Number of repeats
G83 X……. Y…….. Z…….. R……. Q…….. F…….. K……. ;
G83 Peck drilling cycle
X….. X axis address
Y….. Y axis address
Z….. Z address location of bottom of hole
R ….. Retract plane
Q….. Distance for each peck stroke
F….. Feedrate
K….. Number of repeats
Need Parts, Repairs, or Answers?
Whether you’re troubleshooting alarms or planning your next job, FanucWorld has the parts, repairs, and tech support to help you keep moving. Explore our Fanuc parts or request a quote.
Frequently Asked Questions
Can I customize Fanuc G- and M-codes?
Some G- and M-codes are standard across machines, but builders and integrators often assign custom functions, especially for M-codes above M79. Always consult your machine’s documentation or builder before assuming code behavior.
Why won’t my G-code program run as expected?
It could be a missing setup line, incorrect modal command, or an unsupported M-code for your specific control. Check for active offsets, work coordinate settings, or syntax errors in the sequence.
Is there a difference between G90 and G91 on Fanuc controls?
Yes. G90 commands use absolute positioning, moving the tool to a specific coordinate, while G91 uses incremental positioning relative to the current location.
Was this helpful?
584 / 105