.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.

What opens 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.

Windows

  • Cura
  • PrusaSlicer
  • any text editor

macOS

  • Cura
  • PrusaSlicer
  • any text editor

Linux

  • Cura
  • PrusaSlicer
  • any text editor

Web

  • Online G-code viewers

Open a .gcode file step by step

  1. Confirm the file really is a .gcode. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with Cura or PrusaSlicer.
  3. On Mac, use Cura or PrusaSlicer.
  4. On Linux, try Cura or PrusaSlicer.
  5. Still stuck? Search for a dedicated G-code viewer rather than a generic one.

Why can't I open my .gcode file?

Almost always because no installed app understands G-code. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .gcode at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

G-code has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

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. How sources are ranked and what is deliberately left out is set out in the methodology.