THE LANGUAGE OF 3D PRINTERS

From digital
model to motion.

G-code is the set of plain-text instructions that tells a 3D printer where to move, how fast to go, and when to extrude plastic.

PRINTING LAYER 42 / 120
HEATED BUILD PLATE · 60°C
X
Y
Z

Each line becomes a precise physical action.

01 — THE BIG PICTURE

A print, in three stages.

Your printer does not understand a 3D model directly. A slicer translates its geometry into a route the machine can follow.

01.STL / .3MF

Model

A mesh describes the shape and dimensions of the object.

02TOOLPATH

Slice

Software turns the shape into layers, paths, speeds, and temperatures.

03.GCODE
N001 G28 ; home
N002 M109 S210
N003 G1 X80 Y20
N004 G1 E4.2 F900

Print

The printer reads the file line by line and executes each command.

02 — READ THE LANGUAGE

One line. Five instructions.

Most G-code lines begin with a command, followed by parameters. A semicolon starts a human-readable comment.

G1X50Y25E2.4F1200; draw perimeter
G1Move in a straight line
X50X-axis target, 50 mm
Y25Y-axis target, 25 mm
E2.4Extrude 2.4 mm of filament
F1200Feed rate, 1,200 mm/min

Coordinates

X and Y move across the bed; Z moves vertically. Values are usually millimeters.

Extrusion

E controls how much filament the extruder advances—or retracts during travel.

Feed rate

F sets motion speed in millimeters per minute. The setting persists until changed.

03 — MODAL STATE

Commands leave the printer in a state.

G-code is read like a running conversation. A mode stays active until another command changes it, so the same line can mean different motion in a different state.

G90ABSOLUTE POSITIONING

Every target is measured from origin.

G90
G1 X70 Y55

Set absolute mode, then move to coordinate 70,55—no matter where the nozzle started.

G91RELATIVE POSITIONING

Every target is measured from “here.”

G91
G1 X70 Y55

Set relative mode, then move 70 mm farther in X and 55 mm farther in Y from the current position.

M82 / M83

Extrusion has its own mode

M82 makes E absolute; M83 makes E relative. It is independent of G90/G91 on many common firmwares.

G20 / G21

Units are also state

G21 selects millimeters, the normal choice for 3D printing. G20 selects inches.

G92 E0

Position can be redefined

This resets the logical extruder position without physically moving the motor.

F1200

Feed rate persists

After F is set, following moves reuse that speed until a later line changes it.

04 — INSIDE THE FILE

A complete print is a careful sequence.

A real file may contain hundreds of thousands of lines, but its overall rhythm is simple: establish state, prepare the machine, repeat layers, then shut down safely.

  1. 01
    Prepare

    Choose the rules

    Set coordinate and extrusion modes so every later number has a clear meaning.

    G90 · M83
  2. 02
    Warm

    Reach temperature

    Heat the bed and nozzle, then wait until both are stable.

    M190 · M109
  3. 03
    Locate

    Find the machine

    Home the axes; on supported setups, probe or load the bed mesh.

    G28 · G29
  4. 04
    Build

    Repeat each layer

    Travel, extrude walls and infill, lift Z, then begin the next cross-section.

    G0 · G1
  5. 05
    Finish

    Cool and release

    Turn off heaters, move the head away, and release the stepper motors.

    M104 · M140 · M84
LIVE TOOLPATH · LAYER 42● RUNNING
Extrusion move Travel move Retraction
━━━━

Extrusion move

A G1 line with increasing E deposits material while X, Y, or Z moves.

G1 X80 Y40 E0.62 F1200
╌╌╌╌

Travel move

The nozzle changes location without laying plastic. Slicers optimize these to reduce time and stringing.

G0 X22 Y75 F7200
← E

Retraction

The extruder briefly pulls filament back before travel, reducing ooze from the nozzle.

G1 E-0.8 F2100

05 — ESSENTIAL COMMANDS

The ones you’ll meet first.

G commands generally control motion and geometry. M commands handle machine functions such as heaters, fans, and motors.

G0 / G1

Move

Travel or extrude in a straight line

G28

Home

Find the printer’s X, Y, and Z origins

G90 / G91

Position

Use absolute or relative coordinates

G92

Set position

Tell the printer where an axis is now

M104 / M109

Hot end

Set temperature / set and wait

M140 / M190

Bed

Set bed temperature / set and wait

M106 / M107

Fan

Turn the part-cooling fan on / off

M84

Release

Disable the stepper motors

i Exact behavior can differ between printer firmware. Check your machine’s documentation before editing a production file.

06 — PRACTICAL WORKFLOW

Before you press print.

Most people never need to write an entire G-code file by hand. Your slicer does the heavy lifting; understanding the output helps you diagnose problems and make careful changes.

  1. 01

    Slice for the correct machine

    Choose the matching printer profile, nozzle size, and material.

  2. 02

    Preview every layer

    Look for unsupported islands, missing walls, and unexpected travel.

  3. 03

    Check temperatures & limits

    Confirm values are safe for your filament, hot end, and build plate.

  4. 04

    Watch the first layer

    Stay nearby. Stop the print if adhesion or motion looks wrong.