.gcode

What is a .gcode file?

G-code Toolpath · 3D model · MIT (numerical control) · 1958

A .gcode file is the instruction list a 3D printer or CNC machine follows: a plain-text sequence of movement and action commands. A slicer generates it from a 3D model for a specific machine.

Category
3D model
MIME type
Type
Plain text
Is a .gcode file safe to open? Caution with hardware. G-code drives a physical machine; running unverified code can crash a printer's head or overheat it. Preview it in a slicer before printing.

What is a .gcode file used for?

G-code is text, with each line a command like G1 X10 Y10 (move) or M104 (set temperature). It is tuned to one machine and one set of print settings, so a .gcode is not portable between different printers.

You do not model in G-code; a slicer such as Cura or PrusaSlicer produces it from an STL or 3MF. You can preview and tweak it in the slicer or a G-code viewer.

How to open a .gcode file

The .gcode format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .gcode file.

Windows

  • Cura
  • PrusaSlicer
  • any text editor

macOS

  • Cura
  • PrusaSlicer
  • any text editor

Linux

  • Cura
  • PrusaSlicer
  • any text editor

Web

  • Online G-code viewers

.gcode file signature (magic bytes)

Programs recognise a .gcode file by the bytes at the start of the file, not by its name. These are the signatures for G-code.

Hex signatureOffsetNote
(no fixed signature)0no reliable fixed signature

See the full magic-numbers reference for every format.

Frequently asked questions

What is a .gcode file?

A .gcode file is the instruction list a 3D printer or CNC machine follows: a plain-text sequence of movement and action commands. A slicer generates it from a 3D model for a specific machine.

How do I open a .gcode file?

Open it in your slicer (Cura, PrusaSlicer) to preview the toolpath, or in any text editor to read the commands. Send it to the printer to run it.

Can I edit a .gcode file?

Yes, it is text, but changes must match your machine and print. It is safer to change settings in the slicer and re-export than to hand-edit.

Why won't my .gcode print correctly on another printer?

G-code is generated for one specific printer and profile. Re-slice the original model for the new machine rather than reusing the old .gcode.

Related formats

Sources

Details on this page were checked against authoritative references: