Every print starts the same way unless you tell it otherwise, and that default behaviour is rarely ideal for your machine. Custom start and end G-code scripts are the two text blocks your slicer injects at the very top and bottom of every sliced file, and they decide whether your first layer adheres cleanly or your nozzle drags filament across a cold bed. Learn to edit them once and every job afterwards behaves the way you want.
Quick Answer
Custom start G-code lives in Printer Settings under Custom G-code in PrusaSlicer, or under Machine Settings in Cura. A solid start script homes all axes, heats the bed and nozzle in the right order, then runs a prime line to confirm flow before layer one. The end script lifts the nozzle, retracts a little filament, parks the head and switches off heaters and fans.
What the start script actually controls
The start block runs before the first extrusion move. Its job is sequencing: get the machine to a known state, get it hot, and prove the extruder is flowing. A common rookie error is heating the nozzle and bed at the same time, which wastes time and can ooze molten filament onto the plate while the bed is still climbing. Heat the bed first with a blocking command (M190), let it settle, then heat the nozzle with M109 so the printer waits for target temperature rather than charging ahead.
Order matters. Home the axes with G28 before any positioning move, set absolute or relative extrusion explicitly with M82 or M83 so you are not relying on a remembered state, and only then run your prime line. If you skip the wait-for-temperature step, the printer tries to push filament through a cold nozzle and simply grinds the gears.
If you are still choosing a machine to tinker with, the 3D printer range at Evetech covers entry FDM units through to larger-volume printers, and the firmware on most of them reads standard Marlin-style G-code, so these scripts transfer directly.
Writing a reliable prime line
The prime line is a short bead of filament drawn along one edge of the bed before printing begins. It clears any partial blob sitting in the nozzle from the last job and confirms the extruder is pushing plastic evenly. A typical routine moves the head to a corner, drops to roughly 0.3 mm above the plate, then extrudes a slow line across 100 mm or so while the nozzle travels.
Placeholders and brackets
Slicer variables let the script adapt to each profile. In PrusaSlicer, placeholder names sit inside square brackets, for example the bed and nozzle temperatures pulled from your filament profile. In Cura, the same idea uses curly braces. Using the placeholder instead of a hard-coded number means changing material in the slicer automatically updates the heat commands in your start script, so you are not editing G-code every time you swap from PLA to PETG.
Conditional logic
PrusaSlicer, descended from Slic3r, supports basic conditional generation with if, elsif, else and endif. That lets one script behave differently per filament, for example running a longer prime for stringy materials, without keeping separate printer profiles for each.
What the end script should do
The end block runs after the final layer. Retract a few millimetres of filament to stop oozing, lift the nozzle clear of the print with a relative Z move, then home or park the X and Y so the finished part is easy to reach. Switch off the heaters with M104 S0 and M140 S0, leave the part-cooling fan running briefly to set the last layer if you like, then disable steppers with M84. A good end script means you can walk away and come back to a cool, parked machine rather than a nozzle resting on your model.
Klipper macros versus slicer scripts
If you move to Klipper firmware, much of this logic shifts into printer-side macros (PRINT_START and PRINT_END) and your slicer script becomes a single line calling that macro with parameters. The advantage is that the heating and homing sequence lives on the printer, version-controlled in one config file, rather than copied across every slicer profile. For Marlin machines, the slicer scripts remain the right home for this logic.
Frequently Asked Questions
Where do I paste custom start G-code in PrusaSlicer?
Open Printer Settings, then Custom G-code. Paste your routine into the Start G-code box and your shutdown routine into the End G-code box. PrusaSlicer injects them into every exported file for that printer profile.
Why does my nozzle grind filament at the start of a print?
The script is trying to extrude before the nozzle reaches temperature. Use M109 rather than M104 for the nozzle so the printer waits for target heat, and place it before the prime line.
Should I heat the bed or the nozzle first?
Heat the bed first with a blocking M190, let it stabilise, then heat the nozzle. This avoids molten filament oozing onto the plate while the bed is still warming up.
Do Cura and PrusaSlicer use the same placeholder format?
No. PrusaSlicer wraps placeholder names in square brackets, while Cura uses curly braces. Copying a script between the two without converting the brackets will break the variable substitution.
What belongs in the end G-code script?
Retract filament, lift and park the nozzle, turn off the heaters and fan, and disable the stepper motors. The goal is a safe, cool, accessible machine when the job finishes.
If you are kitting out a bench for 3D printing, the accessories best sellers are a quick stop for the cables, tools and storage that make iterating on these scripts less of a hassle.
Ready to dial in your first machine? Browse the 3D printer range at Evetech and start writing scripts that make every print start and finish exactly the way you want.