If you just bought your first CNC machine or you're trying to figure out what all those letters and numbers mean in a program file, you're not alone. CNC maker codes can look like a foreign language at first glance. But once you understand how they work, they become the building blocks of every project you'll run on your machine. A solid reference guide saves you hours of trial and error, prevents costly mistakes, and gives you the confidence to write or edit programs yourself instead of relying entirely on software.
What exactly are CNC maker codes?
CNC maker codes are the instructions your CNC machine reads to know what to do. They tell the machine where to move, how fast to spin the cutting tool, when to turn the coolant on, and dozens of other actions. Think of them as a recipe. Each line is a step, and the machine follows them in order from top to bottom.
There are two main families of codes you'll encounter. G-codes handle motion and positioning things like moving in a straight line or cutting an arc. M-codes control machine functions like starting the spindle or switching the coolant on. If you want a deeper breakdown between the two, we covered the differences in this comparison of G-code vs M-code in CNC machining.
Beyond G and M codes, you'll also see number-based parameters like F (feed rate), S (spindle speed), T (tool number), and N (line numbers). Together, these form the complete language your machine speaks.
Why do beginners need a reference guide?
CAM software generates most of your code automatically these days. So why bother learning the codes at all? Here's the reality: software makes mistakes. It might post a code your specific controller doesn't support, or it might set a feed rate that's too aggressive for your material. When something goes wrong mid-program and it will you need to read the code to figure out what happened.
A reference guide helps you:
- Debug programs when your machine throws an error or behaves unexpectedly
- Edit code by hand for simple changes without re-running the entire CAM process
- Understand what your machine is doing at every step, which improves safety
- Communicate with experienced machinists using the same terminology
- Customize post-processors when your CAM output doesn't match your machine's needs
Which G-codes will you use most often?
You don't need to memorize hundreds of codes. Most beginners work with the same handful of G-codes repeatedly. Here are the ones you'll see on nearly every program:
- G00 Rapid move. Moves the tool as fast as possible to a position. Used for non-cutting travel.
- G01 Linear interpolation. Moves in a straight line at a set feed rate. This is your primary cutting motion.
- G02 Clockwise arc interpolation. Cuts a curved path going clockwise.
- G03 Counter-clockwise arc interpolation. Same as G02 but going the other direction.
- G17 XY plane selection. Tells the machine which plane to work on for arcs and canned cycles.
- G20 Inch mode. Sets the machine to read dimensions in inches.
- G21 Metric mode. Sets the machine to read dimensions in millimeters.
- G28 Return to machine home position. A safe way to send the tool back after a job.
- G40 Cancel cutter compensation. Turns off the tool radius offset.
- G41 / G42 Cutter compensation left/right. Adjusts the tool path to account for the tool's radius.
- G90 Absolute positioning. All coordinates are measured from the program origin (zero point).
- G91 Incremental positioning. All coordinates are measured from the tool's current position.
These codes are mostly universal across Fanuc, Mach3, LinuxCNC, and similar controllers. Some brands add proprietary codes, but the basics above will work on almost any machine you'll encounter as a hobbyist or small shop.
Which M-codes should every beginner know?
M-codes control the "housekeeping" functions of your machine. These are just as important as G-codes because without them, your spindle won't spin and your coolant won't flow.
- M00 Program pause. The machine stops and waits for you to press cycle start.
- M03 Spindle on, clockwise. Starts the spindle spinning in the normal direction.
- M04 Spindle on, counter-clockwise. Used for some operations like left-hand tapping.
- M05 Spindle stop. Turns off the spindle.
- M06 Tool change. Commands an automatic tool change (or prompts you on manual machines).
- M08 Flood coolant on.
- M09 Coolant off.
- M30 Program end and rewind. Stops the program and resets it to the beginning.
What does a basic CNC program look like?
Seeing real lines of code makes everything click faster. Here's a simple example of a program that moves the tool to a starting position, cuts a square pocket, and returns home:
N10 G21 G90 G17 Set metric mode, absolute positioning, XY plane
N20 M06 T01 Select tool 1
N30 M03 S10000 Start spindle clockwise at 10,000 RPM
N40 G00 X0 Y0 Rapid move to the origin
N50 G01 Z-5 F500 Plunge down 5mm at 500 mm/min feed rate
N60 G01 X50 F1000 Cut straight across to X50
N70 G01 Y50 Cut up to Y50
N80 G01 X0 Cut back to X0
N90 G01 Y0 Cut back down to the starting Y position
N100 G00 Z25 Rapid move tool up to safe clearance
N110 M05 Stop the spindle
N120 G28 Return to home
N130 M30 End program
Every line has a purpose. If you read it top to bottom, it makes logical sense even if you've never written code before. That's the beauty of CNC maker codes. They follow a straightforward pattern.
What are common mistakes beginners make with CNC codes?
Mistakes with CNC codes can crash your machine, break tools, or ruin a workpiece. Here are the errors that trip up most beginners:
- Confusing G90 and G91 Running in incremental mode (G91) when you think you're in absolute mode (G90) will send the tool to the wrong location. Always know which mode you're in, and set it explicitly at the start of your program.
- Forgetting to set units If your program uses G21 (mm) but your controller defaults to G20 (inches), every move will be 25.4 times larger than intended. That's a guaranteed crash.
- Missing spindle start before cutting Running G01 moves with the spindle off will break your tool or damage the workpiece. Always command M03 or M04 before any cutting motion.
- Rapid moves into the workpiece G00 moves at maximum speed. If you use G00 Z-10 instead of G01 Z-10 with a feed rate, the tool will slam into the material.
- Wrong arc direction Mixing up G02 and G03 cuts the arc in the wrong direction, which can gouge your part or cause tool deflection.
- Not retracting the tool before tool changes If the tool is still buried in the material when M06 fires, you'll crash the next tool into the workpiece.
One practical habit: always run a new program with the rapid override set to 0% and the tool well above the workpiece. Watch the first pass in the air before letting it cut material.
How do different controllers handle maker codes?
Not every CNC controller reads codes the same way. The basics are consistent, but small differences can cause real problems if you're copying code from one machine to another.
- Fanuc The industry standard for industrial machines. Most G-codes and M-codes follow the original Fanuc convention.
- Mach3 / Mach4 Popular for hobby and small shop machines running on Windows. Supports most standard codes but has some unique M-codes for things like turning outputs on and off.
- LinuxCNC Open-source controller that follows the RS274/NGC standard. Close to Fanuc conventions with some extensions.
- Haas Uses Fanuc-based codes but adds proprietary cycles and some M-codes that differ.
- Siemens (Sinumerik) Uses a different programming dialect in some cases. G-codes are similar, but cycle syntax and some motions differ significantly.
When in doubt, check your machine's programming manual. Every controller comes with one, and it's the single most useful document you'll own. If you bought a used machine without a manual, most are available as PDFs from the manufacturer's website.
Can software help me generate and learn these codes?
Yes. You don't have to memorize everything or write every program by hand. Code generator software for CNC machines can build programs for you based on simple inputs like tool paths, depths, and speeds. These tools are especially helpful when you're working with 3-axis machines and want to get running quickly.
That said, don't treat the software as a black box. Use it to generate code, then read through the output line by line. Compare it to your reference guide. This habit builds your understanding faster than any course or textbook because you're studying real code that runs on your actual machine.
What are practical tips for using a maker code reference?
Keep a printed or digital reference card near your machine. When you see an unfamiliar code, look it up right away instead of guessing. Here are more tips from experience:
- Start by editing, not writing from scratch. Load a proven program, change one value (like a depth or feed rate), and observe what happens. This is safer and teaches you cause and effect.
- Label your programs clearly. Use comments inside the code. Most controllers accept text in parentheses: (This line cuts the outer profile). Your future self will thank you.
- Know your machine's coordinate system. Understand where machine zero is versus work zero (your part zero). Many beginner errors come from mixing these up.
- Test with cheap material first. Run new programs on scrap wood, foam, or MDF before touching expensive aluminum or steel.
- Learn one new code at a time. Pick a code you don't understand, write a small test program that uses it, and run it. This builds real knowledge instead of trying to memorize a 200-page manual in one sitting.
If you want a single-page cheat sheet you can keep at your workbench, we put together a beginner's reference page for CNC maker codes that covers the most commonly used commands.
Where should I go from here?
Download or print a reference list of G-codes and M-codes for your specific controller. Open one of your existing programs and try to read it line by line. If you get stuck on a line, look up that code. You'll be surprised how quickly the pattern becomes familiar.
Once you're comfortable reading code, try writing a simple program by hand even something as basic as cutting a rectangle. The hands-on practice locks in the knowledge in a way that passive reading never will.
If you're planning to engrave text or decorative designs into your CNC projects, having the right font matters for clean results. You can explore popular typefaces at stencil font collections for designs that translate well to CNC toolpaths.
Your quick-start checklist
- Identify which controller your machine uses (Fanuc, Mach3, LinuxCNC, etc.)
- Download or bookmark a G-code and M-code reference list for that controller
- Learn the 12 core G-codes listed above they cover 90% of beginner work
- Learn the 8 core M-codes listed above
- Open an existing program file and read through it with your reference guide
- Change one line, run the program on scrap material, and observe the result
- Always set G90 and G21/G20 explicitly at the start of every program
- Run new programs at reduced speed with the tool above the material first
- Keep a printed cheat sheet at your machine for quick lookups
- Practice writing a simple program from scratch within your first week
What Are Maker Codes in Cnc Machine Programming? a Complete Guide
Understanding G-Code vs M-Code in Cnc Machining
Understanding Maker Codes on a Cnc Lathe: a Complete Guide to Reading and Interpreting Them
Cnc Maker Code Generator Software for 3-Axis Machines | G-Code Solutions
How to Find Active Maker Supply Promo Codes
Maker Supply Store Coupon Codes for Quilting Supplies