G Code CNC Basic Programming: Mastering CNC Machines - Fictiv
- Capabilities Capabilities
CNC Machining
Tight tolerances and finishing capabilities, manufactured in one day.
Sheet Metal
Experience the versatility & cost efficiency with flexible application options.
Injection Molding
Production-grade steel tooling, as fast as weeks.
Die Casting
Create high quality custom mechanicals with precision and accuracy.
3D Printing
FDM, SLS, SLA, PolyJet, MJF technologies.
Compression Molding
Experience lower tooling costs with high-quality durable parts.
Urethane Casting
Production quality parts without the tooling investment.
Explore All Capabilities Explore all materials and finishes
Smart Manufacturing Platform See how our digital platform gives you instant quoting, auto DFM tools, global & domestic options, and complete order visibility.
Try the Platform - Solutions Solutions Prototyping Quality Management Production Tariff Management Teams Why Choose Fictiv? Assembly & Welding Got a Complex Program? Talk to Our Team
Scale Seamlessly Into Production Unlock global, flexible, high-quality manufacturing at scale– all with full supply chain visibility.
Start Production - Industries Industries Aerospace Consumer Products Automotive Medical Climate Tech Robotics Semiconductor eVTOL Got a Complex Program? Talk to Our Team
Case Studies Across A Variety Industries Browse engineering and production successes from aerospace, medical, automotive, and more — see how Fictiv powered them.
View All Case Studies - Resources Resource center
Help Center
Getting Started Getting a quote Placing an order Uploading and organizing parts Production and fulfillment Fictiv TeamsResource center
Articles Case Studies eBooks Podcasts Master Class Tools Teardowns Webinars FictivMadeFeatured Posts
Manufacturing Trends & Supply Chain Insights for 2025
Download 2025 Report
Complete DFM Guide for Production-Ready Parts
Learn Practical DFM
Injection Molding Design Guide (Free eBook PDF)
Download the Guide - Company Company
About Us
Learn about our company, leadership, and mission to transform manufacturing.
Learn more
Digital Platform
Accelerate development with instant quotes, expert DFM, and automated production updates.
Learn more
Global Network
Access a wide breadth of capabilities through our highly vetted network.
Learn more
People On The Ground
Our trained employees ensure your parts will be delivered on time and to spec.
Learn more
Shows and Events
Join us for an upcoming trade show or webinar.
Learn more
Press
Read the latest news about Fictiv and access our Press Kit
Learn more
Careers We're hiring!
Explore opportunities to join the Fictiv team!
Learn more
Contact Us
Our team is on stand by, waiting to assist you.
Learn more
Ready to get started?
Get an instant quote - Reviews
- Log In
Get Instant Quote
Toggle NavigationQuick Links
CNC Machining Injection Molding 3D Printing Urethane Casting- Capabilities
CNC Machining
Tight tolerances and finishing capabilities, as fast as 2 days.
Sheet Metal
Experience the versatility & cost efficiency with flexible application options.
Injection Molding
Production-grade steel tooling, as fast as weeks.
Die Casting
Create high quality custom mechanicals with precision and accuracy.
3D Printing
FDM, SLS, SLA, PolyJet, MJF technologies.
Compression Molding
Experience lower tooling costs with high-quality durable parts.
Urethane Casting
Production quality parts without the tooling investment.
Our Platform Our digital supply chain platform provides high-quality, scalable manufacturing solutions and is built to handle the full product lifecycle.
Learn more - Solutions
Prototyping
Production
Teams
Quality Management
Why Choose Fictiv?
Welding & Assembly
Manufacturing What's Next Join thousands of customers who trust Fictiv with their production programs.
Learn more - Industries Aerospace Consumer Products Automotive Medical Climate Tech Robotics Semiconductor eVTOL
Honeywell Case Study Learn how Honeywell drives 7x faster development with Fictiv.
Learn more - Resources
Help Center
Getting Started Getting a quote Placing an order Uploading and organizing parts Production and fulfillment Fictiv TeamsResource center
Articles Case Studies eBooks Podcasts Master Class Tools Teardowns Webinars FictivMade
2025 State of Manufacturing & Supply Chain Report
Download report
Nightside Success Story
Nightside's Journey from Prototype to Production
Read case study
Airvine Scientific Success Story
The manufacturing behind Airvine's wireless Ethernet backbones.
Read case study
Materials.AI
Powered by ChatGPT and the Fictiv database.
Ask Materials.AI - Company
About Us
Learn about our company, leadership, and mission to transform manufacturing.
Learn more
Digital Platform
Accelerate development with instant quotes, expert DFM, and automated production updates.
Learn more
Global Network
Access a wide breadth of capabilities through our highly vetted network.
Learn more
Teams
Coordinate custom part sourcing across projects, teams, and even your entire company.
Learn more
Shows and Events
Join us for an upcoming trade show or webinar.
Learn more
Press
Read the latest news about Fictiv and access our Press Kit
Learn more
Careers We're hiring!
Explore opportunities to join the Fictiv team!
Learn more
Contact Us
Our team is on stand by, waiting to assist you.
Learn more
SHARE
Resource Center Home / Articles / G-code Knowledge is Key to Mastering Any CNC Machinesearch
Topic
DFM Guides Material Guides Engineering Workflow Tips Mechanical Design Tips Industry Reports Supply Chain Optimization Fictiv Updates Fictiv Culturefilter by
Content type
▸
Master Class Articles Case Studies eBooks Teardowns Tools Webinars PodcastsRole
▸
Business Leadership Engineering ID Industrial Design Supply ChainIndustry
▸
Aerospace Automotive Climate Tech Consumer Products Medical Devices Robotics SemiconductorManufacturing Processes
▸
3D Printing Assembly CNC Machining Compression Molding Die Casting Injection Molding Post Processing Quality Control RTV Molding Sheet metal Urethane Casting ClearSubscribe to MechStack
for articles, videos, and puzzles for the mechanically inclined.
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
Thank you for subscribing!
Your Material Selection Assistant
Try Materials.AI and get help navigating the complex landscape of plastic and metal parts.
Try Materials.AiTessa Axsom
06.25.2021 Manufacturing Processes
Time to read: 6 min
M06? G54? S1000? Do those numbers mean anything to you? Knowing the most common commands in your G-code may not be at the top of your priority list, but it can go a long way in helping you understand what your machine is doing. CNC machines are really good at doing exactly what they’re told. It’s your job to make sure you’re telling it to do the right things — and it’s hard to communicate effectively with a machine if you can’t speak its language.
What is G-code?
G-code is the simple programming language for CNC machines. It consists of lines of code that are organized in blocks. Each block controls one CNC machining operation, such as a cutting operation with a specific tool. Each line in a block is labeled with the letter N and a number. These line numbers are generally only even numbers (N2, N4, N6, etc).

