Complete List of CNC G Codes

G code, sometimes called g-code, is a simple programming language for CNC machines. 

Listed below are the codes that use the G word. These codes are preparatory commands.

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

We have put together a complete list of G codes for your reference.

Not all codes are used often.

Below is a list of G codes. They have been organized into group types based on how the machine reacts to the individual code.

If you are new to G code, you should review the code groups and compare the codes within a single group. 

You will quickly see they handle the same function, such as one code to turn something on and one code to turn something off. 

This makes learning the codes twice as easy.

Table of Contents

CNC Movement and Travel

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

Learn more about the G00 code

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 code

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

Learn more about the G02 code

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

Learn more about the G03 code

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

Learn more about the G04 code

Plane Selection

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.

Unit Modes

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

Learn more about the G20 code

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

Learn more about the G21 code

Compensation Codes

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

Learn more about the G40 code

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

Learn more about the G41 code

G42 CNC G Code

G42 - Cutter Compensation Right

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

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

Learn more about the G43 code

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

Learn more about the G49 code

Work Offsets

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

Learn more about the G54 code

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

Learn more about the G55 code

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

Learn more about the G56 code

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

Learn more about the G57 code

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

Learn more about the G58 code

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

Learn more about the G59 code

Canned Cycles

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.

Drills a hole then rapid retracts out of the hole.

Learn more about the G81 code

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.

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

Learn more about the G83 code

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.

Cancel Codes

G50 CNC G Code

G50 - Cancel Scaling

Turns off scaling mode.

G80 CNC G Code

G80 - Canned Cycle Cancel

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

Positioning Modes

All movement locations are relative to a fixed zero such as the work offset (G54, G55, etc.) or machine home location.

Learn more about the G90 code

All movement locations are relative to the machine’s current position.

Learn more about the G91 code

Speeds and Feeds

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.

Plane Return

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

Learn more about the G98 code

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.

Lesser Used G Codes

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.

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.

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

Learn more about the G28 code

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.

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.

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.

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.

G92 CNC G Code

G92 - Program a Work Offset

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

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:

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