Wednesday, September 17, 2025
HomeHow To3D Printer G-CODES - The newbie guide!

3D Printer G-CODES – The newbie guide!

What are the 3D Printer G CODES and why they are important ? Check this guide to learn the most useful commands, and also how to use it!
Please, keep in mind that this tutorial designed for Marlin / Repetier firmwares, it is not guaranteed to work with another firmware,3DPrinter g-code

What is a 3D Printer G-code?

G-code (a.k.a RS-274), which has many variants, is the common name for the most widely used numerical control (NC) programming language. It is used mainly in computer-aided manufacturing to control automated machine tools (like CNC’s and 3D printers). G-code is sometimes called G programming language

How to send  3D Printer g-codes to the printer?

In repetier host, you should first connect the printer, then go to Manual control and write the code on this box:
img1
then just press SEND.

In Simplify3D, you need to open the tools > Machine control Panel. in the control panel, choose Communication
gcode 2

Remember!, the letters should be in in CAPITAL, example: G1 X-1 Works | g1 x-1 may not work

What can a G-CODE do for me?

Using G-Code, you can set up scripts on your 3D printer, for example:

I want that my printer, before it start printing,

my bed to 110ºC
– heat my nozzle to 180ºC
– go home
– do auto-leveling
– heat the nozzle up to 230ºC
– move nozzle to the left corner, off the bed
– extrude 10mm of plastic (to clean the nozzle)
– start printing

How we do this? using some G-codes!!!

M140 S110 // this will heat the bed to 110 degrees
M104 S180 T0 // this will heat the nozzle to 180 degrees
G28 // Go home! (if you don’t define X, Y or Z, it will go home to all of them)
G29 // do the auto-leveling feature
G28 X // it will go home on the X axis again
G91 // This is needed to move the extruder!
G1 E10 F240 // This will extrude 10mm of plastic
G90 // This is needed to move the extruder!

Wow!, too much strange commands right? well, they are worthy to know!, and this is what i’m gonna show you!

On simplify 3D you can set those scripts here:
3D Printer G-CODES

On repetier you can set those scripts here:
gcodes

 

MOST USEFUL 3D PRINTER G-CODES
(and how to use them)

G0 and G1: Move

G0 = Rapid linear Move (this means it will go FASTER)
G1 = Linear Move (normal speed)

How to use?
G0 Xnnn Ynnn Znnn Ennn Fnnn Snnn
G1 Xnnn Ynnn Znnn Ennn Fnnn Snnn

What the hell is this italo?
Well, most of the commands accept multiple moves at time, this means that if you send this:
G1 X100 Y100 Z100 E10
The nozzle will move 100mm on X, 100mm on Y, 100mm on Z, while extruding 10mm of plastic.

But you can also move only one at time!, example:
G1 X10 = X axis will move 10mm

G2 & G3: Controlled Arc Move

G2 Xnnn Ynnn Innn Jnnn Ennn Fnnn (Clockwise Arc)
G3 Xnnn Ynnn Innn Jnnn Ennn Fnnn (Counter-Clockwise Arc)
Parameters
Xnnn The position to move to on the X axis
Ynnn The position to move to on the Y axis
Innn The point in X space from the current X position to maintain a constant distance from
Jnnn The point in Y space from the current Y position to maintain a constant distance from
Ennn The amount to extrude between the starting point and ending point
Fnnn The feedrate per minute of the move between the starting point and ending point (if supplied)
Examples
G2 X90.6 Y13.8 I5 J10 E22.4 (Move in a Clockwise arc from the current point to point (X=90.6,Y=13.8), with a center point at (X=current_X+5, Y=current_Y+10), extruding 22.4mm of material between starting and stopping)
G3 X90.6 Y13.8 I5 J10 E22.4 (Move in a Counter-Clockwise arc from the current point to point (X=90.6,Y=13.8), with a center point at (X=current_X+5, Y=current_Y+10), extruding 22.4mm of material between starting and stopping)
Why use it?