Since computers became smaller, cheaper to use, and more commonly available, G-code has been generated using CAM, or computer aided manufacturing. A CAM program accepts your 3D CAD model, tool selections, and some other information as inputs. It then optimizes the tools paths and spits out G-code to tell the CNC machine what to do. It’s possible to write G-code programs by hand (I did a short one in grad school!) but for complex machining operations requiring tens of thousands of lines of code, unless you’re a perfectionist masochist, you probably don’t want to.
Even if you aren’t manually writing the blocks of code, you can add comments to the lines of code, which can be useful to identify the operation for yourself. This isn’t necessarily practical if you have a long program, but can be a useful addition at the beginning of each program to track the project or version. To add a comment in the middle of a line between two commands, just use parentheses. For example:
G0 X8 (x-coordinate) Y13 (y-coordinate).
You can also add comments to the end of lines using a semicolon:
S100 F200; set speed and feed
Why is it important to know G-code?
If I know anything about engineers (and I definitely do, because I am one) it’s that we like to understand how things work. G-code is the language that tells a CNC machine what to do, so understanding that language is required to really understand how a CNC machine works.
Plus, If you ever need to talk to the programmer, operator, or machinist you’re working with, it’s good to know what you’re talking about. Similarly, when discussing an issue and they start talking about the CAM program, you won’t be bogged down trying to figure out what they’re saying.
And when you run into trouble working with a CNC machine, it’s useful to be able to check through the program to look for errors. Or, if the machine does something unexpected, you have a better chance of analyzing the issue correctly.
Finally, when you have a good understanding of how your CNC machine works, you can design your parts to be machined more efficiently. With fewer operations, setups, and tricky geometries, you can save both time and money.
What are the critical G-code commands?
Every G-code command is a letter/number combo, and there are 5 main letters used in the language. Each letter corresponds to a different type of action for the machine to execute. These are the letters you need to know::
- M: machine action codes
- G: motion codes
- F: feed control
- S: spindle speed
- T: tool operations
Each of these letters is paired with a number to create an actual command. Here’s a list of the most common and important commands:
M commands
M commands control the machine, doing things such as starting or stopping the spindle or initiating a tool change.
M00: program stop
M02: end of program
M03: spindle on, clockwise rotation
M04: spindle on, counter clockwise rotation
M05: spindle stop
M06: tool change
M08: flood coolant on
M09: flood coolant off
M30: end of program, rewind and reset modes
G commands
G commands prepare the machine to move in a certain way. They’re usually accompanied by coordinates so the machine knows where to move as well. There are also some G commands that are used at the beginning of the program as “safety” settings, to make sure the CNC machine is in the right mode.
Movement commands
G0: rapid motion
Rapid motion is used to move to new coordinates to begin cutting or to move back to the tool carousel for a tool change. This command is only used when the tool is NOT in contact with your part.
G01: controlled motion
This command is used for cutting operations, when a feed rate is also specified.
G02: clockwise motion
Clockwise motion is for curved paths. This mode requires the end coordinates as well as the distance to the center point of the arc in both the X and Y directions. The I command is the X distance to the center point, and the J command is the Y distance to the center point. The starting point of the arc is the position of the machine when G2 is initiated, so you may need to first move the machine to the correct starting position.
Example: G02 X10 Y7 I0 J-5
G03: counterclockwise motion
This command creates an arc between two points in the same way as G2, but in the counterclockwise direction.
Safety Commands
G17, G18, G19: working plane
G17 sets the x/y plane as the plane to be machined. G18 sets the z/x plane, and G19 sets the y/z plane.
G20/21: units
G20 sets the units to inches, and G21 sets the units to millimeters. This HAS to match your CAD model!
G28: home position
G28 sends the machine directly to its home position. The machine will go straight there (possibly running into your part along the way). Provide an intermediate point and you can ensure the machine doesn’t crash into anything on its way home. This point can be just one coordinate, such as Z0, or fully defined, such as X0 Y0 Z0.
G90/G91
These commands control the mode by which the machine interprets coordinates. G90 puts the CNC machine in absolute mode, meaning it will go to the position of X10 Y10, for example, from anywhere else. Conversely, G91 tells the machine to operate in incremental, or relative mode. This means that the machine will move 10 units along the x-axis and 10 units along the y-axis for the same X10 Y10 command.
T: Tool Operations
T specifies the tool number to change to, along with an M06 (tool change) command. When you set up the CNC machine, each tool is assigned a number.

