Quick Answer: What is G-Code and What Does the “G” Stand For?
G-Code is the primary programming language used to control CNC (Computer Numerical Control) machines. The “G” in G-Code stands for “Geometric,” because its main purpose is to command the geometry of the tool’s path—where it moves, how it moves, and at what speed. It’s the language that translates a digital design into the physical motion of a machine tool.
My Introduction: More Than Just a Letter
Hi, I’m Clive, a senior manufacturing engineer here at RM (Rapid Manufacturing). Every single day, I walk through our shop floor and hear the hum of our Haas and DMG MORI CNC machines. That sound—the precise whir of a spindle, the smooth travel of a cutting tool—is the sound of a language being spoken. That language is G-code.
To an outsider, a screen full of G-code looks like cryptic, repetitive text. But to an engineer or a machinist, it’s a detailed set of instructions, a story being told to a multi-ton machine with micron-level precision. Many people ask, “What does the ‘G’ stand for?” While the simple answer is “Geometric,” the real answer is far more profound. Understanding G-code is understanding the very heart of modern manufacturing. In this guide, I’m going to pull back the curtain and show you not just what it is, but how it works and why it’s the single most important language in our industry.
The “G” in G-Code: It’s All About Geometry and Motion
Let’s get this out of the way first. The letter “G” precedes a command that dictates the machine’s movement and how it should interpret the dimensional data that follows. Think of it as the verb in a sentence—it tells the machine what action to take.

- Positioning: Where should the center of the tool go? (e.g.,
X100.5 Y75.0 Z-10.0) - Path: How should it get there? In a straight line? In a clockwise arc?
- Rate: How fast should it travel along that path?
For example, the command G01 tells the machine, “Prepare to move in a straight, controlled line (a linear interpolation).” The coordinates that follow that G01 command are the destination, and an “F” word (Feed rate) tells it how fast to go. The “G” sets the type of geometric action.
Beyond the Letter: What G-Code Actually Does
While the “G” defines the type of motion, G-code as a whole is a complete instruction set. A single line of G-code, often called a “block,” can contain multiple pieces of information that the machine’s controller reads and executes in order.

