Ultimate Guide to CNC G Codes

G codes for CNC machines are preparatory commands.

This means that they set modes or prepare the machine for various actions. 

We have put together a complete list G codes for your reference. Not all are commonly used so we have listed the codes that are rarely used to help you concentrate on the most important and most often used G codes.

Moves the CNC around at the maximum possible speed. Often called rapid traverse.

Learn more about the G00 command

Move the CNC in a straight line to a specific location. The speed of this movement is determined by the feed rate (F).

Learn more about the G01 command

Move the CNC to specific location along along a specified radius traveling clockwise. The speed of this movement is determined by the feed rate (F).

Learn more about the G02 command

Move the CNC to a specific location along a specified radius traveling counterclockwise. The speed of this movement is determined by the feed rate (F).

Learn more about the G03 command

Tells the CNC not to move for a certain amount of time.

Learn more about the G04 command

G09 CNC G Code

G09 - Exact Stop Check (Non-modal)

Causes the machine to come to a stop after each command. Useful for making sharp corners. It causes the machine to stop after executing the current line.

G10 CNC G Code

G10 - Programmed Offset Input

Adjusts offset values. Can change work offset, tool length offset and/or cutter compensation offsets.

G17 CNC G Code

G17 - XY Plane Selection

The vast majority of movement in CNC programs will be relative to the XY plane. Plane selection affects how G02, G03, cutter compensation and some canned cycles are handled.

G18 CNC G Code

G18 - XZ Plane Selection

Plane selection affects how G02, G03, cutter compensation and some canned cycles are handled. G18 tells the machine you are machining radii around the Y axis.

G19 CNC G Code

G19 - YZ Plane Selection

Plane selection affects how G02, G03, cutter compensation and some canned cycles are handled. G19 tells the machine you are machining radii around the Z axis.

G20 CNC G Code

All size and location commands will be in inches until changed.

Learn more about the G20 command

All size and location commands will be in millimeters until changed.

Learn more about the G21 command

G22 CNC G Code

G22 - Stored Stroke Limit

Turns on a set safety zone that will cause the machine to alarm out if it enters.

G23 CNC G Code

G23 - Stored Stroke Limit Cancel

Turns off the stored safety zone.

G27 CNC G Code

G27 - Zero Return Check

Rarely used. This command checks to see that the machine has moved to the zero return position.

G28 CNC G Code

G28 - Zero Return

The machine will move to a specified location and then to the zero return (home) position.

G29 CNC G Code

G29 - Return From Reference Position

The machine will move to the position referenced in the last G28 command. It will then move to the location referenced with the G29 command.

G30 CNC G Code

G30 - Second Position Zero Return

Similar to G28 the machine will move to a specified location and then will move to a secondary reference point in the machine such as a tool changer location.

G31 CNC G Code

G31 - Skip Function

Often used with probing, it is used to move the probe until it hits an object.

G40 CNC G Code

G40 - Cancel Cutter Compensation

Turns off any cutter compensation modes (G41 or G42). 

G41 CNC G Code

G41- Cutter Compensation Left

Shifts the machine tool path to the left based on the radius of the cutting tool.

G42 CNC G Code

G42 - Cutter Compensation Right

Shifts the machine tool path to the right based on the radius of the cutting tool.

G43 CNC G Code

G43 - Tool Length Compensation

Adjusts a tool’s location based on a specified tool height (H) offset.

G44 CNC G Code

G44 - Negative Tool Length Compensation

Rarely used. Adjusts a tool’s location based on a specified height (H) offset in the opposite of the normal direction.

G45 CNC G Code

G45 - Single Offset Increase

Rarely used.

G46 CNC G Code

G46 - Single Offset Decrease

Rarely used. 

G47 CNC G Code

G47 - Double Offset Increase

Rarely used.

G48 CNC G Code

G48 - Double Offset Decrease

Rarely used.

G49 CNC G Code

G49 - Tool Length
Compensation Cancel

Turns off the tool length compensation set by a G43 or G44 command. 

G50 CNC G Code

G50 - Cancel Scaling

Turns off scaling mode.

G51 CNC G Code

G51 - Scaling

Scales the machined part size by a scaling factor.

Scaling factors >1 make it bigger. Scaling factors <1 make it smaller.

G52 CNC G Code

G52 - Temporarily Shift Program Zero

Shifts the program zero location based on a location specified with the command.

G53 CNC G Code

G53 - Return to Machine Zero Position

Rapid moves the CNC to the machine reference position.

G54 CNC G Code

G54 - Work Offset 1

Sets a specific location in the CNC as the zero location for the program.

G55 CNC G Code

G55 - Work Offset 2

Sets a specific location in the CNC as the zero location for the program.

G56 CNC G Code

G56 - Work Offset 3

Sets a specific location in the CNC as the zero location for the program.

G57 CNC G Code

G57 - Work Offset 4

Sets a specific location in the CNC as the zero location for the program.

G58 CNC G Code

G58 - Work Offset 5

Sets a specific location in the CNC as the zero location for the program.

G59 CNC G Code

G59 - Work Offset 6

Sets a specific location in the CNC as the zero location for the program.

G60 CNC G Code

G60 - Single Direction Move

Forces the machine to approach each XY location from the same direction. Helps eliminate location errors caused by machine backlash.

G61 CNC G Code

