What G-code describes

G-code is a line-oriented instruction language used by 3D printers, CNC machines and related motion systems. A line can request movement, change a modal setting, set a temperature or update a controller-specific feature.

A command is rarely meaningful in isolation. Its result can depend on unit mode, coordinate mode, extrusion mode, the machine configuration and the firmware interpreting the file. This reference therefore documents both the common meaning and the context that can change it.

Key idea

G-code is better understood as a family of related dialects than as one perfectly uniform printer-file standard. Core motion syntax overlaps, while available commands, parameters, defaults and extensions depend on the target firmware and its configuration.

Read a command line

G1 X120 Y40 E1.6 F1800
G1

Requests a coordinated linear move.

X / Y

Provide the target position or distance, depending on G90/G91.

E

Provides an extruder position or distance, depending on M82/M83.

F

Sets the feed rate. Printer files normally express it in millimeters per minute, and later moves often continue using the last value.

; ...

Usually begins a comment for people or software. Slicers use comments to label layers and feature types, but those labels are not standardized.

A letter does not carry one context-free unit. X may be a coordinate, F a feed rate, while S can represent temperature, fan output or another setting. Interpret parameter words through the command that owns them.

A print file usually has three parts

Preparation

Sets units and positioning modes, starts heaters, homes axes, selects a tool, and may run leveling, cleaning or startup macros. This establishes how later values are interpreted.

Layered body

Large sequences of motion, extrusion, retraction, fan and temperature changes form the part. Layers and feature types are often marked by slicer comments rather than dedicated commands.

Shutdown

Turns off heaters and fans, lifts or parks the toolhead, releases motors, and may call a machine-specific end macro. A missing ending can leave the machine in a different post-job state.

; start: establish state
G21
G90
M83
G28

; body: travel, then print
G0 X40 Y20 Z0.20 F9000
G1 X80 Y20 E1.40 F1800

; end: stop active outputs
M104 S0
M140 S0
M107

This is a structural illustration, not a complete file to run on any machine. Homing direction, heating order, park position and macro names must match the specific printer.

Firmware context matters

Marlin, Klipper, RepRapFirmware and CNC controllers overlap on core motion commands, but they do not form one perfectly interchangeable language. The same machine goal may use different command names, parameters or value scales.

SystemExtension modelWhat to check
MarlinRepRap-style commandsMany features are compile-time options, so two builds of the same release may expose different commands.
KlipperStandard subset + named extensionsIt deliberately supports a common standard subset, adds names such as SET_PRESSURE_ADVANCE, and allows macros to add or override behavior.
RepRapFirmwareG-code everywhere + macros and expressionsConfiguration, control and status reporting make extensive use of G-code, with newer releases also supporting meta-commands and expressions.
LinuxCNC / RS274NGCCNC modal groups and coordinate systemsCNC concepts such as spindle control, tool compensation, work coordinates and canned cycles do not imply printer-style E-axis or heater behavior.

Firmware name, version and configuration are therefore the minimum compatibility context. A file extension—or a successful run on someone else’s machine—does not prove identical execution on your printer.

How to inspect an unfamiliar file

  • Identify the slicer, target machine and firmware. If that context is missing, treat compatibility as unknown.
  • Read units, axis mode, extrusion mode, homing, tool and heater setup before interpreting later moves.
  • Track X/Y/Z changes separately from E changes to distinguish travel, printing, retraction and priming.
  • Treat semicolon comments as slicer-provided clues, not commands the machine necessarily executes, and do not assume all slicers use the same labels.
  • For macros, named extensions or unfamiliar M-codes, check the official documentation for that firmware version instead of guessing from the number.
  • Finally, check that the ending handles heaters, fans and other outputs, and that parking moves cannot exceed limits or hit the part.

What each command page contains

  • A concise definition followed by the state required to interpret the command.
  • Syntax and parameter meanings, with practical G-code examples.
  • Firmware differences and mistakes that can change machine behavior.
  • A transparent statement of what the local viewer can and cannot verify.

What the viewer can show

Shows the file, not the printer

The viewer can show supported paths and selected file details. It cannot reproduce printer settings or predict exactly what a physical printer will do.

Start with these key commands

Official sources used for this guide

Reviewed on August 5, 2026 against the following primary sources. Together they explain the shared line structure and why controller dialects diverge.