What is g code
Last updated: April 1, 2026
Key Facts
- Industry standard programming language for CNC machines, 3D printers, and other automated manufacturing equipment
- Uses commands starting with G (preparatory functions) and M (miscellaneous functions) to control machine movements and operations
- Created from CAD (computer-aided design) files using CAM (computer-aided manufacturing) software translates designs into machine instructions
- Defines precise coordinates, tool paths, feed rates, and spindle speeds to execute manufacturing tasks with high precision
- Variations exist between machine types and manufacturers, but core G-code language remains standardized across most equipment
What is G-Code?
G-code, short for geometric code, is a programming language that controls the movement and operations of computer numerically controlled (CNC) machines. These machines include mills, lathes, plasma cutters, laser cutters, routers, and 3D printers. G-code provides precise instructions for tool movements, cutting depths, feed rates, and other manufacturing operations, allowing machines to automatically produce parts with high accuracy and repeatability.
How G-Code Works
G-code programs consist of lines of text commands that the CNC machine reads and executes sequentially. Each line typically contains one or more commands with numerical parameters. The machine's controller interprets these commands and translates them into electrical signals that drive motors and control the tool. G commands control motion and positioning, while M commands control miscellaneous functions like spindle start/stop and coolant on/off.
Common G-Code Commands
- G00: Rapid positioning (move tool to location quickly)
- G01: Linear interpolation (move in straight line while cutting)
- G02/G03: Circular interpolation (cut circular arcs)
- G28: Return to home position
- M03/M04: Start spindle clockwise or counterclockwise
- M05: Stop spindle
- M08/M09: Turn coolant on or off
Creating G-Code
Manufacturing engineers and machinists typically create G-code using CAM (Computer-Aided Manufacturing) software rather than writing it manually. Engineers first design parts in CAD software, then use CAM software to generate tool paths and automatically convert designs into G-code. The software calculates optimal cutting patterns, tool speeds, and sequences. In some cases, especially for simple operations, programmers can write G-code directly by hand.
Precision and Applications
G-code enables machines to operate with extremely high precision, often to tolerances of thousandths of an inch. This makes it essential for aerospace, automotive, electronics, and medical device manufacturing where accuracy is critical. Complex parts that would be impossible or impractical to machine manually can be produced consistently and repeatedly using G-code programs. Modern 3D printers also use G-code variants to control layer height, nozzle temperature, and extrusion rates.
Variations and Standards
While G-code follows general standards established by ISO 6983, variations exist between different machine manufacturers and types. Some machines support extended commands or different interpretations of standard codes. CNC programmers must often adapt G-code programs to specific equipment, accounting for manufacturer-specific variations while maintaining the core program logic.
Related Questions
What is the difference between G-code and CAM software?
G-code is the actual machine programming language used to control CNC equipment, while CAM software is the tool that creates G-code from CAD designs. CAM software automates the complex process of converting 3D designs into machine-readable G-code instructions.
Can you write G-code manually?
Yes, G-code can be written manually for simple operations, and experienced programmers sometimes do for optimization or corrections. However, most G-code is generated automatically by CAM software for complex parts due to the time and expertise required to write it by hand.
Is G-code used for 3D printing?
Yes, 3D printers use G-code variants (or similar languages like Marlin) to control nozzle movement, extrusion rates, and temperature. Slicing software converts 3D models into G-code that instructs the printer how to build the object layer by layer.
More What Is in Daily Life
Also in Daily Life
More "What Is" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- Wikipedia - G-codeCC-BY-SA-4.0
- ISO 6983 - G-code StandardISO