There are dozens of G-codes in the standard, but a CNC beginner does not need all of them to start reading programs. A smaller core shows up constantly. Learn this set first.
The motion codes
These command movement and appear in almost every line of cutting:
- G00: rapid positioning (non-cutting). See G00 vs G01.
- G01: linear interpolation, a straight feed move.
- G02: clockwise circular interpolation (arc).
- G03: counterclockwise circular interpolation. See G02 vs G03.
Setup and mode codes
These set up how the machine interprets everything else:
- G17 / G18 / G19: select the working plane (XY, XZ, YZ). G17 is the common default for milling.
- G20 / G21: units, inch (G20) or millimeters (G21). Getting this wrong scales your whole part.
- G90 / G91: absolute (G90) or incremental (G91) positioning.
- G54 to G59: work coordinate offsets, telling the machine where your part zero is.
The core dozen at a glance
| Code | Meaning | Group |
|---|---|---|
G00 / G01 | Rapid positioning / linear feed | Motion |
G02 / G03 | Clockwise / counterclockwise arc | Motion |
G17-G19 | Plane select (XY / XZ / YZ) | Setup |
G20 / G21 | Inch / millimeter units | Setup |
G90 / G91 | Absolute / incremental positioning | Setup |
G54-G59 | Work coordinate offsets | Setup |
G40-G43 | Cutter and tool length compensation | Compensation |
G28 | Return to reference (home) | Reference |
Reference and compensation codes
- G28: return to the machine reference (home) position.
- G40 / G41 / G42: cutter compensation off, left, and right.
- G43: tool length compensation.
How to learn them
A list like this is a reference, and reading a reference builds recognition, not recall. To actually memorize these, drill them as code-to-meaning and meaning-to-code questions, and put extra reps on the confusable pairs. That is the core of the practice-first method for beginner CNC code. Many beginners get the modal behavior wrong too, so it is worth reading about modal versus non-modal G-codes once these names are familiar.
Then do the same for the machine functions in common M-codes for CNC beginners.
Bottom line
Start with the motion codes, the units and positioning modes, work offsets, and compensation. That dozen covers most beginner programs. Memorize them by recall, not re-reading.
Sources
- LinuxCNC G-code quick reference
- Wikipedia: G-code
- ISO 6983-1 (numerical control of machines)
- CNCCookbook: G-code and M-code cheat sheet
Frequently asked questions
How many G-codes do I need to learn as a beginner?
Around a dozen will carry you through most beginner programs. The motion codes (G00 to G03), the units and positioning modes, work offsets, and the compensation codes cover the vast majority of what you will read.
Are G-codes the same on Haas and Fanuc?
The most common G-codes behave the same across Haas, Fanuc, and most controls because they follow a shared standard. Always confirm the details against your specific machine’s manual, since some codes and options vary.
What is the fastest way to memorize the common G-codes?
Active recall, not re-reading a chart. A free tool like G-Code Sprint turns the core G-codes into timed code-to-meaning and meaning-to-code drills and repeats the ones you miss, which locks them in faster than a printed cheat sheet.
G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.