Why use 3D Printer G-CODESNotes

1In Marlin Firmware not implemented for DELTA and SCARA printers.

G4 Dwell (a.k.a delay or pause)

G4 Pnnn
Pnnn Time to wait, in milliseconds

Example
G4 P200
In this case sit still doing nothing for 200 milliseconds. During delays the state of the machine (for example the temperatures of its extruders) will still be preserved and controlled.

G10 and G11 – Retract and Unretract

If you send G10 (the hotend must be hot, otherwise it wont do nothing) will retract the filament. and when you send G11, it will unretract, this can be useful to stop oozing. but there are more effectives methods as proper calibration or cleaning scripts.  the distance can be set on the firmware or via software if you have EEPROM enabled

G28: Move to Origin (Home)

This command can be used without any additional parameters.
X Flag to go back to the X axis origin
Y Flag to go back to the Y axis origin
Z Flag to go back to the Z axis origin
Examples
G28 (Go to origin on all axes)
G28 X Z (Go to origin only on the X and Z axis)

G29: Detailed Z-Probe – (a.k.a auto leveling)

Example: G29
Probes the bed at 3 or more points. The printer must be homed with G28 before G29.

Please notice that for using this, you need to have a configured and working system!, check more in my another tutorial here: Click here to open the AutoLeveling tutorial

G90 and G91: Set to Absolute/Relative Positioning

Example: G90
All coordinates from now on are absolute relative to the origin of the machine. (This is the default.)

Example: G91
All coordinates from now on are relative to the last position.

G92: Set Position

This command can be used without any additional parameters.
Xnnn new X axis position
Ynnn new Y axis position
Znnn new Z axis position
Ennn new extruder position

Example

G92 X10 E90
Allows programming of absolute zero point, by resetting the current position to the values specified. This would set the machine’s X coordinate to 10, and the extrude coordinate to 90. No physical motion will occur.
A G92 without coordinates will reset all axes to zero.

Note that this can be dangerous!, if you are on X200, and your X-Max is 210mm, the printer will think that the hotend is at 0, and will let it to move more 200mm (200+200 = bad idea, and probably a lot of noise).

M92: Set axis_steps_per_unit
Xnnn Steps per unit for the X drive
Ynnn Steps per unit for the Y drive
Znnn Steps per unit for the Z drive
Ennn Steps per unit for the extruder drive(s)
Examples
M92 X87.489 Y87.489 Z87.489
M92 E420:420

Please note that you NEED to have eeprom enabled to save these values! (save sending M500)

M104: Set Extruder Temperature

Example
M104 S190
Snnn = Target temperature

M140: Set Bed Temperature (Fast)
Example
M140 S55
Snnn Target temperature
Set the temperature of the build bed to 55oC and return control to the host immediately (i.e. before that temperature has been reached by the bed). There is an optional R field that sets the bed standby temperature: M140 S65 R40. (it will wait until the temperature is 40ºc before it do anything).
NOTE: is better to use M116 commands!

M116: Wait for temperatures stabilize
M116
Wait for all temperatures and other slowly-changing variables to arrive at their set values if no parameters are specified. See also M109.

M112: Emergency Stop
Any moves in progress are immediately terminated, then RepRap shuts down. All motors and heaters are turned off. It can be started again by pressing the reset button on the master microcontroller.
You just need to send M112!
But be aware!, if you have a hardware problem is better to remove the printer from the power!

 

You can see a lot more G-code commands on the following PDF.

[CMDM-download id=1120]

RELATED ARTICLES

