Learn what G code is, how your CAD model becomes CNC machine instructions, and where good design fits into the process

A CNC machine does the cutting, but it needs instructions telling it where to go, how fast to move, and what to do when it gets there.

G code is part of the programming language used to control CNC machines. It translates a digital manufacturing plan into commands the machine can follow—from moving a cutting tool to a specific position to controlling how it travels through the material.

In most modern CNC workflows, G code is automatically generated from your CAD model. CAM software uses the model to create toolpaths, then translates those toolpaths into machine‑specific code.

The basic process looks like this:

CAD model → CAM toolpaths → G code → CNC machine → finished part

  • CAD model: Defines the part’s geometry and dimensions.
  • CAM toolpaths: Tell the cutting tool where and how to move to create that geometry.
  • G code: Converts those toolpaths into instructions the CNC machine can understand.
  • CNC machine: Follows the instructions to cut, drill, mill, or turn the material.
  • Finished part: The machined component is ready for action.

Even though CAM software generates the toolpaths and G code automatically, your design still determines how complex those toolpaths need to be. Understanding the process can help you avoid features that add machining time or specialised tooling.

For a comprehensive guide on optimising part designs for CNC machining, see our six practical ways to optimise CNC part design .

Press releases

What Is G Code?

G code is often used as a catch‑all term for the instructions that control a CNC machine. Technically, though, G commands handle motion‑related functions like tool movement, positioning, and coordinate systems, while M codes handle supporting functions like the spindle, coolant, and tool changes.

Together, these instructions tell the CNC machine how to turn the geometry in your CAD model into a physical part.

You usually will not create the G code directly from CAD. First, CAM software uses the part geometry and machining set‑up to calculate toolpaths. Next, a post processor converts those toolpaths into an NC program formatted for the specific machine control. CNC controls can use different variations of G code, so this machine‑specific translation is an important part of the process.

For a deeper look at how CNC machines interpret design data, see our guide to understanding CNC machining tolerances .

How Does G Code Work?

A CNC program is made up of lines, or blocks , of instructions. Each block tells the machine to perform one or a series of actions. The CNC controller reads those instructions and turns them into machine actions, coordinating axis movement, spindle operation, and other functions as the programme runs.

  • Tool movement: Coordinates such as X, Y, and Z tell the machine where to position the tool, while commands determine whether it travels in a straight line, follows an arc, or rapidly repositions between cuts.
  • Feed rate: The programme controls how quickly the tool moves through the material during cutting. The right rate depends on factors such as the material, tool, and type of operation.
  • Spindle speed: Instructions control how fast the spindle rotates and when it starts, stops, or changes direction.
  • Tool changes: When a part needs more than one cutting tool, the programme tells the machine when to switch tools and which one to use next.

For guidance on designing features that simplify toolpaths, see our CNC turning design guidelines .

Common G Code Commands

You do not need to memorise G code to design CNC machined parts, but understanding a few common commands can help with visualising how CNC programming controls the machining process.

CommandWhat It DoesIn Practice
G00Rapid positioningMoves the tool quickly between non‑cutting positions
G01Linear cutting movementMoves the tool in a straight line at a controlled feed rate
G02Clockwise circular movementCuts a clockwise arc or circular path
G03Counter‑clockwise circular movementCuts a counter‑clockwise arc or circular path
G17/G18/G19Select machining planeDefines the plane used for certain movements and operations
G20/G21Select unitsSets the programme to inches or millimetres
G54Select work coordinate systemEstablishes a reference point for locating the part
G90Absolute positioningMeasures coordinates from a fixed origin
G91Incremental positioningMeasures each movement from the current position

In practice, a line of CNC code might look like this: G01 X40 Y15 F250. Here, G01 is the G code command specifying a straight cutting move; X40 Y15 are the destination coordinates; and F250 sets the feed rate.

You may also see M codes , which control machine functions rather than tool movement. For example, M03 commonly starts the spindle clockwise, M05 stops it, and M06 commands a tool change.

The exact codes and behaviour can vary between machine controls, which is one reason CAM software and machine‑specific post processors are so useful.

The choice of machining strategy—whether 3‑axis, 5‑axis indexed, or continuous 5‑axis—has a direct impact on G code complexity. For an overview of these options, see our 3‑axis vs. 5‑axis machining comparison .

Finished parts in as fast as 4 days

Designing Parts That Are Easier to Machine

You may never touch the G code yourself, but your design still has a big impact on how the part gets machined. Every pocket, hole, wall, radius, and surface can affect the project’s budget and timeline.

That is where design for manufacturability (DFM) can help.

There are several ways to optimise part design for CNC machining so the resulting toolpaths—and the G code behind them—can be simpler and more efficient. In practice, that often comes down to a few design choices:

  • Keep features easy to reach: Tall walls and hard‑to‑reach surfaces may need longer tools, extra set‑ups, or more complicated tool movements.
  • Do not make features deeper than they need to be: Deep pockets and holes usually mean more cutting passes and can make chip removal and tool rigidity harder to manage.
  • Give internal corners some radius: Very small radii need smaller cutting tools, which often means slower machining and more passes.
  • Use tight tolerances selectively: Tighter requirements can mean slower finishing passes or extra set‑ups, so use them where fit and function justify the added precision.
  • Make set‑ups and tool changes easier to avoid: If several features can be machined from the same orientation, or with compatible tool sizes, the overall machining strategy can be simpler and faster.

Konlida’s automated DFM analysis reviews your uploaded CAD model and flags geometry that may be difficult to manufacture. That gives you a chance to optimise the design before machining starts.

For more on how DFM analysis works in practice, see our design validation with SOLIDWORKS guide .

When designing complex parts that require multiple setups, understanding how jigs and fixtures are used can help streamline the process. See our guide to jigs and fixtures for more.

Do You Need to Know G Code to Use CNC Machining?

No. Knowing the basics can help you understand how your design affects machining, but you do not need to write G code yourself.

With Konlida, you upload your 3D CAD model and receive automated DFM feedback on features that may be difficult to manufacture. From there, Konlida handles the CNC programming and machining.

So while knowing what G code does can make you a more manufacturing‑aware designer, your focus can stay on designing great parts. The rest is handled for you.

For more on material selection and how different materials affect machining strategies, see our 1018 vs. 4140 steel guide or our aluminium alloy comparison .

Production manufacturing 1

Summary

StageWhat HappensKey Consideration
CAD modelDefines part geometryDesign for manufacturability
CAM toolpathsCalculates tool movementsFeature accessibility, depth, radii
G codeConverts toolpaths to machine instructionsMachine‑specific post processing
CNC machineExecutes instructionsMaterial, tooling, feed rate, spindle speed
Finished partReady for useQuality inspection and documentation

Ready to Start Your CNC Machining Project?

Konlida handles everything from DFM feedback to G code generation—so you can focus on designing great parts.