3D printing & CAD · Intermediate

G-code

The line-by-line instructions a 3D printer or CNC machine follows

What is G-code?

G-code is the plain-text list of instructions a 3D printer or CNC machine follows, line by line. Each line tells the machine where to move, how fast, and what to do, such as heat the nozzle or push out plastic. A slicer writes it from your 3D model.

Think of it like this

Like turn-by-turn driving directions: go here, at this speed, then turn, with no view of the whole map, only the next instruction.

Where it fits in a 3D project

  1. Create
  2. Surface
  3. Rig
  4. Animate
  5. Render
  6. Export

Export: Saving and sharing the result: file formats, engines and printing.

How G-code works

  1. 01You load a 3D model into a slicer and choose print settings.
  2. 02The slicer cuts the model into layers and plans each nozzle path.
  3. 03It writes every move, speed and temperature as G-code lines.
  4. 04The printer reads the file line by line and builds the part.

G-code vs STL

PropertyG-codeSTL
DescribesHow to print the objectThe shape of the object
Made byA slicerA 3D or CAD app
Works onOne printer with its settingsAny printer, through a slicer

Keep and share the STL, since it works anywhere; G-code is a one-off output for a specific printer, material and set of settings.

Where G-code is used

  • Running FDM 3D printers
  • Controlling CNC mills, routers and laser cutters
  • Custom start routines, like heating and bed leveling

Beginner tip

Never print G-code sliced for someone else’s printer. Bed size, nozzle and temperatures are baked in, so reslice the original model with your own printer profile.

G-code FAQ

Can you edit G-code?
Yes. It is plain text, so any text editor opens it. People often change the start or end routine, adjust temperatures, or add a pause at a set layer. For bigger changes, reslicing is safer.
How is G-code made?
A slicer generates it automatically from a 3D model and your settings. You rarely write it by hand, though each line is readable, such as a move command with X, Y and Z positions and a speed.
Do resin printers use G-code?
Mostly not in the usual way. Resin printers usually read layer image files from their slicer, since they cure a whole layer at once. FDM printers and CNC machines are the main G-code users.

Updated October 29, 2026 · Browse all 3D terms