9 COMMENTS

  1. Thanks for posting this and the PDF link! I’m starting to remember a lot of it. Repetition will help with remembering codes when I get the 3D printer. But I will always have the sheet of codes “in hand” while making a project! Thanks!

  2. Came back to save the PDF for my laptop but it’s saying, “I have no permission to download this file”. I’m not logged into the 3DPrinterChat website so that may be why. But I re-read the article and it refreshed my brain! Thanks again for the great article!

  3. When I first saw this article, much of it was way over my head. I didn’t realize how helpful understanding some of the G codes would be. Having revisited this article several months later, I have a better appreciation for it. Thank you for the great article, and PDF.

  4. Hello, heres what some of us want to do ….Slicer Mode instead of saying how many feet of material …we need M3 to turn our extruder on at the start of each extrude and M5 at the end of each extrude nothing else…in other words M3..XY,XY,XY than M5 move to next position XY,XY,M3 ..XY,XY XY M5 ect no heated bed,no extruder temp check ect if you or any software person can please help…

Most Popular

Recent Comments

mperkins37 on 3D Printed Rockets
desitheblonde on New Low-Cost LSAM 3D Printer
Mad3DHatter on Flex3Drive Review
Salvatore_Lacorte on Guide to Successful ABS Printing
Jordi Lopez on 3D Printer Maintenance
Bill Nonnenmacher on 3D Printed Gears Easy!
Andy Marriott on Flex3Drive Review
Denny Hannaford on Creality Ender 3 Announced
Tom Baxter on 3D Printer Maintenance
Daniel Faegnell on How does 3D Printing work?
Tom Baxter on 3D Printer Maintenance
Tom Baxter on 3D Printer Maintenance
Henry Jolly on 3D Printer Maintenance
mperkins37 on 3D Printer Maintenance
Brian Martin on 3D Printer Maintenance
Melanie F. on DIY etching
Melissa Englebright on 3D Printer Maintenance
Kelly Freeman on 3D Printer Maintenance
Jeremy Fister on 3D Printer Maintenance
Ronan on DIY etching
mperkins37 on 3D Printer Maintenance
mperkins37 on 3D Printer Maintenance
mperkins37 on 3D Printer Maintenance
Leesa R McClure on 3D Printer Maintenance
Charles Goldman on 3D Printer Maintenance
Tom Baxter on 3D Printer Maintenance
mperkins37 on 3D Printer Maintenance
Carol Oddy on DIY etching
Tom Baxter on 3D Printer Maintenance
Michael Perkins on 3D Printer Maintenance
Michael Perkins on 3D Printer Maintenance
Michael Perkins on 3D Printer Maintenance
Richard Bynum on 3D Printer Maintenance
Richard Bynum on Slicers: Which one to use?
Brian Martin on Flexion Retrofit Kit Review
Carol Oddy on DIY etching
Richard Bynum on Flexion Retrofit Kit Review
Michael Perkins on Flexion Retrofit Kit Review
Richard Bynum on 3d printer Extruders
Michael Perkins on DIY etching
Richard Bynum on Rigid.ink Review
Justin K Jones on Wanhao D7 Review
Brian Martin on Creality Ender 3 Announced
Michael Perkins on Creality Ender 3 Announced
Richard Bynum on Autodesk to .STL
Chris Kockler on Creality Ender 3 Announced
Michael Perkins on MG Chemicals wood filament
Ronald Shropshire on MG Chemicals wood filament
Michael Perkins on MG Chemicals wood filament
Richard Bynum on 3D printed CNC Mill
Richard Bynum on 10 Fun Things to 3D Print
Justin Flugum on Creality Ender 3 Announced
Richard Bynum on Creality Ender 3 Announced
Justin Flugum on Creality Ender 3 Announced
David Griffith Rowe on Interesting 3D Printed Drone Projects
Richard Bynum on Wanhao D7 Review
Richard Bynum on ColorFabb Filament Review
Richard Bynum on Who is 3D-PT?
Richard Bynum on BuildTak – Is it Worth it?
Richard Bynum on Who’s 3D model is it?
Sumit Trivedi on MG Chemicals wood filament
Richard Bynum on CAD Review for 3D Printers
Asgor Reidaa on DIY etching
Asgor Reidaa on Wanhao D7 Review
Richard Bynum on MG Chemicals wood filament
Richard Bynum on 3d Print a Rubber band gun
Richard Bynum on 3d Print a Rubber band gun
Justin Flugum on Wanhao D7 Review
Tom Baxter on Wanhao D7 Review
Asgor Reidaa on 3d Print a Rubber band gun
Nathan Cox on Wanhao D7 Review
Nathan Cox on DIY etching
Tom Baxter on DIY etching
Richard Bynum on DIY etching
George Fomitchev on DIY etching
Richard Bynum on Wanhao D7 Review
Richard Bynum on Magnetic PLA Filament
Justin Flugum on Selfcad – A Short Review
Justin Flugum on Top 10 3D Printer Upgrades
Stan Baldwin on Vacuum Drying PLA Pt.1
Richard Bynum on 3D Printed Robots & Figures
Richard Bynum on Marlin a beginners guide
Richard Bynum on G-Codes – Wiki
Richard Bynum on How to NOT Be a 3DHubs Noob
Richard Bynum on 3D-Printing for Scuba Diving
Richard Bynum on Vacuum Drying PLA Pt.2
Asgor Reidaa on 3D Printing Dictionary
Richard Bynum on Vacuum Drying PLA Pt.1
Richard Bynum on What 3D-Printer to buy 2016
Richard Bynum on 3D Printing Homes
Madalyn Nguyen on 3D Printing Dictionary
Daniel Waldner on Prusa i3 MK3 – New Features
Richard Bynum on TOP 5 3D PRINTED CARS
Richard Bynum on 3D Printer safety tips
Annaloa Hilmarsdottir on The Anet A8 3D-Printer DIY Kit Review
David Robert Pemberton on 3D Printed Grenade Launcher
Justin Flugum on 3D Printer safety tips
Darren Scrubb on 3D Printing in the Classroom
Tom Baxter on 3D Printable Tools
Darren Scrubb on 3D Printing Homes
Darren Scrubb on 3D Printing Jewellery
Richard Bynum on Flex3Drive Review
Stan Baldwin on 3D Printed Grenade Launcher
Richard Bynum on Magigoo Adhesive Pen
Linda Beghtel on 3D Printing Jewellery
Richard Bynum on How much to Charge?
Justin Flugum on How much to Charge?
Jon Gardner on Big 3D Printers
Tom Baxter on 3D Printing Dictionary
Richard Bynum on 3D Print Wood Working Tools.
Richard Bynum on Sienci Labs Mill One
Lori Mahan on 3D Printing Jewellery
Tom Baxter on RIP Pinshape 2013-2016
Richard Bynum on 3D Printing Dictionary
Justin Flugum on 3D Printable Tools
B Michenfelder on Sienci Labs Mill One
John Smith on 3D Printing Jewellery
Richard Bynum on 3D Printed Gears Easy!
Stephen Shimatzki on The 3D Printing Gifts Guide 2018
Richard Bynum on Helpful Holiday Safety PSA.
Santiago Archilla on Making Money With 3D Printing
Braxten Brannon on 3D Printing in the Classroom
Stuart Hawton on 3D Print Wood Working Tools.
Richard Bynum on 3D Printing Jewellery
Tom Baxter on 3D Printing Jewellery
Stuart Hawton on 3D Printing Jewellery
Stuart Hawton on 3D Printing in the Classroom
Richard Bynum on 6 Taboos of 3D Printing
Dawn Mateo De Acusta on Holiday Gifts for Your 3D Printer
Todd Whetstone on Folgertech FT-5 R2 – Review
Todd Whetstone on Folgertech FT-5 R2 – Review
Richard Bynum on 3D Printing Filament Review
Sandi McGinnis on Folgertech FT-5 R2 – Review
Andreas Gasser on Folgertech FT-5 R2 – Review
Edward Dekkers on Folgertech FT-5 R2 – Review
Andrew Venkersammy on Holiday Gifts for Your 3D Printer
Braxten Brannon on 10 Hotends for your 3D printer
Jon Acosto (3DPrintnerd.com) on Calidum HALE Heated Bed – Review
Macario on Flex3Drive Review
Tom Baxter on Beer based Filament
Tom Baxter on Rick and Morty 3D Models
Richard Bynum on Rick and Morty 3D Models
Richard Bynum on Top 10 3D Printer Upgrades
eduardo martini on Prusa i3 MK3 – New Features
Richard Bynum on Random Models on Thingiverse
Richard Bynum on Random Models on Thingiverse
Michael Champlin on Random Models on Thingiverse
Richard Bynum on Random Models on Thingiverse
Michael Champlin on How to calibrate a 3D Printer
Michael Champlin on 3D Printer safety tips
Richard Bynum on Selfcad – A Short Review
Richard Bynum on Selfcad – A Short Review
Richard Bynum on The Ultimaker 2 3D Printer
Jared Heifetz on Top 5 3D Printers Under $300
Jared Heifetz on Top 5 3D Printers Under $300
Richard Bynum on Top 5 3D Printers Under $300
Jared Heifetz on 3D Printer safety tips
Richard Bynum on 3D Printer safety tips
Jared Heifetz on Magigoo Adhesive Pen
Jon Acosto (3DPrintnerd.com) on The 13 Phases of 3D Printing
Jared Heifetz on 3D Printable Tools
Richard Bynum on 3D Printable Tools
Jared Heifetz on 3D Printable Tools
David Klein on 3D Printable Tools
Richard Bynum on 3D Printable Tools
mperkins37 on 3D Printable Tools
Jared Heifetz on 3D Printable Tools
mperkins37 on 3D Printable Tools
Dewu Han on 3D Printable Tools
mperkins37 on 3D Printable Tools
Tania Alam on 3D Printable Tools
Jon Acosto (3DPrintnerd.com) on Advertising Your 3D Printing Business
mperkins37 on Sienci Labs Mill One
mperkins37 on Flex3Drive Review
Jeffrey M. Holliman on Flex3Drive Review
tpoage@mindspring.com on The Ultimaker 2 3D Printer
tpoage@mindspring.com on Snapmaker: The All-Metal 3D Printer
tpoage@mindspring.com on The best 3d print bed material
tpoage@mindspring.com on Snapmaker: The All-Metal 3D Printer
Stan Baldwin on 3D Printed Grenade Launcher
tpoage@mindspring.com on 3D Printed Grenade Launcher
tpoage@mindspring.com on A New Era in Desktop 3D Printing
tpoage@mindspring.com on Dynamo3D One Pro Unboxing & First Print
tpoage@mindspring.com on 3D Printed Guns as Illegal 3D File?
tpoage@mindspring.com on 3D Printed Guns as Illegal 3D File?
tpoage@mindspring.com on Get more from your cyclops scanners
tpoage@mindspring.com on 5 kits to get more from your 3D Printer
mperkins37 on TOP 5 3D PRINTED CARS
tpoage@mindspring.com on Top 10 3D Printer Upgrades
tpoage@mindspring.com on Media falsely attacks 3d printing again
tpoage@mindspring.com on 3D Printing Communities on Google+
tpoage@mindspring.com on 3D Print Wood Working Tools.
mperkins37 on TOP 5 3D PRINTED CARS
tpoage@mindspring.com on 3D Printing Market Trends For 2017
mperkins37 on TOP 5 3D PRINTED CARS
tpoage@mindspring.com on 3d Printing Brushless Motors and More
tpoage@mindspring.com on TOP 5 3D PRINTED CARS
jvastine on TOP 5 3D PRINTED CARS
mperkins37 on TOP 5 3D PRINTED CARS
tpoage@mindspring.com on 3D Printer manufacturers list 2020
tpoage@mindspring.com on How Strong is PLA? Lab Experiment!
tpoage@mindspring.com on Vacuum Drying PLA Pt.2
tpoage@mindspring.com on Top 6 Unique CAD Programs (2016-2017)
tpoage@mindspring.com on Finishing & Painting A 3D Printed Alien!
tpoage@mindspring.com on 10 Popular 3D Printing Fidget Patterns
tpoage@mindspring.com on Slicers: Which one to use?
tpoage@mindspring.com on Top 10 Large Format 3D Printers
tpoage@mindspring.com on 13 Best CAD Programs for Kids
tpoage@mindspring.com on 10 Places To Get Free 3D-Printing Files
tpoage@mindspring.com on Upgrading a Prusa i3
tpoage@mindspring.com on Top 7 3D Scanners on a Low Budget
tpoage@mindspring.com on 5 Fun Prints for your new 3d printer.
tpoage@mindspring.com on The Tantillus Part 1
tpoage@mindspring.com on What is Love? 3D Print Me (NSFW)
tpoage@mindspring.com on 3D Printing for the Second Cold War Pt.1
tpoage@mindspring.com on 5 Ways to Feed your 3D Printing Habit
tpoage@mindspring.com on Helpful Holiday Safety PSA.
tpoage@mindspring.com on 3D Printing a Quadcopter: Part 1
mperkins37 on Testing TinkerCAD Beta
tpoage@mindspring.com on Will your 3D-printer kill you?
mperkins37 on Testing TinkerCAD Beta
tpoage@mindspring.com on Big 3D Printers
mperkins37 on Testing TinkerCAD Beta
tpoage@mindspring.com on Testing TinkerCAD Beta
mperkins37 on Testing TinkerCAD Beta
tpoage@mindspring.com on Nanodax Glass Wool Polypropylene Review
tpoage@mindspring.com on Kanesis Hemp Bio Plastic PLA Review
tpoage@mindspring.com on Great 3D-Printers to look for 2016!
choschiba on 3D Printing Fidgets
tpoage@mindspring.com on Folgertech Kossel build Part 1
tpoage@mindspring.com on Build Plate Supported 3D Printing
tpoage@mindspring.com on Top 6 Unique CAD Programs (2016-2017)
tpoage@mindspring.com on Let’s move our prints to the cloud!
tpoage@mindspring.com on The Guardian of Techno phobia
tpoage@mindspring.com on 3D printing your own cosmetics with Mink
tpoage@mindspring.com on 3D Printing Fidgets
tpoage@mindspring.com on Folgertech Kossel build Part 1
tpoage@mindspring.com on Build Plate Supported 3D Printing
tpoage@mindspring.com on Ultimaker 3 – A Quick Review
Nick Kalogeropoulos on Why 3D Printing Must Alter Its Course
Andrew Werby on 3D Printing Homes
Andrew Werby on 3D Printing Homes
Nick Kalogeropoulos on 3D Printing in the Army: Here’s how
mperkins37 on 3D Printing Homes
mperkins37 on 3D Printing Homes
juggernath on 3D Printing Homes
mudface2003 on Upgrading a Prusa i3
Alexis Puentes on Five amazing DIY 3d printers.
lucpet on 3D Printing Piracy
Tony Davies on 10 Fun Things to 3D Print
Italo Soares on 3D Printed Gears Easy!
Frostbite on Vacuum Drying PLA Pt.1
3AM Productions on 3D printer after care Package
3AM Productions on RIP Pinshape 2013-2016
Italo Soares on About me: Italo Soares
Lays Rodrigues on Slicers: Which one to use?
Robbie Pearson on How To Use TinkerCAD
Robbie Pearson on Edit STL Files with TinkerCAD
Tony Davies on Marlin a beginners guide
3AM Productions on 3D PRINTED SEX TOYS
Alexis Puentes on Sintron Prusa i3 Review
Daniel F on Beer based Filament
Curtis J. Pratt on Beer based Filament
bioelectrobot on Beer based Filament
admin on Makergear M2