G-code (Geometric Code) is the standard programming language for Computer Numerical Control (CNC) machines, providing precise instructions for tool movements, speeds, feeds, and operations. Developed in the 1950s, it remains the universal language for CNC mills, lathes, routers, plasma cutters, 3D printers, and more. This write-up covers its history, first use, an example program, modern generation via CAM software, widespread adoption, range from multimillion-dollar machines to hobbyist Arduino setups, open-source tools like LinuxCNC, and applications in industries and among hobbyists.
G-code originated in the late 1950s at MIT's Servomechanisms Laboratory as part of numerical control (NC) research funded by the U.S. Air Force for aerospace manufacturing. The first practical implementation was in 1952 on an experimental NC milling machine—a modified Cincinnati Hydro-Tel vertical mill controlled by punched paper tape. This machine demonstrated automated contouring for complex aircraft parts. The language was formalized in 1958 as RS-274 (later ISO 6983-1), initially called "G-code" for its preparatory commands (e.g., G00 for rapid move). By 1963, the Electronic Industries Alliance published RS-274-D, standardizing it across machines. Early programs were hand-written or generated by mainframes; G-code quickly became the industry standard for CNC systems.
G-code was first used in 1952 on MIT's prototype NC milling machine, a retrofitted Cincinnati Hydro-Tel. This 3-axis mill used punched tape for instructions, marking the birth of automated machining. By 1958, the Numericord (first commercial NC machine) adopted similar principles. G-code enabled precision manufacturing for aerospace, replacing manual operation and reducing errors.
Here's a simple G-code program for a CNC mill to cut a 10mm square pocket at 1mm depth, feed rate 100mm/min, starting at (X0 Y0 Z0):
N10 G90 G21 G17 ; Absolute positioning, millimeters, XY plane N20 G00 Z5 ; Rapid move to safe Z height N30 G00 X0 Y0 ; Rapid to start point N40 G01 Z-1 F100 ; Plunge to -1mm depth at feed 100mm/min N50 G01 X10 Y0 ; Cut to (10,0) N60 G01 X10 Y10 ; To (10,10) N70 G01 X0 Y10 ; To (0,10) N80 G01 X0 Y0 ; Back to (0,0) N90 G00 Z5 ; Retract to safe height N100 M30 ; End program
This program sets modes, moves rapidly to start, plunges the tool, cuts the square with linear moves (G01), retracts, and ends. It demonstrates core G-code elements: positioning (G00/G01), feed rate (F), and program control (M30).
Today, almost all G-code is generated by Computer-Aided Manufacturing (CAM) software from 3D CAD models, not written by hand. Tools like Autodesk Fusion 360, Mastercam, SolidWorks CAM, or free options (FreeCAD, Inkscape) simulate toolpaths, optimize feeds/speeds, and output machine-specific G-code via post-processors. This automation handles complex geometries, multi-axis operations, and collision avoidance, reducing errors and time. Even hobbyists rarely hand-code beyond simple tasks—CAM makes precision accessible.
G-code is the universal CNC language, used on over 90% of machines worldwide—from multimillion-dollar Mazak Integrex series ($500,000–$2M+) for aerospace to low-cost hobbyist setups. Mazak machines run advanced G-code with custom extensions (e.g., G61.1 high-accuracy mode). On the affordable end, Arduino-based CNCs (e.g., GRBL firmware on Uno with gShield, $50–$200) interpret G-code for routers, mills, and 3D printers. Open-source LinuxCNC (1993) powers custom builds like plasma cutters or robot arms on Linux PCs. G-code enables everything from industrial production to DIY projects.
LinuxCNC (formerly EMC2, started 1993) is a free, open-source CNC control software that interprets G-code for real-time machine control. It runs on Linux with a real-time kernel, supports mills, lathes, routers, and more, with a GUI for simulation and jogging. Hobbyists and small shops use it for custom machines, offering features like toolpath visualization and probing. LinuxCNC democratizes CNC by providing professional-level control without proprietary costs.
G-code powers manufacturing industries: aerospace (precision parts), automotive (molds/tools), electronics (PCBs), medical (implants/prosthetics), and woodworking (custom furniture). In hobbyist communities, it's used for 3D printers, laser cutters, CNC routers, and plasma tables—creating signs, models, and custom gadgets. Affordable Arduino/GRBL setups make G-code accessible to makers, while high-end Mazak machines handle complex production.
G-code remains the enduring language of CNC, bridging 1950s NC research to today's digital manufacturing. From hand-written tape programs to CAM-generated code on multimillion-dollar machines or hobbyist Arduinos, it enables precision across scales. Its simplicity and universality ensure it will power CNC for decades to come.