---
title: "Snapmaker 2.0 CNC G-code Guide: Reading What Luban Outputs"
description: "The Snapmaker 2.0 runs CNC G-code generated by Luban on Marlin-based firmware. Here is how to read it, the codes it uses, and how to verify before you cut."
url: https://gcodepractice.com/journal/snapmaker-2-0-cnc-g-code-guide/
canonical: https://gcodepractice.com/journal/snapmaker-2-0-cnc-g-code-guide/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-06-08
updated: 2026-06-08
category: "Guides"
tags: ["snapmaker", "hobby cnc", "g-code", "luban"]
lang: en
---

# Snapmaker 2.0 CNC G-code Guide: Reading What Luban Outputs

> **TL;DR** The Snapmaker 2.0 CNC module runs G-code that Luban generates on Marlin-based firmware, so it looks a little different from industrial Fanuc-style code but follows the same logic: set units and origin, start the spindle, move with G0 and G1, then stop. Read it in blocks, confirm the work origin and Z zero before cutting, and learn the common codes so you can verify the file rather than trust it blindly.

The Snapmaker 2.0 is a popular three-in-one machine that does 3D printing, laser engraving, and CNC carving, and the CNC side runs on G-code just like any other machine. What surprises people coming from industrial controls is that Snapmaker's code, generated by its Luban software, looks a little different. It is based on Marlin firmware, the same family that drives many 3D printers, so the dialect has its own conventions. Once you know those, reading a Snapmaker CNC program is straightforward, and reading it is what lets you catch a problem before it ruins a workpiece.

This guide explains how the Snapmaker makes G-code, what the code looks like, how to read a program in blocks, and the checks that matter before you cut. The goal is the same as on any machine: you do not have to write the code by hand, but you do need to read it well enough to verify it.

## How the Snapmaker makes G-code