S: Spindle Speed
This sets the spindle speed to the number directly following the S. For example, S500 means 500 revolutions per minute (in typical units).
F: Feed Rate
F controls how quickly the machine moves when implementing the G movement modes to the specified coordinates. The units here depend on what you set using G20 or G21.
Most of these commands are standardized and will work on any CNC machine that uses G-code. However, some machines have their own unique commands as well, so make sure you learn your CNC machine’s particular vocabulary!
While you may not be writing the CAM program yourself, it is useful to know what commands control your CNC machine. Remember, your Haas or DMG Mori machine will do exactly what you tell it to do! Knowing G-code ensures that you’re telling it to do the right things.
Tired of machining your own parts? Let Fictiv do it for you! Sign up and upload a part to see how fast we can deliver, or explore our CNC machining services.
Download the calculator
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
Download the worksheet
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
Thank you for downloading!
XSIGN UP FOR OUR NEWSLETTER
Subscribe for expert design and manufacturing tips delivered to your inbox
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
Thank you.
X20% OFF YOUR FIRST ORDER
When you subscribe for expert design and manufacturing tips delivered to your inbox.
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
Thank you.
Appreciate this Topic?
Subscribe to MechStack to get articles, videos, and puzzles for the mechanically inclined.
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
Thank you for subscribing!
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
YOU MIGHT ALSO BE INTERESTED IN
Energy Storage Systems (ESS): Types, Design Considerations, and Manufacturing Challenges
In today’s technology-driven world, global energy demand is higher than ever—and it continues to grow. From data centers and electric vehicles to electrified manufacturing and smart infrastructure, modern economies rely on a constant, reliable power supply. Energy Storage Systems (ESS) have emerged as critical enabling technologies that make this possible, supporting renewable energy integration, improving […]Learn More
Jetting Defects in Injection Molding: Causes, Identification, and Prevention
How important is it to reduce jetting? (No—we’re not talking about private planes and celebrities.) Anyone who works with injection molding knows how crucial it is to maintain dimensional tolerances. But even after all that hard work, parts can still be rejected if they look bad. Jetting defects can occur even with the most advanced […]Learn More
Also of Interest- The Best CAD & CAM Software for CNC
- CNC Machining: Macros, Subprograms, and...
- Getting Started with CNC Milling
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
Thank you for submitting, someone will reach out to you within 1-3 business days.
By signing up, you agree to our Terms of Use and Privacy Policy. We may use the info you submit to contact you and use data from third parties to personalize your experience.
Thank you for submitting your information. Your submission has been received, and we will get in touch with you shortly.
Từ khóa » G0 Cnc
-
CNC G Code: G0 Or G00
-
G0 G-code - Smoothieware
-
CNC G Codes
-
SUMMARY OF G-CODES - MachMotion
-
CNC Mill G-Code | G0, G1 - YouTube
-
G00 And G01 G-Codes: CNC Linear Motion - CNCCookbook
-
List Of Most Important G-code Commands - How To Mechatronics
-
G Codes - LinuxCNC
-
G0 Cancels Canned Cycles - CNC Training Centre
-
What Is G-Code? What Is M-Code? What Do They Mean In CNC ...
-
Get To Know Your CNC: How To Read G-Code - Make Magazine
-
G0 Z-100 Bad Idea G-Code CNC Machinist Operator Funny T-Shirt