G61 - Exact Stop Check (Modal)

The machine will come to a stop after each line of code. 

G64 CNC G Code

G64 - Normal Cutting Mode

Cancels both G60 and G61 modes.

G65 CNC G Code

G65 - Custom Macro Call

A macro is similar to a subprogram but it allows you to use variables in the program.

G66 CNC G Code

G66 - Custom Macro Modal Call

Makes the machine call a macro, similar to G65, with every new location given until turned off.

G67 CNC G Code

G67 - Cancel Custom Macro
Modal Call

Cancels any active custom macro modal calls.

G68 CNC G Code

G68 - Coordinate Rotation Mode

Rotates the machine coordinates at a given angle around a specified location.

G69 CNC G Code

G69 - Cancel Coordinate Rotation Mode

Turns off coordinate rotation mode.

G73 CNC G Code

G73 - High-Speed Peck Drilling Canned Cycle

Peck drill a hole by repeatedly drilling, then retracting a small amount, then drilling deeper. Often used to break up chips when drilling.

G74 CNC G Code

G74 - Left-Hand Tapping Canned Cycle

A tapping cycle for left-hand or reverse threads. The spindle must be running in reverse during this cycle. The machine will feed to the bottom of the hole and then reverse the spindle direction and back out of the hole.

G76 CNC G Code

G76 - Fine Boring Canned Cycle

Bores a hole then stops the spindle, retracts the tool from the surface and rapid retracts the tool out of the hole.

G80 CNC G Code

G80 - Canned Cycle Cancel

Cancels any active canned cycles for drilling, boring, tapping, etc.

G81 CNC G Code

G81 - Standard Drilling Cycle

Drills a hole then rapid retracts out of the hole.

G82 CNC G Code

G82 - Standard Drill with Dwell

Drills a hole, dwells at the bottom of the hole for a set amount of time and then rapid retracts out of the hole.

G83 CNC G Code

G83 - Deep Hole Peck Drilling Cycle

The machine will drill in pecks while rapid retracting out of the hole between each peck to help clear chips from the drill.

G84 CNC G Code

G84 - Right-Hand Tapping Cycle

The standard tapping cycle with the spindle running clockwise. The CNC will feed to the bottom of the hole and then reverse the spindle direction and back out of the hole.

G85 CNC G Code

G85 - Reaming Cycle

The machine will feed to the bottom of the hole and then rapid retract out. 

G86 CNC G Code

G86 - Boring Cycle

The machine will feed to the bottom of the hole and then rapid retract out. The tool is not pulled away from the surface which can leave a tool mark on the hole.

G87 CNC G Code

G87 - Back Boring Cycle

Bores a hole from bottom to top. This is the reverse direction of the G86 code.

G88 CNC G Code

G88 - Boring Cycle with Dwell

Bores a hole and then dwells at the bottom for a set amount of time.

G89 CNC G Code

G89 - Back Boring Cycle with Dwell

The machine will feed to the bottom of the hole, pause for a set amount of time and then rapid retract out. The tool is not pulled away from the surface which can leave a tool mark on the hole.

G90 CNC G Code

G90 - Absolute Mode

All movement locations are relative to the work offset (G54, G55, etc.)

G91 CNC G Code

G91 - Incremental Mode

All movement locations are relative to the current position.

G92 CNC G Code

G92 - Program a Work Offset

Sets a work offset based on a specific location in the machine.

G94 CNC G Code

G94 - Feed per Minute Mode

Sets the feed rate to units (inches/mm) per minute. The tool will move at a set rate.

G95 CNC G Code

G95 - Feed per Revolution Mode

Sets the feed rate to units (mm/inches) per revolution. The tool will move a set rate for every spindle rotation.

G96 CNC G Code

G96 - Constant Surface Speed

The spindle speed will vary to maintain the same surface speed of the material.

G97 CNC G Code

G97 - Constant Spindle Speed

The spindle will operate at a consistent RPM.

G98 CNC G Code

G98 - Return to Initial Plane

After a canned cycle the tool will retract to the start of the canned cycle.

G99 CNC G Code

G99 - Return to Rapid Plane

After a canned cycle the tool will retract to a specified location. Can be useful for avoiding workholding fixtures.

Frequently asked questions

How many G codes are there?

We listed 70 G codes in our list alone but in reality there are many more. 

Some will have different meanings on lathes vs mills. Also, different CNC controller manufacturers will include their own special codes. For example, some will have codes such as G103 or they will switch the meaning of a code.

You should always know how your individual machine will react to a specific code. 

What other types of codes are used in CNC programming?

There are numerous codes other than G codes used in CNC programming. 

There are codes for locations, speeds, feeds and machine operations among others. For the most common codes, review our posts on CNC codes and M codes.

Who needs to know G code?

Anyone who works with a CNC machine would benefit from understanding G code. 

While it may not be a requirement for their job depending on where they work, these positions would benefit from understanding G codes:

  • CNC operator
  • CNC setup
  • CNC programming
  • CNC machinist

Is learning G code hard?

Learning G code can be a daunting task when there are so many codes to understand. 

While it is true that there are a lot of codes that can be used, you should know that most shops will only use a small selection of codes which cuts down the number you need to understand before you are up to speed.

Don’t be overwhelmed. Figure out which codes are the most commonly used ones and start your learning there.

Leave a Comment