On the Snapmaker, you usually design or import a model, then [Luban](https://www.snapmaker.com/), the official software, generates the toolpath and exports a G-code file the machine runs. You are not writing code by hand; the software writes it, and you load it. That is convenient, but it means the output reflects the settings you chose, so a wrong work origin or a wrong depth in Luban becomes a wrong move in the file. Reading the generated code is how you confirm those settings survived into the program.

Because the firmware is based on [Marlin](https://marlinfw.org/meta/gcode/), the code follows Marlin conventions rather than industrial Fanuc ones. The motion commands are the same standard [G-code](https://en.wikipedia.org/wiki/G-code) at heart, but some auxiliary commands and the overall style differ from what you would see on a Haas or a Fanuc lathe.

## What the code looks like

A Snapmaker CNC program uses a compact set of codes. Here are the ones you will see most.

| Code | Meaning | Notes |
| --- | --- | --- |
| G0 | Rapid move | Positioning without cutting |
| G1 | Feed move | Cutting move with an F feedrate |
| G2 / G3 | Clockwise / counterclockwise arc | Curved cuts |
| G90 / G91 | Absolute / incremental | Usually absolute |
| G21 | Millimeter units | Snapmaker works in millimeters |
| M3 / M5 | Spindle on / off | The CNC module spindle |
| M3 P (or S) | Spindle power or speed | Sets how hard the spindle runs |
| G28 | Move to origin | Homing or reference move |

Notice the codes are written G0 and G1 rather than G00 and G01, which is a Marlin style; they mean the same thing. The spindle control with M3 and M5 is familiar, though the way speed or power is specified can differ from industrial S-word usage, which is one of the Marlin-flavored details worth noting.

## Read a Snapmaker program in blocks

Like any G-code, a Snapmaker file reads best in blocks rather than line by line. The top sets up the job: units with G21, absolute mode with G90, and a move to a known position. The spindle starts with M3. Then the cutting section repeats G0 rapids to position and G1 feed moves to cut, following the toolpath Luban generated. At the end, the spindle stops with M5 and the tool retracts. If you read it as setup, cut, and finish, even a long file becomes a few repeating sections. Understanding [how the machine reads the code step by step](/journal/how-does-a-cnc-machine-read-code-step-by-step) makes this much clearer, because it shows why order and modal state matter.

The single most important thing to confirm is the work origin and the Z zero. On a small machine like the Snapmaker, where you set the origin and how you zero the Z height decide whether the tool cuts the material or cuts air above it. A reliable general reference such as the [LinuxCNC G-code list](https://linuxcnc.org/docs/html/gcode/g-code.html) helps you look up any standard code you do not recognize in the file.

## Snapmaker-specific things to check

A few details are particular to this machine and worth a deliberate check. First, the work origin: Luban lets you set where the program's zero sits on the stock, and it must match how you positioned and zeroed the machine, or the carve lands in the wrong place. Second, the Z zero: you typically set Z zero at the top of the material, and if it is set wrong the tool either plunges too deep or floats above the stock. Third, the spindle: the CNC module is a relatively small spindle, so feeds and depths from an aggressive industrial mindset will not suit it, and the Luban settings should reflect that.

These are setup checks, and reading the code is how you confirm them, since the file is the record of what Luban will actually tell the machine to do. Knowing the codes well enough to read that file is the same skill that matters whether you run a hobby machine or [verify output from professional CAM](/journal/do-i-need-to-know-g-code-if-i-use-mastercam).

## A sample program, read in plain language

To make the dialect concrete, here is how the opening of a typical Snapmaker carve reads, line by thought.

| Line | What it means |
| --- | --- |
| G90 | Absolute coordinates |
| G21 | Millimeter units |
| G0 Z5 | Rapid to a safe height above the stock |
| M3 P100 | Spindle on at full power |
| G0 X0 Y0 | Rapid to the start position |
| G1 Z-1 F300 | Feed down 1 mm into the material at 300 mm per minute |
| G1 X20 F600 | Cut a straight line in X at the cutting feed |
| G0 Z5 | Rapid retract to the safe height |
| M5 | Spindle off |

Notice the safe Z move happens before the spindle starts and again before any reposition, and the first cutting move is a controlled G1 with a feedrate. Reading those nine lines confirms the units, the safe approach, the spindle, and the first cut, which is most of what you need to verify.

## Setting the work origin and Z zero

The two settings that cause the most trouble on a Snapmaker are the work origin and the Z zero, so they deserve a deliberate routine. The work origin is where the program's X and Y zero sits on your stock, and you set it in Luban and match it on the machine by jogging to that point. The Z zero is the height the program treats as the top of the material, and you usually set it by touching the tool tip to the stock surface. If the Z zero is too high, the tool floats above the material and cuts air; if it is too low, it plunges into the bed or too deep into the stock. Getting into the habit of double-checking both before every job removes the single most common cause of ruined carves.

## Feeds, speeds, and the small spindle

The Snapmaker's CNC module is a compact spindle, not an industrial one, so the cutting parameters have to respect that. Aggressive feeds and deep cuts that suit a large mill will stall or break bits on a hobby machine. In practice that means lighter depths of cut, moderate feedrates, and patience with harder materials. Luban's default settings for a given material and bit are a reasonable starting point, and you adjust from there based on how the cut sounds and looks. Reading the F values in the generated program tells you what feedrates Luban chose, which is worth a glance before you run, especially if you changed settings. This is where a little [machinist math](/journal/cnc-machinist-math-cheat-sheet) helps, and a simple feeds-and-speeds reference pairs well with reading the code. A good habit is to compare the feedrate in the file against what you would expect for the material and bit, since a value that looks far too high or too low is a sign that a setting in Luban needs another look before you commit the stock to the cut.

## When the carve goes wrong

The most common beginner problem on any small CNC, including the Snapmaker, is the tool cutting air or plunging wrong, which almost always traces back to the origin, the Z zero, or the units. Because these are reading-and-setup issues rather than software faults, learning to read the program and confirm the setup prevents most of them. The dedicated guide on [why a CNC router cuts air](/journal/why-does-my-cnc-router-cut-air) walks through the specific causes and fixes, and they apply directly to the Snapmaker.

## The reading skill behind it all

Whether the code comes from Luban, Fusion, or anything else, the skill that keeps you in control is reading it. On the Snapmaker the dialect is Marlin-flavored, but the core codes, G0, G1, G2, G3, M3, and M5, are a small set you can learn to recognize instantly. When you can, you stop trusting the file blindly and start verifying it, which is what prevents wasted material and broken bits.

That recognition is recall, and short practice builds it. The free G-Code Sprint app at GCodePractice.com runs 60-second rounds on the common G and M codes and repeats whatever you miss, so the codes in your Snapmaker files become instantly readable. It is an educational practice tool for building that fluency, not a machine controller and not a replacement for Luban, so always set up and prove your carve carefully on the machine. Learn the codes, read every file in blocks, and the Snapmaker's CNC mode stops feeling like a black box.

## Frequently asked questions

### What G-code does the Snapmaker 2.0 use?

The Snapmaker 2.0 runs standard G-code generated by Luban on Marlin-based firmware, so motion uses G0 for rapids, G1 for feed moves, and G2 or G3 for arcs, with M3 and M5 controlling the spindle and G21 setting millimeter units. The style is Marlin-flavored, so codes appear as G0 and G1 rather than G00 and G01. To read those codes fluently, the free G-Code Sprint app at GCodePractice.com drills the common G and M codes in 60-second recall rounds.

### How do you read a Snapmaker CNC G-code file?

Read it in blocks: the top sets units and mode and starts the spindle with M3, the middle repeats G0 rapids and G1 cutting moves from the Luban toolpath, and the end stops the spindle with M5 and retracts. Confirm the work origin and Z zero before cutting, since those decide whether the tool cuts the material or air.

### Why does my Snapmaker carve in the wrong place or cut air?

Almost always the work origin, the Z zero, or the units are set wrong. The origin in Luban must match how you positioned and zeroed the machine, and Z zero is usually the top of the stock. Reading the program and confirming the setup prevents most of these problems.

### Does the Snapmaker use the same G-code as industrial machines?

The core motion codes are the same standard G-code, but the Snapmaker's Marlin-based firmware uses some different conventions and auxiliary commands compared to industrial Fanuc-style controls. The basics transfer, but read each file on its own terms.

### Do I need to know G-code to use the Snapmaker CNC?

You do not need to write it, because Luban generates it, but you should be able to read it to verify the origin, depth, and spindle settings before cutting. Reading-level fluency with a small set of codes is enough and prevents most wasted material.

### What is Luban for the Snapmaker?

Luban is Snapmaker's official software that generates the toolpath and exports the G-code file the machine runs for CNC carving, laser, and printing. It writes the code from your settings, so reading the output is how you confirm those settings are correct.

---

Source: https://gcodepractice.com/journal/snapmaker-2-0-cnc-g-code-guide/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
