Fanuc G-codes86 codes

Fanuc G-code List

Fanuc's G-code table is the baseline the Haas, Mazak and Okuma lists on this site are measured against. Below are all the G-codes the G-Code Guru reference marks as supported on a 0i or 30i, G00 rapid to G99 return level, mills and lathes together.

Fanuc G-code: 86 codes

Codes in colour link to a full page with a worked example and controller differences; the rest link to their row on the G-code list.

CodeFunctionNotes
G00Rapid PositioningMoves the tool at maximum speed to the specified position. Used for non-cutting moves to position the tool quickly. Movement is typically not in a straight line - each axis moves at its maximum rate independently.WARNING: G00 moves at maximum speed. Ensure clear path to avoid collisions. Movement path may not be linear.
G01Linear InterpolationMoves the tool in a straight line at a specified feed rate. Used for cutting operations where precise linear movement is required.Feed rate (F) is modal - once set, it remains active until changed.
G02Circular Interpolation CWMoves the tool in a clockwise arc. The arc center is defined by I/J/K offsets or R radius. Direction is clockwise when viewed from the positive direction of the perpendicular axis.I/J/K are usually incremental from current position. R cannot make full circles.
G03Circular Interpolation CCWMoves the tool in a counter-clockwise arc. The arc center is defined by I/J/K offsets or R radius. Direction is counter-clockwise when viewed from the positive direction of the perpendicular axis.I/J/K are usually incremental from current position. R cannot make full circles.
G04DwellPauses program execution for a specified time. Useful for chip clearing, allowing spindle to reach speed, or timing operations.P format varies by controller: Fanuc uses milliseconds, some use seconds. Check your controller documentation.
G05High-Speed Machining ModeActivates high-speed machining mode for smoother motion at high feed rates. Reduces acceleration/deceleration for better surface finish.Controller-specific. Check documentation for exact syntax and modes available.
G09Exact Stop CheckNon-modal exact stop. Machine decelerates to a complete stop at the end of the current block only. Unlike G61, it only affects the single block it appears on.Non-modal, only affects the block it's on. Use instead of G61 when you need exact stop at one point only.
G10Data Setting / Offset EntryProgrammable data entry for work offsets, tool offsets, and parameters. Allows automatic offset adjustment during program execution.Powerful but use with caution. L2 sets absolute values, some controls use L20 for incremental. Check controller documentation.
G12Circular Pocket Milling CWMills a circular pocket using clockwise tool motion. The tool starts at the center and spirals outward to the specified diameter, then retracts. Simplifies circular pocket programming without CAM.Position tool at pocket center and desired Z depth before calling. I/K/Q usage varies by controller, check documentation. CW direction pushes chips outward (climb milling with standard tooling).
G13Circular Pocket Milling CCWMills a circular pocket using counter-clockwise tool motion. Identical to G12 but with opposite rotation direction. Use for conventional milling approach.Position tool at pocket center and desired Z depth before calling. CCW direction is conventional milling with standard tooling. Some machinists prefer G13 for harder materials.
G15Polar Coordinate Mode CancelCancels polar coordinate mode and returns to Cartesian (X/Y) coordinate programming.Always cancel polar mode when done to avoid confusion. Modal, stays active until G16.
G16Polar Coordinate ModeEnables polar coordinate programming. X specifies radius (distance from origin) and Y specifies angle in degrees. Useful for bolt circles and patterns.X = radius from origin, Y = angle in degrees. Origin is the current work offset origin. Cancel with G15.
G17XY Plane SelectionSelects the XY plane for circular interpolation (G02/G03). Arc movements will occur in the XY plane with Z as the perpendicular axis. This is the default plane for most milling operations.
G18XZ Plane SelectionSelects the XZ plane for circular interpolation. Arc movements will occur in the XZ plane with Y as the perpendicular axis. Common for lathe operations.
G19YZ Plane SelectionSelects the YZ plane for circular interpolation. Arc movements will occur in the YZ plane with X as the perpendicular axis.
G20Inch ModeSets the unit system to inches. All position values and feed rates will be interpreted as inches and inches per minute.
G21Metric ModeSets the unit system to millimeters. All position values and feed rates will be interpreted as millimeters and mm per minute.
G27Reference Point Return CheckMoves to reference point and verifies position. Alarms if machine does not reach reference position. Used for safety verification.Use at program start to verify machine is homed. Alarms if not at reference.
G28Return to Reference PointReturns the machine to its reference point (machine home). Can pass through an intermediate point if coordinates are specified. Often used for safe tool changes.CRITICAL: Always retract Z first before X/Y return to avoid crashes. G91 G28 Z0 is a common safe retract pattern.
G29Return from Reference PointMoves from reference point through intermediate point to final position. Reverses the G28 path.Uses the intermediate point stored by previous G28. Rarely used in modern programming.
G30Return to 2nd Reference PointReturns the machine to its second reference point. Similar to G28 but goes to an alternate reference position. Useful when G28 position is inconvenient for tool changes.
G31Skip Function / ProbeMoves at feed rate until the skip signal (probe trigger) is received, then stops. Used for touch probing and measuring.Trigger position stored in system variables. Slow feed rate recommended for accuracy.
G32Single-Pass ThreadingCuts a single threading pass synchronized with spindle rotation. Used for custom thread profiles or when full control is needed. Multiple passes required for full thread.Requires spindle encoder. F value is pitch, not feed rate. Use G76 for automatic multi-pass.
G33Constant Pitch ThreadingContinuous threading at constant pitch. Similar to G32 but for continuous thread cutting. Spindle and Z-axis are synchronized.On some controls (Siemens), G33 is the primary threading command.
G34Variable Lead ThreadingCuts threads with variable (increasing or decreasing) pitch. The lead changes at a specified rate per revolution, creating tapered or accelerating thread forms.Positive K increases lead (pitch gets coarser), negative K decreases lead. Used for worm gears and special thread forms.
G37Automatic Tool Length MeasurementInitiates automatic tool length measurement using a tool length measuring device (probe). Measures the tool and stores the offset automatically.Requires tool length measurement hardware (tool setter). Automatically updates tool length offset register.
G38.2Probe Toward - Stop on ContactMoves toward workpiece until probe contact, then stops. Standard probing move. Error if probe doesn't trigger.Generates error if probe not triggered by end of move. Used in probing routines.
G40Cutter Compensation CancelCancels cutter radius compensation (G41/G42). Tool path returns to programmed path. Should be called before tool changes and at program end.Must exit compensation with a linear move (G00/G01). Cannot cancel during an arc.
G41Cutter Compensation LeftActivates cutter radius compensation to the left of the programmed path. Tool is offset by its radius to the left of the direction of travel. Used for climb milling on external profiles.Must enter compensation with a linear lead-in move. Offset value in D register = tool radius (not diameter on most controls).
G42Cutter Compensation RightActivates cutter radius compensation to the right of the programmed path. Tool is offset by its radius to the right of the direction of travel. Used for conventional milling on external profiles.Must enter compensation with a linear lead-in move. Offset value in D register = tool radius.
G43Tool Length Compensation +Activates tool length compensation in the positive direction. Adds the offset value to the Z axis position. Standard for milling operations.H number typically matches tool number. Apply after tool change and before any Z moves to work.
G44Tool Length Compensation -Activates tool length compensation in the negative direction. Subtracts the offset value from the Z axis position. Less commonly used than G43.
G49Tool Length Compensation CancelCancels tool length compensation. Returns Z axis to programmed values without offset.Automatically cancelled by some controllers on M06. Good practice to call before tool change.
G50Scaling Cancel / Max Spindle SpeedOn mills: Cancels scaling (G51). On lathes: Sets maximum spindle speed for constant surface speed mode (G96).Function varies by machine type. On lathe, critical for CSS operations to prevent over-speed.
G50.1Mirror Image CancelCancels mirror image mode. Returns axes to normal direction of movement after G51.1 mirroring.Always cancel mirror mode when done. Forgetting to cancel can cause crashes on subsequent operations.
G51ScalingActivates scaling of programmed coordinates. Multiplies all moves by the scale factor around the specified center point.Cancel with G50. Be careful with scaling - affects all subsequent moves including rapids.
G51.1Mirror Image EnableEnables mirror image mode for specified axes. Reverses the direction of programmed moves around the specified mirror center point. Useful for machining symmetric parts.Cancel with G50.1. Specify which axes to mirror by including their center coordinates. Great for symmetric parts, program one side, mirror for the other.
G52Local Coordinate SystemSets a local coordinate system offset that is added to the active work coordinate system. Creates a temporary shift without changing the work offset.G52 X0 Y0 Z0 cancels the local offset. Useful for pattern work.
G53Machine Coordinate SystemTemporarily use machine coordinates for the current block only. Coordinates are interpreted relative to machine zero, ignoring work offsets. Non-modal - only affects the block it's on.Must be used with G00 or G01. Non-modal - only affects current line.
G54Work Coordinate System 1Selects work coordinate system 1. This is typically the primary/default work offset used for most machining operations. Origin is set during setup.Work offset values are set in the controller. G54 is the most commonly used work offset.
G54.1Extended Work Coordinate SystemsOn an 0i-MF, G54.1 P1 to P48 are standard and 300 pairs are an option. The 0i-F specification lists the 48 pairs as not available on the lathe.
G55Work Coordinate System 2Selects work coordinate system 2. Use for second fixture or part setup.
G56Work Coordinate System 3Selects work coordinate system 3. Use for third fixture or part setup.
G57Work Coordinate System 4Selects work coordinate system 4.
G58Work Coordinate System 5Selects work coordinate system 5.
G59Work Coordinate System 6Selects work coordinate system 6.
G60Single Direction PositioningApproaches the final position from one direction only to eliminate backlash error. Machine overshoots and returns from the specified direction for precise positioning.Used for precision boring and jig boring where backlash compensation is critical. Direction set by parameter.
G61Exact Stop ModeMachine decelerates to complete stop at each programmed point. Ensures precise positioning but slower cycle time. Use for sharp corners.Use for accurate corners. G64 returns to cutting mode for smoother motion.
G62Automatic Corner OverrideAutomatically reduces feed rate at corners to maintain accuracy. Balances speed and precision for complex contours.Useful for complex 2D contours where sharp corners need accuracy but straights need speed.
G63Tapping ModeActivates tapping mode where spindle and feed are synchronized. Feed override and spindle override are disabled.Overrides disabled to prevent thread damage. F = pitch × RPM.
G64Cutting Mode / Continuous PathEnables continuous path mode for smooth motion. Machine does not decelerate fully at corners, allowing faster cycle times with slight corner rounding.Default mode on most machines. Corners may be slightly rounded based on speed.
G65Macro CallCalls a custom macro program with optional arguments. Allows parameterized subprograms for repetitive operations.Arguments A-Z map to local variables #1-#26. Macro must be defined on controller.
G66Macro Modal CallActivates modal macro call. The macro is executed after every subsequent motion block until cancelled.Cancel with G67. Useful for repetitive operations at multiple positions.
G67Macro Modal Call CancelCancels modal macro call activated by G66.
G68Coordinate System RotationRotates the coordinate system around a specified point by a specified angle. All subsequent moves are in the rotated system.Cancel with G69. Affects G00, G01, G02, G03 moves. Use for patterns.
G69Coordinate System Rotation CancelCancels coordinate system rotation activated by G68. Returns to normal coordinate system.
G70Finishing CycleFinishing cycle that follows a previously defined rough profile (G71/G72). Removes the finishing allowance left by the roughing cycle with a single pass.Must be used after G71 or G72 roughing cycle. Uses same profile blocks.
G71Rough Turning Cycle (OD/ID)Automatic roughing cycle for turning. Removes material in multiple passes parallel to the Z-axis, leaving a finishing allowance. Used for OD and ID turning.Two-line format on Fanuc. Profile blocks (P-Q) define the finished shape. Follow with G70 for finishing.
G72Rough Facing CycleAutomatic roughing cycle for facing. Removes material in multiple passes parallel to the X-axis. Used for face roughing operations.Similar to G71 but cuts parallel to X-axis. Use for parts with more facing than turning.
G73High Speed Peck DrillingChip breaking peck drill cycle with minimal retract. Drills incrementally with small retracts to break chips without fully retracting. Faster than G83 for most materials.Retract distance is typically small (0.5-1mm). Use G83 for deep holes requiring full chip evacuation.
G74Left-Hand Tapping CycleLeft-hand (reverse) tapping cycle. For cutting left-hand threads. Spindle runs CCW during cutting.Start with M04 (CCW spindle). Feed = Pitch x RPM.
G74latheFace Grooving / Peck Drilling Cycle (Lathe)On lathe: Peck drilling cycle in Z-axis or face grooving cycle. Plunges with pecks for chip breaking.Different from mill G74 (left-hand tapping). On lathe, this is peck drilling/grooving.
G75Grooving Cycle (OD/ID)Peck grooving cycle for OD or ID grooves. Plunges to depth with multiple pecks for chip breaking, then traverses to create groove width.P and Q values are in microns (no decimal point). For 2mm peck, use P2000.
G76Fine Boring CycleFine boring cycle with oriented spindle stop and shift. Tool retracts off the wall before withdrawing to prevent scratching.Requires oriented spindle stop (M19). Q direction set by parameter. Use for precision bores.
G76latheAutomatic Threading Cycle (Lathe)Complete automatic threading cycle for lathe. Cuts multiple passes with automatic depth calculation, in-feed angle, and spring passes. Most common threading method.Two-line format. First line sets parameters, second line sets dimensions. P value on second line is thread depth in microns.
G80Canned Cycle CancelCancels any active canned cycle (G73, G81-G89). Returns to normal motion mode.Good practice to call G80 after completing all holes in a pattern.
G81Drilling CycleSimple drilling cycle. Rapids to R-plane, feeds to Z depth, then rapids out. No dwelling or pecking.Use for shallow holes (typically less than 3x diameter). For deeper holes, use G73 or G83.
G82Drilling Cycle with DwellDrilling cycle with dwell at the bottom. Rapids to R-plane, feeds to depth, dwells, then rapids out. Used for counterboring and spot drilling.Dwell improves bottom finish and hole accuracy. P value in milliseconds on most controls.
G83Deep Hole Peck DrillingFull retract peck drilling cycle. Drills incrementally with full retract to R-plane for chip evacuation. Essential for deep holes.Use for holes deeper than 3x diameter. Q value typically 1-2x drill diameter. Use coolant (M08).
G84Tapping CycleRight-hand tapping cycle. Feeds in at specified rate, reverses spindle, feeds out. Synchronizes spindle and feed for threading.Feed = Pitch x RPM. Example: M8x1.25 at 400 RPM needs F500. Use rigid tapping if available.
G85Boring CycleSimple boring cycle. Feeds in at specified rate, feeds out at same rate. Provides better finish than rapid retract.
G86Boring Cycle with Spindle StopBoring cycle that stops spindle at bottom before rapid retract. Prevents drag marks on bore wall.Spindle restarts automatically on retract. Use for precision bores.
G87Back Boring CycleBack boring cycle for machining from the back side. Tool enters through hole, orients, shifts, and bores upward.Requires oriented spindle stop (M19). Complex cycle - verify with dry run.
G88Boring Cycle with Manual RetractBoring cycle with dwell and manual retract. Stops at bottom for operator inspection or manual intervention.Requires operator to press cycle start for retract. Use for inspection or special operations.
G89Boring Cycle with DwellBoring cycle with dwell at bottom, then feed retract. Dwell allows spring pass for improved finish.Dwell allows tool deflection to recover, improving bottom finish and diameter accuracy.
G90Absolute PositioningOn a mill, and on a lathe in G code system B or C. In system A, G90 is the outer and inner diameter cutting cycle, and absolute or incremental is set by the address: X and Z against U and W.
G91Incremental PositioningOn a mill, and on a lathe in G code system B or C. A system A lathe has no G91: incremental moves are written with U and W.
G92Position Register / Coordinate System OffsetSets the current position to specified values without moving. Creates an offset to make current position equal to given coordinates. Use with caution - can cause confusion.WARNING: G92 offset is persistent and can cause crashes if forgotten. Prefer G54-G59 work offsets when possible.
G92latheThreading Cycle (Simple)On lathe: Simple threading cycle for single straight or taper thread pass. Commonly used for threading operations where manual control of each pass is desired.Simpler than G76 but requires manual programming of each pass depth. Good for learning threading.
G93Inverse Time Feed ModeFeed rate specifies time to complete the move (1/minutes). F2.0 means move completes in 0.5 minutes. Used for complex multi-axis moves.Essential for 5-axis simultaneous machining. F = 1 / time in minutes.
G94Feed Per MinuteOn a mill. On a lathe in G code system A, G94 is the end face turning cycle and feed per minute is G98.
G95Feed Per RevolutionSets feed rate mode to units per revolution. Feed rate value represents distance traveled per spindle revolution. Common for turning and drilling operations.
G96Constant Surface SpeedActivates constant surface speed mode (lathe). Spindle RPM varies automatically to maintain constant cutting speed as diameter changes.ALWAYS set G50 maximum RPM before G96 to prevent spindle overspeed at small diameters.
G97Constant RPMCancels constant surface speed mode. Spindle runs at the programmed RPM regardless of cutting diameter.Use for threading operations and when CSS is not appropriate.
G98Return to Initial LevelIn canned cycles, tool returns to the initial Z level (where cycle started) after each hole. Safer for fixtures with varying heights.Use when moving between holes that have obstructions between them.
G99Return to R-LevelIn canned cycles, tool returns to the R-plane after each hole. Faster for flat surfaces with clear paths between holes.Use for faster cycle times when part surface is flat and path between holes is clear.

