What Language Do CNC Machines Use?
Almost every CNC machine runs on G-code, a line-by-line instruction set that describes motion, feed, speed and tool changes. The interesting part is where that code comes from, and why the same part can behave differently on two machines. This page is for engineers and buyers who need to read a program, question a setup, or judge whether a shop really controls its process.

What language do CNC machines use: the short answer
Ask what language do cnc machines use and the honest answer is G-code. It is a text format defined by ISO 6983, and it is old enough that most of its letters were fixed before desktop computers existed. Each line is one instruction. G00 moves fast, G01 moves at a programmed feed, G02 and G03 cut arcs, M03 starts the spindle, M08 opens coolant.
What makes G-code readable is that it is not really a language in the software sense. There are no functions, no loops in the base standard, and no variables unless your controller adds them. It is a sequence of moves and switch flips, executed in order. A machinist can read a program on the screen and predict what the tool will do next.
That predictability is the point. A lathe manual from 1985 and a 2024 five-axis mill both expect the same G01 X Y Z F pattern. The commands survived because they describe the machine, not the part. Geometry lives in the coordinates. Strategy lives in the order of the blocks.
So when someone asks what language do cnc machines use, the accurate answer is G-code for motion, plus a controller-specific layer for everything else. That second layer is where most real-world differences hide.
How a block of G-code is built
A single line of G-code is called a block. A typical block reads N120 G01 X45.0 Y-12.5 Z-3.2 F250. The N number is a sequence label, useful when you search the program or restart after a tool break. G01 sets the mode. The X, Y and Z words are the target position in millimeters or inches, depending on G20 or G21.
F is feed rate in mm/min or in/min, and it stays active until you change it. That modal behavior is the core mechanic of G-code. G, M, F and S words persist across blocks; coordinate words do not. Understanding modality is what separates machinists who read code confidently from those who guess.
Spindle speed S is programmed in RPM for most mills and in surface speed for many lathes, where the controller then computes RPM from the current diameter. That difference matters on a turned part: as the tool moves toward center, the RPM must rise to hold cutting speed. A constant-RPM program will rub near the center, burnish the surface and wear the insert.
The controller also maintains offsets. G54 to G59 are work coordinate systems, and they are how the same program runs on a vise, a fixture or a fourth-axis tombstone without rewriting coordinates. Tool length offsets live in the offset table, not in the program. When a part comes out a fixed distance off on Z, the offset table is the first place to look, not the code.
Why the same G-code fails on another machine
ISO 6983 covers the common core. Fanuc, Siemens, Heidenhain, Mitsubishi and Haas each extend it, and the extensions do not always agree. A program with G43 H01 runs on Fanuc-style controls. Heidenhain conversational programming and Siemens ShopMill use a different syntax for the same idea.
Canned cycles are the usual trouble spot. G81 drilling, G83 deep-hole pecking and G84 tapping exist nearly everywhere, but the parameter order and the retract behavior differ. G83 on one control retracts fully between pecks; another offers a small retract as an option. On a deep hole in 17-4PH stainless, that difference changes chip evacuation and tool life.
High-speed look-ahead is another. G61 exact stop, G64 continuous path and G05 on some controls set how the machine blends corners. A program tuned for one controller can leave visible facets on a corner radius when moved to another, even though the geometry in the CAM file is identical.
This is why a shop does not simply move a proven program onto a new machine. Someone reprocesses it and cuts a test piece. The code is portable in principle. The behavior is not.
CAM, post-processors and macro languages
Nobody hand-writes five-axis toolpaths. CAM software takes a solid model, applies toolpath strategies, and simulates the cut. The output is a cutter location file, which is machine-neutral. A post-processor then translates that into the dialect of a specific machine, adding the correct G-codes, tool change format, and rotary axis conventions.
The post-processor is where accuracy is won or lost. On a simultaneous five-axis machine, the CAM system must account for the pivot distance between the rotary table center and the spindle, and for the tool tip position. Get that wrong and the part is scrapped with a perfectly valid-looking program.
Macros are the other layer. Fanuc macro B, Siemens R-parameters and Heidenhain Q-parameters let a program compute values, loop, and read from a probe. A probing macro measures a cast surface, updates the work offset, and starts the cut. That is not ISO 6983 any more. It is a small program running inside the control.
So the full stack is model to CAM to post to G-code to controller. When a shop says it controls its process, this chain is what it means. The G-code is the visible end. The decisions are upstream.
What this means for tolerance and inspection
Tolerance comes from the machine, the tool, the fixture and the thermal state, not from the code. A program that produces ±0.005 mm on a warm machine at 06:00 can drift by 0.02 mm after four hours of cutting aluminum. The code did not change. The spindle grew.
Feed and speed choices in the program decide surface finish and tool life more than any other single factor. Ra 0.8–1.6 μm is a normal target for a finishing pass with a sharp insert and a light radial engagement. Pushing feed to save time raises Ra quickly, and no amount of polishing fixes a torn surface.
Verification is where programming discipline pays off. Simulation catches collisions and over-travel, but it does not catch a wrong work offset, a loose vise, or a tool that is 0.03 mm under size. Those show up on the first article. This is why we inspect the first piece before running a batch, and why 100% inspection before shipment is a process step, not a slogan.
For prototypes, the practical rule is simple. Prove the setup on one part, measure it against the drawing, then release the run. A program that has never been cut is a hypothesis.
Common G-code and M-code words
Core words you will see in almost every program
| Word | Meaning | Typical use |
|---|---|---|
| G00 | Rapid positioning | Move clear of the part, no cutting |
| G01 | Linear interpolation | Feed move, F sets the rate |
| G02 / G03 | Circular interpolation | CW / CCW arcs, R or I J K |
| G17 / G18 / G19 | Plane selection | XY, XZ, YZ for arc and cutter comp |
| G20 / G21 | Inch / metric units | Set once at the top of the program |
| G54–G59 | Work coordinate systems | One per fixture position |
| G43 / G49 | Tool length comp on / off | Applied after each tool change |
| M03 / M05 | Spindle on / off | M03 S8000 starts at 8,000 rpm |
| M08 / M09 | Coolant on / off | Flood or through-tool, per material |
| M30 | Program end and reset | Returns to start, clears modal state |
When the language matters, and when it does not
If you are quoting a prototype, G-code dialect rarely matters: send a 3D model and let the shop post-process for its own machines. If you are transferring a proven program between plants, or debugging a part that came out off-size, the dialect, the offsets and the post-processor are the first things to check. Pick a supplier who can show you the post-processor output and the first-article report, not just a machine list.
Questions engineers ask next
Is G-code the only language a CNC machine understands?
For most mills, lathes and routers, yes. The control reads G-code and executes it directly. Some machines accept a conversational input layer, such as Heidenhain plain text or Siemens ShopMill, but the control still converts that into its own motion commands.
A few systems go further. STEP-NC (ISO 14649) aims to send feature-based instructions rather than moves, and some controllers accept macro or parametric programs that compute their own paths. In production shops today, G-code remains the common denominator.
Do all CNC machines use the same code?
The core is shared, the edges are not. G00, G01, G02 and G03 behave the same on every mainstream control. Canned cycles, probing macros, rotary axis conventions and corner blending behavior vary by builder and by model.
That is why a post-processor is machine-specific. The same CAM file posted for a Fanuc mill and a Heidenhain mill produces different text, and both are correct for their own machine.
Can I edit the G-code myself after the shop sends it?
You can, but coordinate edits are safer than mode edits. Changing an X or Z value shifts the cut. Changing a G43 or G54 line can move the entire part or crash the tool.
If a part needs a dimensional tweak, the cleaner route is to change the model or the CAM file and re-post. Editing the posted code works for a quick fix on a proven setup, not for a change you want to reproduce next month.
How does a five-axis machine know where the tool tip is?
The control uses the kinematic model of the machine, including rotary axis centers and pivot distances, plus tool length and tool radius data. The CAM system measures or receives the same values and uses them in the post-processor.
If any of those numbers are wrong, the part will be cut to the right shape in the wrong place. We verify the kinematic values and cut a test feature before running a five-axis job.
What file should I send for a CNC quote?
A STEP or IGES solid model, plus a 2D drawing with tolerances, material, finish and any critical dimensions marked. If you have a preferred stock size or a fixture constraint, say so.
For a quick quote, the model alone is often enough. We return a DFM analysis within 12 hours, and production can start within 24 hours once the drawing is settled.
Does the programming language affect the price?
Not directly. Price follows machining time, setup, material and inspection. Programming effort matters when a part needs many setups or complex five-axis work, because that adds engineering hours.
A simple part on a three-axis machine and the same part on a five-axis machine can carry very different prices even though both run G-code.
Send a model, get a DFM review and a quote
Upload your STEP file and drawing. We review the geometry, flag features that will be slow or risky to cut, and return a quotation with a free DFM analysis within 12 hours.
12-hour quote100% inspectionNo minimum order quantity