Consider this common line of G-code:
N100 G01 X50.0 Y25.0 F200;
Let’s break that down like a sentence:
N100(Block Number): This is like a line number in a book (N). It gives the line a unique identifier, which is useful for editing and troubleshooting.G01(G-Code): The “verb.” This command says, “Perform a linear feed move.” In plain English, “Move in a straight line at a specified cutting speed.” This is different fromG00, which means “Move as fast as possible,” used for non-cutting repositioning.X50.0 Y25.0(Coordinates): The destination. These are the X and Y coordinates on the machine’s Cartesian plane where the tool should end its move.F200(Feed Rate): The speed. This tells the machine to move at a rate of 200 millimeters per minute (or inches per minute, depending on the machine’s setup).;(End of Block): This is the period at the end of the sentence. It tells the controller that the instruction is complete.
So, that single line of code tells the machine a complete story: “On line 100, I want you to perform a straight-line cutting move to the coordinate X=50, Y=25 at a speed of 200 mm/minute.”
The Unspoken Partner: A Quick Introduction to M-Code
You cannot talk about G-code without mentioning its essential partner: M-Code. If G-code is the “Geometric” code for motion, M-code is the “Miscellaneous” or “Machine” code.
M-codes control all the non-geometric functions of the machine. They are the switches, buttons, and auxiliary functions. Think of it this way:
- G-Code: Tells the car where to drive and how fast.
- M-Code: Tells the car to turn on the headlights, start the windshield wipers, or open the trunk.
Common M-codes include:
M03: Turn the spindle on (clockwise).M05: Turn the spindle off.M08: Turn the flood coolant on.M09: Turn all coolant off.M30: End the program and reset.
A G-code program is actually a carefully choreographed dance between G-codes (motion) and M-codes (machine actions) to produce a finished part.
Why G-Code Isn’t Just One “Standard” Language
A common point of confusion for newcomers is that G-code can vary slightly from machine to machine. While the core commands (G00, G01, G02, G03) are nearly universal, different machine controller manufacturers (like Fanuc, Haas, Siemens, or Heidenhain) have their own “dialects.
This is because each machine has unique features. One machine might have a special probing cycle that another doesn’t, so it will have a proprietary G-code to activate it. At RM, our machinists are multilingual; they understand the nuances between the Haas dialect on our VF series mills and the Siemens dialect on our more complex 5-axis machines. This is why a critical piece of software in any modern shop is the “post-processor,” which acts as a translator, converting a generic toolpath from our CAM software into the specific G-code dialect that a particular machine needs to run perfectly.
A Practical G-Code “Cheat Sheet”: The 10 Commands I Use Every Day
While there are hundreds of G-codes, the reality of daily manufacturing is that a handful of them do 90% of the work. If you understand these core commands, you understand the fundamentals of CNC motion. Think of this as the essential vocabulary. I’ve put them into a table with my own notes on why they’re so critical.
| G-Code | Name | Function & Clive’s Notes |
|---|---|---|
| G00 | Rapid Positioning | Function: Move the tool at the machine’s maximum possible speed from one point to another. My Note: This is for non-cutting moves only—getting the tool into position above the part or moving it out of the way. Using G00 to move into the material is the fastest way to break a tool, scrap a part, and get a talking-to from your shop foreman. Speed is great, but only when you’re moving through air. |
| G01 | Linear Interpolation | Function: Move the tool in a straight line at a specified, controlled feed rate (F). My Note: This is the workhorse of CNC milling. Every straight cut, every flat face, every angled chamfer is made with G01. Its partner is the F word (e.g., F300.0), which dictates the cutting speed. Get this speed wrong, and you’ll get poor surface finish, or worse, a broken tool. |
| G02 / G03 | Circular Interpolation | Function: Move the tool in a circular arc (G02 for clockwise, G03 for counter-clockwise) at a controlled feed rate. My Note: This is how we cut circles, fillets, and complex curves. It requires defining the endpoint of the arc and the center point or the radius (I, J, K, or R parameters). Forgetting the direction (G02 vs. G03) is a classic rookie mistake that results in a part that’s a mirror image of what you designed. |
| G20 / G21 | Unit Selection | Function: G20 sets the machine to program in Imperial units (inches). G21 sets it to Metric units (millimeters). My Note: This is one of the most critical commands at the very top of a program. Mismatching the units between your design (CAD) and your program (CAM/G-code) can lead to a part that is 25.4 times too big or too small. We’ve seen it happen! |
| G28 | Return to Home | Function: Sends the machine axes to their “home” or “zero return” position. My Note: This is a safety and reset command, often used at the end of a program. It sends the tool to a known, safe location, far away from the part and the vise, making it safe to open the door and remove the finished component. |
| G41 / G42 | Cutter Compensation | Function: Shifts the toolpath to the left (G41) or right (G42) of the programmed path by the radius of the cutting tool. My Note: This is a more advanced but absolutely essential concept for precision. Instead of programming the path of the tool’s edge, we program the path of its centerline. Cutter compensation tells the machine to automatically offset that path based on the tool’s diameter, allowing us to precisely control the final dimensions of the part and adjust for tool wear. |
| G54 | Work Coordinate System (WCS) | Function: Activates the primary “Work Coordinate System.” It tells the machine where the “X0 Y0 Z0” of the part is located on the machine’s table. My Note: The machine has its own home position (G28), but that’s not where our block of aluminum is. We use a probe or an edge finder to locate a corner or the center of our workpiece and save that location as G54. When the program calls G54, all subsequent coordinates are relative to that specific spot on our part, not the machine’s absolute home. You can have multiple WCS (G55, G56, etc.) for jobs with multiple parts. |
| G90 / G91 | Positioning Mode | Function: G90 sets Absolute Positioning mode. G91 sets Incremental Positioning mode. My Note: In G90 (the most common mode), all coordinates (X, Y, Z) are relative to the G54 part zero. X100 means “go to the 100mm position.” In G91, coordinates are relative to the last position. X100 means “move 100mm in the positive X direction from where you are now.” Mixing these up is a recipe for disaster. 99% of the time, we operate in G90. |
| G81 | Simple Drilling Cycle | Function: A “canned cycle” that automates a standard drilling operation. It rapids to a safe plane, feeds down to the specified depth, and rapids back up. My Note: Canned cycles are a programmer’s best friend. Instead of writing four or five lines of code for every single hole, we use G81 and just provide a list of X/Y coordinates. The machine automatically repeats the drill-and-retract motion at each location. There are other cycles for deep hole drilling (G83), tapping (G84), and boring (G85). |
G-Code vs. M-Code: A Head-to-Head Comparison
We’ve established that G-code and M-code are partners, but their roles are distinct. A great machinist understands exactly what each is responsible for. Here’s a direct comparison to make the difference crystal clear.
| Aspect | G-Code (Geometric) | M-Code (Miscellaneous / Machine) |
|---|---|---|
| Primary Purpose | Controls the motion of the machine’s axes and the path of the tool. | Controls the on/off states of the machine’s hardware and auxiliary functions. |
| Analogy | The steering wheel, accelerator, and brake pedal of a car. It dictates where the car goes and how it gets there. | The ignition key, headlights, coolant pump, and door locks of a car. It controls the car’s systems. |
| Governs… | Position, speed, and path (geometry). | Spindle rotation, coolant flow, tool changes, and program flow. |
| Core Question Answered | “Where is the tool going and how is it moving?” | “What hardware on the machine should be turned on or off?” |
| Example Commands | G01 (Linear move), G02 (Arc move), G90 (Absolute mode). |
M03 (Spindle on), M08 (Coolant on), M06 (Tool change). |
| Impact on Part | Directly creates the shape, size, and features of the part. | Enables the conditions necessary for cutting but doesn’t directly form the part’s geometry. |
In short, a CNC program is an elegant interplay between these two command sets. A G01 command is useless if the spindle isn’t turned on first with an M03. An M08 command to turn on coolant is pointless if the tool isn’t moving with a G01. They are two sides of the same coin, working together to turn a raw block of metal into a finished component.
Case Study: Machining a Simple Aluminum Bracket
Theory is great, but let’s see how this works in the real world. A customer just sent us a design for a simple L-shaped bracket made from 6061 aluminum. It needs its outer profile cut, and four mounting holes drilled. Here’s a simplified look at how we take that from a file to a physical part using G-code.
Step 1: The Design (CAD)
The customer provides a 3D model, which we load into our CAM (Computer-Aided Manufacturing) software, like Mastercam or Fusion 360. This is the digital blueprint.
Step 2: The Toolpath (CAM)
In the CAM software, we don’t write G-code directly. Instead, we create “toolpaths.” We tell the software:
- “Use a 10mm end mill to cut the outside profile.”
- “Use a 5mm drill to create the four holes.”
- “Set the spindle speed to 8,000 RPM and the feed rate to 1,200 mm/minute.”
The software shows us a visual simulation of the tool cutting the virtual part. We can check for any collisions or errors before a single piece of metal is touched.
Step 3: The Post-Processor (The Translator)
Once we’re happy with the simulation, we click “Post.” The post-processor is a configuration file specific to our Haas VF-2 machine. It acts as a translator, converting the visual, generic toolpaths from our CAM system into the precise G-code “dialect” that our Haas controller understands. This is what it spits out:
Step 4: The G-Code in Action (A Simplified Snippet)
%
O0123 (ALUMINUM_BRACKET_OP1);
N10 G21 G90 G54; (Use Metric, Absolute Positioning, WCS #1)
(TOOL 1 - 10MM ENDMILL - PROFILE)
N20 T01 M06; (Select Tool #1 and perform tool change)
N30 G43 H01 Z50.0; (Activate tool length comp, move to safe Z height)
N40 S8000 M03; (Set spindle speed to 8000 RPM, turn spindle on CW)
N50 M08; (Turn flood coolant on)
N60 G00 X-10.0 Y-10.0; (Rapid move to start position outside the part)
N70 G01 Z-5.0 F500.0; (Plunge into material at a slower feed rate)
N80 G41 D01 X0.0 F1200.0; (Activate cutter comp, move to the part edge at full feed rate)
N90 Y50.0; (Cut along the first edge)
N100 G02 X10.0 Y60.0 R10.0; (Cut a clockwise corner radius)
... (many more lines of G01, G02, G03 to complete the profile) ...
N200 G00 Z50.0; (Rapid retract to safe height)
N210 M05; (Stop the spindle)
N220 M09; (Turn coolant off)
(TOOL 2 - 5MM DRILL - HOLES)
N230 T02 M06; (Select Tool #2 and perform tool change)
... (similar setup for the drill) ...
N280 G81 G99 Z-12.0 R2.0 F400.0; (Drilling cycle: Z depth -12mm, Retract plane 2mm)
N290 X15.0 Y15.0; (Drill first hole at this coordinate)
N300 X85.0; (Drill second hole)
N310 Y35.0; (Drill third hole)
N320 X15.0; (Drill fourth hole)
N330 G80; (Cancel drilling cycle)
N340 G28 Z0.0; (Return Z-axis to home)
N350 M30; (End program and reset)
%
The Result
Our machinist loads this program, sets up the aluminum block in the vise, finds the part zero (G54), and hits “Cycle Start.” The machine then flawlessly executes these instructions. The spindle whirs to life, coolant floods the part, and the end mill carves out the profile with perfect precision. After the tool change, the drill efficiently creates the four holes. A few minutes later, the machine goes silent, and a finished, in-spec bracket is ready to be cleaned and shipped. That is the power of G-code: turning a digital language into a physical reality.
The Definitive G-Code List: A Programmer’s Reference
In Part 2, I gave you my top 10 daily drivers. Now, let’s expand that into a more comprehensive reference list, organized by function. This is the kind of chart you’ll find taped to the side of a CNC machine in shops all over the world. Understanding these groups is the key to reading and troubleshooting any G-code program.
| Category | Code | Name & Function | Clive’s Notes |
|---|---|---|---|
| Motion Commands | G00 | Rapid Positioning: Maximum speed travel for non-cutting moves. | The “get there fast” command. Only use it when moving through open air. |
| G01 | Linear Interpolation: Controlled, straight-line movement for cutting. | The workhorse. Every flat face, straight line, and chamfer uses this. | |
| G02 | Circular Interpolation (Clockwise): Creates a CW arc. | For cutting circles and rounded corners. Requires an endpoint and a radius (R) or center point (I,J). | |
| G03 | Circular Interpolation (Counter-Clockwise): Creates a CCW arc. | The opposite of G02. Mixing them up will give you a mirrored curve. | |
| G04 | Dwell: Pauses the machine for a specified time (P). | Essential for operations like spot drilling or boring to ensure a clean cut at the bottom of a hole. | |
| Coordinate & Plane Selection | G17 | XY Plane Selection: Sets the working plane for circular moves. | The default for most vertical milling machines (like our Haas). |
| G18 | XZ Plane Selection: Sets the working plane for lathes and horizontal mills. | Used when the tool is moving along the Z-axis while cutting an arc. | |
| G19 | YZ Plane Selection: Sets the working plane for specific side-milling operations. | The least common of the three, but critical for complex 5-axis work. | |
| G20/G21 | Inch / Millimeter Mode: Sets the machine’s units. | A critical command at the start of a program. Mismatching this can scrap a part by a factor of 25.4. | |
| G28 | Return to Home: Sends axes to the machine’s reference zero point. | A safety command used to move the tool to a known safe position. | |
| G54-G59 | Work Coordinate Systems (WCS): Defines the part’s zero point. | G54 is the default. This is how we tell the machine where our raw material is clamped on the table. |
|
| G90 | Absolute Positioning: All coordinates are relative to the active WCS zero. | The standard mode. X10 means “go to the X=10 position.” |
|
| G91 | Incremental Positioning: Coordinates are relative to the last position. | A specialty mode. X10 means “move 10 units in X from where you are now.” Dangerous if used incorrectly. |
|
| Cutter Compensation | G40 | Cancel Cutter Compensation: Turns off compensation. | Always used after a compensated move to return the machine to its default state. |
| G41 | Cutter Compensation Left: Offsets the tool path to the left by the tool’s radius. | Allows us to program the part’s exact geometry and let the machine account for the tool size. | |
| G42 | Cutter Compensation Right: Offsets the tool path to the right by the tool’s radius. | The opposite of G41, used for operations like climb milling in the opposite direction. | |
| Canned Cycles (Drilling, Tapping, Boring) | G80 | Cancel Canned Cycle: Ends any active canned cycle mode. | You must use this after your last hole to stop the machine from trying to drill at the next coordinate. |
| G81 | Simple Drilling Cycle: Drills to a specified depth and rapids out. | The most basic and common drilling cycle. | |
| G83 | Peck Drilling Cycle: Drills incrementally, pulling the drill out to clear chips. | Absolutely essential for deep holes to prevent chips from packing up, overheating, and breaking the drill. | |
| G84 | Tapping Cycle: Taps a hole to a specified depth and reverses the spindle to exit. | A lifesaver. It synchronizes the feed rate with the spindle RPM to create perfect threads. Never try to tap manually with G-code if you can avoid it! |
The Future of G-Code: Is It Here to Stay?
With the rise of incredibly sophisticated CAM software, 3D simulations, and even AI-driven toolpaths, a common question arises: “Do we even need to learn G-code anymore?”
The answer is an emphatic yes, but the role of the machinist is evolving.
Think of it like this: modern software developers write in high-level languages like Python or C++, not in the raw binary or assembly code that the computer’s processor actually understands. A “compiler” does the translation for them.
In our world, CAM software is the high-level language, and G-code is the assembly code.
- The Programmer’s Role: Today, very few of us write complex programs line-by-line in a text editor. Our job is to create the strategy in the CAM system. We define the geometry, select the right tools, and set the optimal speeds and feeds. The CAM software then acts as our compiler, “posting” thousands of lines of pristine, error-checked G-code in seconds.
- The Machinist’s Role: The modern machinist is a highly skilled technician, not just a code-writer. Their job is to set up the machine, verify the program, and—most importantly—understand the G-code well enough to troubleshoot and optimize it at the machine. When a tool isn’t cutting right or a surface finish is poor, they can’t go back to the CAM seat. They need to be able to read the G-code on the controller, identify the problematic line (maybe an incorrect feed rate or a bad coordinate), and make a live adjustment.
So, while we may not hand-write G-code as often, the ability to read and understand it remains the fundamental dividing line between a “button-pusher” and a true CNC professional. It’s the language the machine speaks, and to be a master of the machine, you must be fluent in its language.
Conclusion: From Geometry to Reality
At its core, the answer to “What does G-code stand for?” is simple: Geometric Code. It is the language of motion, the digital DNA that instructs a multi-ton machine to move with microscopic precision.
But its true meaning is far more profound. G-code is the critical bridge between a designer’s imagination and a physical, tangible product. It’s the silent partner to M-code (Miscellaneous), which handles the machine’s hardware. Together, they form a complete instruction set that has driven the manufacturing world for over half a century.
From the simplest bracket to the most complex aerospace turbine blade, every feature is defined by a series of G-code commands. Understanding this language, even at a high level, empowers you to understand the very essence of modern manufacturing. It allows you to look at a finished product and not just see its shape, but visualize the precise dance of the cutting tool that brought it to life.
Here at RM (Rapid Manufacturing), G-code is the language we speak every single day. It’s how we guarantee that the part you design on your screen is the exact same high-quality part that arrives at your door.
Frequently Asked Questions (FAQs)
1. What does G in G-code stand for?
The “G” stands for Geometric. These codes control the geometry of the toolpath—where the machine moves, how it moves (straight line or arc), and the coordinate system it uses.
2. What do G and M codes stand for?
“G” stands for Geometric Code, controlling the machine’s motion and position. “M” stands for Miscellaneous Code (or Machine Code), which controls the machine’s hardware functions like turning the spindle on/off (M03/M05), activating coolant (M08/M09), or changing a tool (M06).
3. What does the G-code mean?
G-code is the common name for the most widely used programming language for CNC (Computer Numerical Control) machines. It is a set of text-based instructions that tells the machine’s controller how to move its axes to cut, shape, or form a part.
4. What does code G stand for?
Code “G” is simply another way of saying G-code. The “G” itself refers to the Geometric nature of the commands, as they primarily define the shape and motion of the manufacturing process.
About the Author
Clive is a Senior Manufacturing Engineer at RM (Rapid Manufacturing) with over 15 years of hands-on experience in CNC programming, toolpath optimization, and process control. He specializes in translating complex customer designs into efficient, high-quality G-code for 3-axis and 5-axis machining centers. When he’s not optimizing cycle times, you can find him mentoring the next generation of machinists on the shop floor.
References
- NIST (National Institute of Standards and Technology): The RS274/NGC Interpreter. This is the foundational public document that outlines the standards for the G-code language (often referred to as the Fanuc dialect). It’s the “original text” for modern G-code.
- Haas Automation, Inc.: Mill Operator’s Manual. Machine tool builders provide the definitive G-code list for their specific controllers, including proprietary codes. The Haas manual is an excellent real-world example of a specific G-code “dialect.”
- Peter Smid, “CNC Programming Handbook, 3rd Edition.” This book is widely considered the industry bible for manual G-code programming, offering deep dives into every aspect of the language.
Disclaimer
The information on this page is for informational purposes only. RM makes no representations or warranties, express or implied, as to the accuracy or completeness of this information. For any third-party services procured through the RM network, it is the buyer’s responsibility to specify and confirm performance parameters, tolerances, materials, and workmanship during the quotation process. For more detailed information, please do not hesitate to contact us.
RM: Your Precision Manufacturing Partner
RM is an industry leader in custom manufacturing solutions. With over 20 years of profound experience, we have become the trusted partner for more than 5,000 clients worldwide. We specialize in a comprehensive range of manufacturing services—including high-precision CNC machining, sheet metal fabrication, 3D printing, injection molding, and metal stamping—to provide you with a true one-stop-shop experience.
Our world-class facility is equipped with over 100 state-of-the-art 5-axis machining centers and operates in strict compliance with the ISO 9001:2015 quality management system. We are dedicated to providing solutions that blend speed, efficiency, and exceptional quality to customers in over 150 countries. From rapid prototyping to large-scale production, we promise delivery in as fast as 24 hours, helping you gain a competitive edge in the market. Choosing RM means selecting an efficient, reliable, and professional manufacturing ally.
Explore our capabilities today by visiting our website: www.rapmaf.com


9 Responses
I’m not sure where you are getting your info, but great topic.
I needs to spend some time learning much more or understanding more.
Thanks for wonderful info I was looking for this information for my mission.