How To Edit G-Code In Cura: 3 Modification Steps For Beginners

When you want to change some details on your 3D printing model without changing the entire CAD file, applying changes from the G-Code is the next best thing. 

But what if you don’t have advanced computer knowledge, and don’t know where to start? 

If you’re using Cura, you might be in luck.

You can edit G-Code in Cura by accessing customizable elements. Alternatively, you can access G-Code files, download them as plain text files, make the necessary changes, and replace them in your software. Regardless of the method you choose, learning G-Code basics first is essential.

Can You Modify G-Code In Cura?

Editing G-Code in Cura is possible regardless of the Cura version you have. That’s because slicing software has been turning STL files into G-Codes since the dawn of 3D printing. 

In a simplified way, G-Code is the basic language that your 3D printing understands. You can give instructions to the machine through G-Code directly, but unless you’re a programming expert, designing your model in CAD software and then slicing it is more feasible. 

Once you prepare the STL file and upload it in Cura – or any other slicing software, as a matter of fact – the slicer takes it and turns it into G-Code through slicing.

This process is typically automatic. However, if you’re not happy with some details or want to make slight changes, you can do so by editing the G-Code directly in the slicer.

For instance, you might want to edit the G-Code to pause printing and change filament mid-print, if you want to print with different colors or materials. Or you might want to tweak settings like print speed or temperature to adjust default settings to a specific filament brand.

All this is possible directly from your slicing software.

Starting out with 3D printing and want to AVOID rookie MISTAKES? New: Filament Printing 101 Course
Starting out with 3D printing and want to AVOID rookie MISTAKES?
  • Our new Filament Printing 101 Course is just for you! Lean how to create perfect professional prints without all the hassle.
  • Don't let common mistakes hold you back, click the link to learn more and get ahead now!

How To Edit G-Code In Cura

There are two ways to edit G-Code in Cura, either from the software’s Custom Modes or by altering the generated G-Code files.

The steps below explain both methods, and also how to change the start and end G-Code scripts. 

1. Edit G-Code from Custom Modes 

Changing the G-Code from Custom Modes is the easiest way to edit G-Code in Cura for non-developers. 

Custom Modes are nothing but custom print settings that alter the G-Code automatically. You’re likely using them constantly without giving it a second thought – customizations include alterations of the Z offset, retraction, print temperature, and print speed, to name just a few. 

To change these settings: 

  1. Open Cura, upload your design, and slice it. 
  2. After the model is sliced, click on Extension in the menu and go to Post Processing. 
  3. Click on Modify G-Code. By selecting this option, the slicer opens a new pop-up window with various commands. Select Add a script. 
  4. When clicking on this button, Cura will display a drop-down menu with various selections. Options include Pause at height (used to stop extrusion mid-print), Display Filename and Layer on LCD, Filament Change, Speed Tower, and Retract Continue, to name just a few. 
  5. Select the setting you want to edit, input the new values, and save before exiting. 
See also  Marlin G-Code: The Ultimate Guide (2023)

For instance, if you want to perform a G-Code assisted change of filament mid-print, you can do so by selecting Filament Change from the drop-down menu mentioned earlier. 

In the new window, enter the layer number at which you want to change the filament and click Close. Slice the model again to reflect the G-Code changes, and start the printing process. 

When the printer reaches the input layer number, the altered G-Code stops the printing process and unloads the filament automatically. You can then proceed with loading the new filament and resuming the process. 

2. Alter G-Code Files  

Another way to edit the G-Code is by downloading the generated G-Code files, changing them manually, and then uploading them again in Cura.

This method is simple if you’re an experienced developer, but could be complex if you don’t understand the programming language.

While you can learn how to do it, keep in mind that any error in these files could result in bed or hot end overheating, the nozzle crashing into the bed or printed model, and other malfunctions that could destroy your model and damage your printer. 

To edit a G-Code file manually: 

  1. Click on the File menu in the top left corner.
  2. Choose Export from the drop-down menu. 
  3. From the new window, choose the G-Code files that you want to export.

G-Code files are usually plain text files that you can open and alter in Windows Notepad or a similar program. Each text line corresponds to a specific command, with the command code visible at the beginning of the line. 

To edit G-Code this way, you must learn the commands that you want to change and insert specific X, Y, and Z coordinates for each change. Read on to find the most common and useful G-Code commands that you can edit with this method.

After you’ve edited the G-Code, save the file and import it back into the slicer software.

3. Change Start and End G-Code Scripts

The last method for editing the G-Code in Cura allows you to change the start and end G-Code scripts. 

Start and end G-Code scripts are pre-set indications that your slicer and printer use when creating G-Code files. They define stuff such as build plate size, home axes position, hot end and bed temperature, etc. 

Default settings are generally pretty basic, and by tweaking these scripts you can add commands such as automatic bed leveling, alert noises, auto-part-removal sequences, printing a priming line to prime the extruder, etc. 

To edit the start and end G-Code scripts: 

  1. Click on the Settings tab in the main menu at the top of your Cura window. 
  2. From the drop-down menu, select Printers, then click on Manage Printers and select Machine Settings. 
  3. This option opens a new pop-up window with the start and end G-Code settings displayed in two boxes at the bottom of it. The Code displayed in these boxes is similar to code in .txt files, so you should be familiar with the commands before changing anything. 
  4. Edit the G-Code by altering the code manually or copy/pasting commands.
  5. Click on Close and exit the window when you’re done to save the new scripts. 

