G-code

Also known as: GCode, NC Code

intermediate File Formats

The programming language of instructions that tells the 3D printer how to move and extrude.

G-code is the language 3D printers understand. It’s a series of text commands that control every movement, temperature change, and extrusion. Slicers generate G-code from 3D models.

Common G-code Commands

Movement

  • G0 / G1 - Linear move (G0 travel, G1 print)
  • G28 - Home axes
  • G90 - Absolute positioning
  • G91 - Relative positioning

Temperature

  • M104 - Set hotend temp (no wait)
  • M109 - Set hotend temp (wait)
  • M140 - Set bed temp (no wait)
  • M190 - Set bed temp (wait)

Extrusion

  • M82 - Absolute extrusion
  • M83 - Relative extrusion
  • G92 E0 - Reset extruder position

Other

  • M106 - Fan on
  • M107 - Fan off
  • M84 - Disable motors
  • M25 - Pause print

Example

G28 ; Home all axes
M190 S60 ; Heat bed to 60, wait
M109 S200 ; Heat nozzle to 200, wait
G1 X50 Y50 F3000 ; Move to position
G1 Z0.2 ; Lower to first layer
G1 X100 E10 F1500 ; Extrude while moving

Editing G-code

You can open and edit G-code in any text editor. Common modifications:

  • Adjusting start/end scripts
  • Adding pause commands
  • Changing temperatures mid-print
  • Adding filament change points