PrusaSlicer start G-code (start gcode) is the block of printer commands that runs before the first layer: heat the bed and nozzle, home the axes, then purge. It is a text box in the printer profile, and it can use placeholders so temperatures follow your filament preset.
What is start G-code in PrusaSlicer?
Start G-code is a custom G-code field that PrusaSlicer pastes at the top of every file it exports, before any layer is printed. It is part of the printer profile, so one printer keeps one start routine and every filament preset reuses it. Typical contents are heating, homing, an optional leveling step and a purge line.
Prusa's knowledge base describes PrusaSlicer's custom G-code fields as accepting a macro language, so the text is not sent to the printer verbatim. Anything in curly braces is evaluated when you slice. For the basics of the language itself, see what G-code is, and for how the file gets out of the slicer, see exporting G-code in PrusaSlicer.
For a hotend temperature test in PrusaSlicer, see the PrusaSlicer temp tower guide, which builds one with M104 custom G-code.
Where do you find and edit the start G-code?
Open the Printer settings tab and look for the Custom G-code page, which holds Start G-code and related boxes such as the end and layer-change fields. If you cannot see the page, switch the mode toggle to Expert. Our own guide to PrusaSlicer filament and printer profiles shows how the Expert mode adds pages to a tab.
Prusa's help page on tab features explains that a system preset shows a lock icon, that a changed value turns the label orange, and that the Save icon stores your edit as a user preset. In practice that means you save your edited start G-code under a new printer preset name rather than overwriting a built-in profile. This is described from Prusa's documentation; we have not run PrusaSlicer for this article.
What does a basic start G-code look like?
A basic Marlin-style routine heats first, homes, then waits for temperature. This is an illustration built from the command definitions in Marlin's documentation, not a profile for any specific printer:
M140 S{first_layer_bed_temperature[0]}
M104 S{first_layer_temperature[0]}
G28
M190 S{first_layer_bed_temperature[0]}
M109 S{first_layer_temperature[0]}
Each line does one job:
- M140 sets the bed temperature and carries on without waiting.
- M104 sets the hotend temperature and carries on without waiting.
- G28 homes the axes so the firmware knows where the toolhead is.
- M190 sets the bed target and waits until it is reached.
- M109 sets the hotend target and waits until it is reached.
Starting both heaters first and waiting afterwards lets the bed and nozzle warm at the same time. Printer-specific steps such as a purge line, a probing routine or a firmware macro come after the waits, and the right commands differ per machine, so copy them from your maker's profile.
How do M190 and M109 differ from M140 and M104?
M140 and M104 set a target and return immediately, while M190 and M109 set a target and block until it is reached. Marlin's documentation says M190 "waits for the target temperature to be reached before proceeding", and that M140 sets the bed temperature and proceeds without waiting. M109 and M104 split the same way for the hotend.
The S parameter waits only while heating, and the R parameter waits whether heating or cooling, per Marlin's pages for both commands. Use S for a normal start, because the bed is usually below target. A start routine that never waits would begin extruding into a cold nozzle.
Which placeholders can you use in start G-code?
| Placeholder | What it gives you | Source |
|---|---|---|
{first_layer_temperature[0]} | First-layer nozzle temperature of the first extruder | Prusa macros page |
{first_layer_bed_temperature[0]} | First-layer bed temperature | Prusa macros page |
initial_extruder, initial_tool | Which extruder or tool is used first | Prusa placeholder list |
first_layer_print_min, first_layer_print_max | Bounding box of the first layer | Prusa placeholder list |
total_layer_count | Number of layers in the print | Prusa placeholder list |
num_objects | Number of objects on the plate | Prusa placeholder list |
Prusa's list also notes that every configuration option can be used in custom G-codes, so temperatures and other preset values are available by their option names. Curly braces mark the current macro syntax, and square brackets mark an older placeholder syntax whose contents are interpreted verbatim. Vector options such as temperature take an index, for example [0] for the first extruder. Prusa warns that its macro language is not compatible with the conditional expressions of Slic3r, so snippets copied from older Slic3r guides may fail.
Can start G-code change with the filament or extruder?
Yes, because the macro language supports conditions, which means one printer profile can serve several filaments. Prusa's macros page lists these building blocks:
- Conditional blocks in if/elsif/else and if/else/endif form.
- Operators: comparison, boolean logic, arithmetic, a ternary operator and regular expression matching with patterns between slashes.
- Functions for minimum, maximum, integer casting, rounding, padding and a check for whether a configuration option is active.
Four rules cause most errors. Vector options such as temperature, first_layer_temperature and bed_temperature must be indexed, for example first_layer_temperature[0]. Multidimensional vectors such as extruder_offset and bed_shape can be printed as text but not used in arithmetic. A ternary expression has to sit inside parentheses. And layer_z and layer_num only exist in layer-change G-code, so they will not work in the start box. Prusa also says strings are not parsed recursively, so brackets inside a string show up literally in the output. Always slice and read the top of the exported file after editing.
Can the start G-code call a Klipper macro?
Yes. Klipper's slicer documentation recommends a single line for slic3r-derived slicers such as PrusaSlicer, which hands the temperatures to a macro:
START_PRINT EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature]
Klipper's command templates page explains that values passed to a macro arrive through the params pseudo-variable, that parameter names are upper case, and that values are strings, so math needs a conversion. The macro itself lives in your Klipper config, and it does the heating, homing and purging. If you are new to that firmware, read what Klipper is first.
Klipper's documentation also warns that these slicers insert their own heating codes when certain conditions are not met, and suggests putting M140 S0 and M104 S0 before the macro call to prevent that. Check the exported file to confirm what your version does.
Klipper's slicer page adds a quality warning that applies to what you leave out of the start box: it advises against coasting, extra restart distance (Simplify3D), PreloadVE (KISSlicer) and advanced extruder pressure settings, because they can cause poor prints with Klipper, which has pressure advance instead. It also notes that large retractions may need max_extrude_only_velocity and max_extrude_only_accel tuned in the Klipper config. Klipper's example for Cura passes {material_print_temperature_layer_0} in braces, while PrusaSlicer and SuperSlicer use square brackets, so do not paste one slicer's line into the other.
Can you heat the bed faster with start G-code?
Prusa's macros page includes an example titled faster heat-up with weak bed heaters. It uses the start G-code to heat the bed to a target 5 degrees C below the first-layer value, then starts warming the hotend while the bed finishes. The idea is to avoid the hotend sitting hot and idle. Treat it as a technique for printers with slow bed heaters, and check your maker's guidance before changing temperature behavior.
What should you check if the first layer goes wrong?
If the first layer is poor after you edit the start G-code, undo the change before touching anything else. Common start-routine causes are a missing home, a purge line in the wrong place or a probing step that no longer runs. On printers with probing, see automatic bed leveling explained, and for symptoms use how to fix a bad first layer. Re-slice and read the top of the exported file to confirm the placeholders turned into numbers.
To see how filament choice shifts print time, try the print cost calculator.
Sources and method
This is a research page. The facts come from the Prusa Knowledge Base, Marlin's G-code pages and the Klipper documentation listed below. We did not print with any of these routines, and the sample start G-code is an illustration, not a tested profile.