Important G-Codes For Better 3D Print Quality

Editing the G-Code can be troublesome if you’re not sure of what you’re doing.

See also  Cura Z Hop: Boosting Accuracy & Precision In 3D Printing

The most common commands that may come in handy include the following. 

M104 or M109: Temperature Settings

Two of the most important commands in 3D printing, M104 and M109 allow you to set the hot end temperature. The only difference between them is that the former instructs the printer to continue printing without waiting for the hot end to reach the input temperature.

M109, on the other hand, instructs the machine to pause printing until the new nozzle temperature is reached. 

G1: Print Speed

Formally called Linear Move in Marlin G-Code, the G1 command allows you to set the print speed and feed rate during extrusion movements. 

When changing these settings remember that measurement units are set to millimeters by default. You can change them to inches with the G20 command.

Letters such as F and E in the command line refer to feed rate and layer height. For instance, G1 X45 Y45 Z1 F1000 E1 tells the print head to move to the specified coordinates at a feed rate of 1,000mm/minute while extruding 1 mm of material.

G92: Set Current Position

This command allows you to change homing axes (0,0,0) from default to any position on the print bed. All you have to do is to insert the desired coordinates and save the command.

When the printer needs to home the print head, it will automatically take it to the new coordinates.

When setting these coordinates, remember that not all Marlin versions maintain the physical boundaries. If you’re using a version prior to Marlin 1.1.0 and insert the wrong coordinates, you might actually tell the printer to move the nozzle below the bed.

This will inevitably result in the nozzle crashing into the build plate, and you may end up with a damaged nozzle, damaged bed, or both. 

In Marlin 1.1.0 and higher, the firmware can recognize physical boundaries and won’t allow you to use this command to move the nozzle below the bed.

G02 or G03: Circular Interpolation

These commands add a circular arc movement in a clockwise (G02) or counterclockwise (G03) direction.

You can use these commands to print objects with a circular footprint, such as a vase or bowl, but also when printing miniatures that have rounded contours.

G29: Bed Leveling

One of the most important G-Code commands, G29 is responsible for bed leveling.

If you’re not completely new to 3D printing, you should already know that this is a crucial step at the beginning of each printing process, or your object might end up with a variety of defects. 

An important thing to know about this command is that it comprises five different systems. Each system determines the G29 to behave differently and comes with a different set of options. 

You can choose the desired system to level the bed automatically (four systems) or manually.

M106: Fan Control

Another essential setting in 3D printing is the fan control. Some filaments need the fan on full blast, others do better with no cooling at all, and you might even want to adjust cooling based on a specific filament brand or circumstances. 

Instead of setting the fan speed in Cura, you can alter the G-Code’s M106 command.

If the machine is idle, this command will turn on the fan and set it to the specified speed instantly. If the machine is printing, the change will be implemented when the next block is added to the planner. 

See also  Cura Z Offset: The Ultimate Tool For Accurate 3D Printing

Keep in mind that this command requires speed. If you leave it to zero, the G-Code will set the fan to full speed automatically. You’ll have to use the M107 command to turn the fan off. 

M84: Turn Off Machine Motors

M84 command is often neglected, but implementing it at the end of the cycle could help you prolong your machine’s lifespan and save on electricity.

This command simply turns off the printer at the end of the cycle, so you won’t have to keep an eye on it at all times.

Precautions And Tips For Successful G-Code Modification

Editing the G-Code can open up a world of 3D printing customizations and possibilities. However, there are a few things to keep in mind before proceeding. 

Know the Commands 

The first thing to learn before editing the G-Code is the type of commands you’re going to alter. 

G commands control movements and actions. You can use them to move the nozzle in a linear or arc movement, level the print bed, change the home position on the bed, adjust the Z offset, adjust or set the print speed and layer height, etc. 

However, these commands won’t give you overall control over the 3D printer. 

That’s what the M (machine) commands do. You can use M commands to start and stop the printing cycle, turn cooling on and off, adjust cooling, etc. 

Edit Code in Cura First 

If you’re new to G-Coding – or new to coding in general – start by editing these settings in Cura first, following the steps in method one (custom modes). 

The best thing about this setting is that you only have to input values instead of actually finding the right code and altering the right parameter in the line.

Save the Original G-Code File 

If you’re confident enough to export G-Code files and edit them directly, remember to save a copy of the original file before changing anything.

In this way, you can always restore the default settings if needed.

Double-Check Copied Commands 

Already written G-Code commands and parameters are readily available on forums and in other online communities. However, these codes are not necessarily written by experts.

If you copy/paste a command that contains errors, you might end up damaging your print or printer. For this reason, you should learn as much about G-Code as possible and always double-check the commands before using them.

Double-Check Before Printing 

Whether you’re using ready-made commands or have edited your own, always double-check everything before starting the printing process.

As explained, any error could result in your printer or object being damaged, and errors in coding can be frequent no matter how careful you are. Better to be safe than sorry.


Editing the G-Code in Cura is possible directly in the software or by downloading and editing G-Code files, then uploading them again into the program. 

No matter which method you choose, remember to learn the codes correctly and double-check everything before printing.

Recent Posts