Where Fanuc differs

  • A tool length offset is applied in the G43 block itself, so G43 H01 Z50. arrives at Z50 with the offset in, and on some Fanuc controls a G43 H block with no Z word moves Z by the offset there and then. Put a Z word on the G43 line.
  • On an 0i-MF, G54.1 P1 to P48 extend the six work offsets as standard, and 300 pairs are an option. The EXT (common) row on the offset page is added to every one of G54 to G59.
  • G53 suppresses the work offset for one block only and needs G90 to be active.
  • Cutter compensation C looks two blocks ahead to work out a corner. Two or more consecutive blocks with no movement in the compensation plane leave it nothing to aim at, and it overcuts. The compensation alarms are PS0033 (no intersection at G41/G42), PS0034 (start-up or cancel in an arc block), PS0037 (plane changed with compensation on) and PS0041 (interference, excessive cutting ahead).
  • On the mill, canned cycles sit in group 09 and are cancelled by G80 or by any group 01 motion code, so a bare G00 or G01 block ends the cycle too. K is the repeat count.
  • In G91 the R and Z of a canned cycle are distances, not heights: R from the initial level, Z down from the R plane.
  • The P dwell in G82 and G04 takes whole milliseconds and no decimal point. P0.5 raises PS0007, illegal decimal point.
  • The two peck retract distances are machine data: parameter 5114 is the backoff G73 makes after each peck, parameter 5115 the clearance a G83 rapid stops at above the previous depth.
  • The X, Y and Z on a G28 or G30 are the intermediate point, not the destination, and are read in whichever of G90 or G91 is live. G91 G28 Z0. is the safe form.
  • G92 sets the current position to the given value without moving and the offset persists until it is cleared, which the app's note flags as a crash risk. Prefer G54 to G59.

