What Does the Language Look Like That CNC Machines Use?
The cnc machines language is G-code: short letter-number commands that tell a spindle where to move, how fast to spin, and when to change tools. This page breaks the code down piece by piece, shows where each piece stops being enough, and explains what that means for the tolerances and finishes you put on a drawing.

In this article
- 1
- 2
- 3
- 4
- 5
- 6
- 7
Five things worth knowing before you read further
G-code: the cnc machines language at its core
Every CNC machine, whether it is a 3-axis mill in a job shop or a 16-pallet 5-axis cell, runs on the same idea. A line of text tells the controller one thing to do. G01 X50.0 Y25.0 F800 means move in a straight line to that point at 800 mm/min. G02 adds an arc. M06 changes the tool. M03 starts the spindle clockwise. That is the whole grammar, repeated thousands of times per part.
The standard behind it is ISO 6983, often called G-code or RS-274. It dates back to paper tape readers, which is why the syntax is so terse. A letter addresses a register: G for preparatory function, M for miscellaneous function, X Y Z for linear axes, A B C for rotary axes, F for feed, S for spindle speed, T for tool number. Nothing is spelled out because every character once cost a row of punched holes.
Controllers are only loosely compatible. Fanuc, Siemens, Heidenhain, Mitsubishi and Haas all read the core G01/G02/G03 set, but canned cycles, macro calls and high-speed look-ahead differ. A post-processor that works for one brand will not post clean code for another. This is why a shop with mixed machines keeps multiple post configurations, and why sending a program between shops is rarely plug-and-play.
For a buyer, the practical point is this: the code is the last translation step between your CAD file and the metal. Tolerance, surface finish and cycle time are all decided in that translation. A ±0.005 mm callout does not survive a program that feeds a Ø6 mm end mill at 2,500 mm/min through 4140 steel.
- 1G01 / G02 / G03Linear, clockwise arc and counterclockwise arc moves. The workhorses of every program.
- 2F, S and T wordsFeed rate, spindle speed and tool selection. Set per operation, not per part.
- 3M-codesMachine actions: spindle on/off, coolant, tool change, program end.
- 4Work offsets G54–G59Define where the part sits relative to machine zero. Wrong offset, scrapped part.
CAM software and post-processors: how code gets written
Nobody hand-writes 40,000 lines for a contoured mold cavity. A CAM programmer imports the solid model, sets stock, picks tools, and generates toolpaths. The CAM engine works in its own internal representation: cutter location data, CL data for short. That is geometry only. The post-processor is what converts CL data into the dialect your specific controller understands.
The post is where most real-world problems live. A generic post will produce code that runs but wastes time, or worse, drives a tool into a fixture. A tuned post knows the machine's travel limits, its rapid retract plane, its spindle warm-up routine and its tool-change positions. At GreatLight we run 127 high-precision CNC machines across 3 wholly-owned plants, and each machine family has its own post. That is not bureaucracy. It is the difference between a 4,000 mm gantry part running clean and a crash.
Modern CAM also handles rest machining, adaptive clearing and toolpath smoothing. Adaptive or trochoidal paths keep radial engagement low, which lets you run higher feed rates without burning the tool. On 17-4PH stainless this can cut cycle time substantially compared with a conventional offset path, and it holds a more consistent Ra. The code looks strange to a human reader. It performs better.
One caution for engineers reviewing a quote: cycle-time estimates are only as good as the post and the tool library behind them. If a shop quotes a 3-hour cycle on a part that CAM says needs 5 hours, either they have a better process or they have not simulated the program. Ask which one.
- 1CL data vs G-codeCAM outputs geometry; the post converts it to machine-specific words.
- 2Post-processor tuningRapids, retracts, safe planes and tool-change positions set per machine.
- 3Adaptive clearingLow radial engagement, higher feed, longer tool life on hard alloys.
What changes when you add rotary axes
A 3-axis program moves X, Y and Z. A 5-axis program adds two rotary words, usually A and C or B and C, and can move them at the same time as the linear axes. That simultaneity is the whole point. It lets a ball nose cutter stay normal to a curved surface, which gives a better effective cutting speed and a more even scallop height.
The syntax itself does not grow much. The complexity moves into the CAM strategy and the post. A 5-axis post must solve the machine's kinematics, check that the tool holder does not hit the table or the trunnion, and manage singularity points where two rotary axes line up and the controller cannot decide which way to turn. Get that wrong and the machine makes an unpredictable move. In a 16-machine 5-axis department, we simulate every new program before it touches metal.
There is a second family of formats worth knowing. STEP-NC (ISO 14649) tries to describe features and operations rather than raw motion, so a controller could in theory decide its own toolpaths. It has been in development for decades and remains rare in production. APT, an older higher-level language, still appears in aerospace post chains. Neither replaces G-code at the spindle today.
The engineering meaning is simple. More axes in the code means fewer setups, tighter true position on angled features, and better surface finish on complex geometry. It also means programming time goes up and the cost of a mistake goes up with it. A part with a single datum and 20 angled holes is a 5-axis job. A flat bracket is not.
- 1Simultaneous 5-axisAll five axes move together. Required for contoured surfaces and undercuts.
- 23+2 positioningRotary axes index, then cut in 3 axes. Simpler code, still fewer setups.
- 3Singularity and collisionThe two failure modes a 5-axis post must catch before the run.
Where the code shows up on your part
Feed and speed are the two words with the most visible consequences. Push feed too high and the tool deflects, leaving chatter and a Ra that misses the callout. Push it too low and the tool rubs instead of cutting, which work-hardens stainless and burns the edge. The window is narrower on titanium and Inconel than on 6061 aluminium, which is why a shop's material experience matters more than its machine list.
Tool selection is encoded in the T words and the CAM tool library. A Ø12 mm end mill with a 4-flute geometry behaves differently from a 3-flute aluminum-specific cutter at the same feed. Chip evacuation changes, and so does the risk of recutting chips in a deep pocket. On a 4,000 mm part with deep pockets, the tool sequence in the program decides whether the job runs in one shift or three.
Offsets matter for tolerance. Work offsets set the part origin. Tool length offsets set the Z reference for each tool. Cutter compensation lets the operator adjust for tool wear without reprogramming. If a shop runs 100% inspection before shipment, as we do, the offset log is part of what the inspector checks against. A ±0.005 mm band leaves little room for a stale offset.
Surface finish callouts map to specific program decisions. Ra 1.6–3.2 μm is a normal as-machined result. Ra 0.8–1.6 μm usually needs a finishing pass with a smaller stepover. Ra 0.2–0.8 μm typically means a separate finishing strategy or a secondary operation. Telling your machinist the finish target in Ra, not in adjectives, is the fastest way to get a program that hits it.
- 1ChatterUsually feed or rigidity, not the code syntax. Check tool overhang first.
- 2Work hardeningToo low a feed on stainless or titanium. Raise feed, keep the tool cutting.
- 3Offset driftA worn tool with an unadjusted offset will walk out of a ±0.005 mm band.
What the cnc machines language cannot do
Code cannot fix a bad design. A 0.5 mm internal corner radius that needs a Ø0.5 mm cutter will run, but the tool will deflect and the finish will be poor. A deep, narrow slot will force a long-reach tool and the same problem. These are geometry issues that a better program cannot solve. A DFM review catches them before the program is written.
Code cannot create precision the machine does not have. A worn ballscrew or a spindle with runout will put error into every line, no matter how clean the G-code looks. That is why machine maintenance schedules and calibration records belong in a supplier audit. We hold ±0.005 mm on production parts, and that number depends on machine condition as much as on programming.
Code cannot inspect the part. A program can drive a probe and log the result, but it cannot decide whether a feature is functionally acceptable. That is a metrology question. We inspect 100% of parts before shipment and run raw material checks, in-process monitoring and final inspection, with reports available on request.
The honest summary: G-code is a precise but narrow instruction set. It controls motion and machine state. Everything above that layer, from material choice to fixture design to inspection strategy, is where the outcome is actually decided.
- 1Tool reachDeep pockets and small internal radii need long-reach tools, which deflect more.
- 2Machine conditionBacklash and runout show up in the part regardless of the program.
- 3InspectionProbing collects data. Judging acceptance is a separate step.
Which program format fits which job
Use this to decide what to ask for in a quote.
| Format | Typical use | When it is the right call |
|---|---|---|
| 3-axis G-code | Prismatic parts, plates, brackets | Flat features, one setup, simple datums |
| 3+2 G-code | Angled faces, multi-side parts | Several faces need machining in one setup |
| Simultaneous 5-axis | Contoured surfaces, impellers, medical | Curved geometry or undercuts need continuous motion |
| Mill-turn | Shafts, bushings, round-to-flat parts | Turning and milling on one part in one cycle |
| STEP-NC | Research and long-term standardization | Almost never in production today |
| APT | Legacy aerospace post chains | Only when a customer spec requires it |
The short version
If your part is prismatic and flat, ask for 3-axis and expect a lower cycle time. If it has contoured surfaces or features on many faces, ask for 5-axis and accept the higher programming effort. The code follows the geometry, not the other way around.
Questions engineers ask us about CNC code
Do I need to read G-code to work with a machine shop?
No. You need to know what your drawing asks for and what the shop can hold. The useful part is understanding that feed, speed and tool choice decide finish and tolerance.
The one thing worth learning is how finish callouts map to operations. Ra 0.8–1.6 μm is a different process from Ra 3.2 μm, and quoting them separately saves back-and-forth.
Why do two shops quote different cycle times for the same part?
Different posts, tool libraries and machine condition. A tuned post with adaptive clearing can cut cycle time on hard alloys compared with a conventional path. Machine rigidity affects how fast a shop can safely run without chatter.
Ask what toolpath strategy they plan and what spindle speed they will use. A vague answer usually means the estimate came from a rule of thumb.
Can you program from a STEP file alone?
Yes, if the model is watertight and the critical features are called out. We also accept native CAD files and 2D drawings with tolerances.
We return a free DFM analysis with the quote, usually within 12 hours, so geometry issues surface before programming starts.
What tolerance can a 5-axis program hold on an angled feature?
The rotary axes add their own positioning error, so an angled feature is harder to hold than a flat one. At GreatLight we hold ±0.005 mm on production parts when the setup and inspection plan support it.
If a feature is on a steep angle and the tolerance is tight, expect a conversation about datums and probing.
Does the programming language change for different materials?
The syntax does not. The numbers do. Feed, speed and depth of cut change a lot between 6061 aluminium and Inconel or Ti-6Al-4V.
That is why material experience matters more than the machine list when you pick a supplier.
How do you keep our design confidential during programming?
Uploads are secure and confidential, and we sign an NDA on request. Our information security management is certified to ISO 27001:2022.
Programs and models stay inside the project team. We do not reuse a customer's geometry for any other job.
Send us the drawing and we will tell you which process fits
Quotation and free DFM analysis within 12 hours. No minimum order quantity, from one prototype to 10,000+ part runs.
12-hour quote100% inspectionNDA on requestISO 9001 · IATF 16949 · ISO 13485