What is the Gcode? Transforming your 3D models to the language of printers

Recent Articles

Blog Search



As we discussed in a previous blog post, STLs are the main files used in 3D printing . But, does our printer understand these files? The answer is no. The control systems used by our printers need specific movement instructions for motors and other elements. This is where the GCode language comes into play .

GCode comes from "Geometric Code" and is responsible for telling the 3D printer where to move and how much material to extrude in each step of 3D printing . If you have been in the world of 3D printing for a short time, you may not have seen these codes. The Slicing programs are automatically responsible for generating it without the user having to interact with it.

Even so, it is very important to know how this language works since it can be very useful when solving problems and to be able to do more advanced things with our 3D printers.

How the Gcode works

A Gcode line looks similar to this:

G1 X-5.3 Y-8.25 Z0.7 F3000.0 E0.0433

This particular code tells the 3D printer to move in a straight line up to the coordinates X -5.3 Y-8.25 Z 0.7 with a FeedRate of 3000 and that also extrudes 0.0433 along the way.

Let's see it in parts:

  • G1 : All Gcode lines start with a command. In this case G1. This is the Gcode command for a constant movement in a straight line.
  • X : From the command what comes are the parameters that indicate how the command has to be performed. In this case, it receives the X coordinate where the movement must end.
  • Y : Y coordinate where the movement should end.
  • Z : Z coordinate where the movement should end.
  • F : This parameter is the Feed Rate and indicates the speed of movement
  • E . This parameter indicates the amount of material that will be extruded by the 3D printer along the way.

All Gcodes that start with the letter G refer to movement actions. But as you'll be thinking right now, 3D printers do more than just move. That's why there are The Mcodes . Similar to the Gcode in their operation, they implement other orders for the 3D printer such as the M140 used to set the temperature of the hot bed or the M190 that makes the printer wait until it reaches a certain temperature.

The most important Gcodes

There are certain Gcodes that are the most used in 3D printing , in this section we will see them and explain them all.

G0 "Fast movement"

This command tells the 3D printer to move at the maximum allowed speed to specific coordinates . The execution of the G0 does not allow to extrude during the movement. It is normally used at the beginning of printing to bring the head to the starting point or during printing for movements that do not need to perform plastic extrusion.

G1 "Controlled movement"

With this Gcode we indicate to the 3D printer that it moves to a specific point, but we can also specify the speed at which the movement will be made and if we want it to extrude plastic along the way. It is the command that you will find the most if you look at a gcode before printing, since it is the one used during 3D printing itself.

G17, G18 and G19 "Select the planes of movement"

These Gcodes are used to indicate to the 3D printer on what plane the nozzle movement should perform.

G17 indicates the XY plane, G18 the ZX plane and G19 the YZ plane.

G28 "Ir al origen"

This is the command that is used to tell the 3D printer to bring the extrusion head to the home position , for most printers it is (0,0,0).

G90 "Absolute movement"

This command indicates that the subsequent movement commands received by our 3D printer will be referenced on the origin of this, as we have said before (0,0,0). This means that if we are in the X 5 coordinate and the next GCode is G0 X10 the printer head will move to X10.

G91 "Relative movement"

Unlike the previous one, this GCode indicates to the printer that it must move in relation to the current coordinates. Following the previous example, if we were in X 5 and after a G91 the next Gcode was G0 X10 the head this time would move to X 15.

Comments on the GCodes

As in any programming language, it is possible to insert comments in the Gcodes to indicate their meaning or whatever we want. For this it is necessary to insert the comment in the same line as the GCode using the ";" symbol.

The structure of a GCode for 3D printing

Now that we have seen how the Gcodes work , it is time to d ever as a valid file for 3D printing is composed .

The gcodes for 3D printing are divided into 3 parts: Preparation, printing and finishing.


Before starting to print, we need the 3D printer to perform certain tasks. These can be: heat the nozzle, heat the bed, go to the origin ...

A real example of this would be the following:

G90; Establishes absolute movement
M82; Establishes extrusion values ​​as absolute
M106 S0; Plug in the fan at a speed of 0
M140 S100; Sets the temperature of the hot bed to 100
M190 S100; Tells the printer to wait until the temperature of the bed has been reached


This is the phase where 3D printing takes place. It consists mainly of movements of the extruder in the XY plane while extruded material and movements in Z to change layer.

An example:

G1 X108.587 Y111.559 F525; Controlled movement in XY
G1 X108.553 Y111.504 F525; Controlled movement in XY
G1 Z0.345 F500; Change of layer
G1 X108.551 Y111.489 F525; Controlled movement in XY
G1 X108.532 Y111.472 F525; Controlled movement in XY


At the end of the printing we need to leave the printer ready for the following: This is: stop heating, pick up the motors, take the extruder to the origin ...

G28; Take the printer to the origin
M104 S0; Stop heating
M140 S0; Turn off the bed
M84; Shut down the engines

Bidirectional communication

So far we have seen how to send GCodes to our printer, but it is also possible that the printer sends information to us. This information is usually what we see on the screens of our 3D printer or on the control consoles.

The 3D printer can send 3 different states:

  • OK : if everything went well
  • RS : if you need a particular line to be sent again
  • !! : this indicates an error in the hardware. In this case the machine will automatically turn off and the printing will be canceled.

The information that we see on the screen, such as temperature or current coordinates, are sent using M commands such as M105 for temperature or M114 and 117 for coordinates.

If you want to see all the GCodes, you can consult them in the official wiki of the reprap project

We hope that this knowledge about GCodes will help you in the use of 3D printing . Soon we will bring you a more detailed article on how to correct problems using GCodes .

Greetings and see you printing

Join us on our social networks for more articles like this!


Leave a Comment

Cart 0 Shopping Cart

No products

Free shipping! Shipping
0,00 € Total

Check out