Frequently asked questions

Which G-codes are the same on a Fanuc mill and a Fanuc lathe?

Motion (G00 to G04), plane selection, G40 to G42 and G54 to G59 read the same on both, and so do G20 and G21 except in G code system C, where they are G70 and G71. Parameter 3401 bits GSB and GSC pick the lathe's system, and in system A the numbers that change meaning are G74 (left-hand tapping on the mill, peck drilling or face grooving on the lathe), G76 (fine boring on the mill, the threading cycle on the lathe) and G92 (position register on the mill, the simple threading cycle on the lathe), with G73, G94, G98 and G99 as well. G90 on a system A lathe is the outer and inner diameter cutting cycle, absolute and incremental are X and Z against U and W, and the lathe list has no plain G43. The table lists both versions of G74, G76 and G92.

What is the safe way to send a Fanuc home?

G91 G28 Z0. first, then G91 G28 X0. Y0. if the table has to move. The axis words are the intermediate point, so in G90 a G28 Z0. goes to part zero before it goes home, and with G43 live the intermediate point is an offset position. Cancel the length and cutter offsets first. See G27 to G30: reference point return.

How many work offsets does a Fanuc have?

Six, G54 to G59, plus 48 more as G54.1 P1 to P48, which are standard on an 0i-MF, and 300 with the 300-pair option. The EXT row on the offset page shifts G54 to G59 together. See G54 to G59: work offsets.

Why does my Fanuc alarm on P0.5 in a dwell?

Because P in G04 and G82 is read as whole milliseconds with no decimal point. P500 is half a second; P0.5 is an illegal decimal point alarm. Haas reads the same word in seconds with a decimal, which is why a Haas program dwells for half a second and the Fanuc copy alarms. See G81 and G82: drilling cycles.

Other controller lists

Last updated 11 Oct 2026