Guide · 3D printing
3D Printer Start G-code Explained Line by Line (Marlin and Klipper)
What every line of a good start code does, the four mistakes that ruin first layers, and how to move the start sequence into a Klipper PRINT_START macro.
On this page
The start code runs before the first layer and decides whether the print starts well. Most problems with the first layer come from a start code copied from another printer.
A good Marlin start code
G21 ; millimetres
G90 ; absolute positions
M83 ; relative extrusion
M140 S{bed} ; start heating the bed
M104 S150 ; nozzle warm, but not oozing
G28 ; home all axes
M190 S{bed} ; wait for the bed
G29 ; probe the mesh (or M420 S1 to load a saved one)
M109 S{nozzle} ; wait for the nozzle
G92 E0
G1 Z0.3 F1200
G1 X5 Y20 F6000 ; prime line start
G1 Y120 E12 F1200 ; prime line
G1 X5.4 F6000
G1 Y20 E12 F1200
G92 E0Why this order
- Heat the bed first, the nozzle only to 150 °C: probing with a hot, oozing nozzle puts a blob under the probe point and changes the Z height.
- G28 before G29: the mesh needs a known position.
- Mesh after the bed is hot: beds bend when they heat.
- M109 before the first extrusion: M104 alone does not wait, and the extruder grinds or the firmware refuses with "cold extrusion prevented".
- G92 E0 after the prime line in absolute E mode; with M83 it is harmless and keeps the code portable.
The four classic mistakes
- M104 instead of M109, so the print starts cold.
- Moves outside the bed in the purge or park position of another printer.
- A mix of M82 in the start code and relative E in the slicer.
- G28 after G29 on Marlin builds where homing turns the mesh off, without M420 S1 afterwards.
Paste your start code into the 3D printer simulator: it reports all four.
The Klipper way: PRINT_START
In Klipper the slicer start code shrinks to one line, PRINT_START BED=60 EXTRUDER=210, and the sequence lives in a macro in printer.cfg. The macro can use the temperatures as variables, run an adaptive mesh only where the part is, and is the same for every slicer. A complete macro is in the program library.
More guides
- How Fast Can a 3D Printer Really Print? The Four Real Limits
- Engineering Filaments: PETG, ABS, ASA, Nylon, PC and Carbon Fibre Compared
- 3D Printed Fixtures and Soft Jaws for CNC Machining
- Fanuc Macro B Advanced: System Variables, Safe Macros and Real Shop Examples
- High-Speed Machining: Look-Ahead, Tolerance and Why Your Machine Never Reaches the Programmed Feed
- Trochoidal Milling Explained: Engagement Angle, Chip Thinning and When It Pays
Frequently asked questions
Should the prime line be long?
Long enough to fill the nozzle and to see that the flow is even, typically 100–200 mm. On textured plates a short blob also works.
Was this page helpful?