Model
A mesh describes the shape and dimensions of the object.
● THE LANGUAGE OF 3D PRINTERS
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.
Each line becomes a precise physical action.
01 — THE BIG PICTURE
Your printer does not understand a 3D model directly. A slicer translates its geometry into a route the machine can follow.
A mesh describes the shape and dimensions of the object.
Software turns the shape into layers, paths, speeds, and temperatures.
N001 G28 ; home
N002 M109 S210
N003 G1 X80 Y20
N004 G1 E4.2 F900The printer reads the file line by line and executes each command.
02 — READ THE LANGUAGE
Most G-code lines begin with a command, followed by parameters. A semicolon starts a human-readable comment.
X and Y move across the bed; Z moves vertically. Values are usually millimeters.
E controls how much filament the extruder advances—or retracts during travel.
F sets motion speed in millimeters per minute. The setting persists until changed.
03 — MODAL 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 POSITIONINGG90
G1 X70 Y55Set absolute mode, then move to coordinate 70,55—no matter where the nozzle started.
G91RELATIVE POSITIONINGG91
G1 X70 Y55Set relative mode, then move 70 mm farther in X and 55 mm farther in Y from the current position.
M82 / M83M82 makes E absolute; M83 makes E relative. It is independent of G90/G91 on many common firmwares.
G20 / G21G21 selects millimeters, the normal choice for 3D printing. G20 selects inches.
G92 E0This resets the logical extruder position without physically moving the motor.
F1200After F is set, following moves reuse that speed until a later line changes it.
04 — INSIDE THE FILE
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.
Set coordinate and extrusion modes so every later number has a clear meaning.
G90 · M83Heat the bed and nozzle, then wait until both are stable.
M190 · M109Home the axes; on supported setups, probe or load the bed mesh.
G28 · G29Travel, extrude walls and infill, lift Z, then begin the next cross-section.
G0 · G1Turn off heaters, move the head away, and release the stepper motors.
M104 · M140 · M84A G1 line with increasing E deposits material while X, Y, or Z moves.
G1 X80 Y40 E0.62 F1200The nozzle changes location without laying plastic. Slicers optimize these to reduce time and stringing.
G0 X22 Y75 F7200The extruder briefly pulls filament back before travel, reducing ooze from the nozzle.
G1 E-0.8 F210005 — ESSENTIAL COMMANDS
G commands generally control motion and geometry. M commands handle machine functions such as heaters, fans, and motors.
G0 / G1Travel or extrude in a straight line
G28Find the printer’s X, Y, and Z origins
G90 / G91Use absolute or relative coordinates
G92Tell the printer where an axis is now
M104 / M109Set temperature / set and wait
M140 / M190Set bed temperature / set and wait
M106 / M107Turn the part-cooling fan on / off
M84Disable the stepper motors
i Exact behavior can differ between printer firmware. Check your machine’s documentation before editing a production file.
06 — PRACTICAL WORKFLOW
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.
Choose the matching printer profile, nozzle size, and material.
Look for unsupported islands, missing walls, and unexpected travel.
Confirm values are safe for your filament, hot end, and build plate.
Stay nearby. Stop the print if adhesion or motion looks wrong.