Generic selectors
Exact matches only
Search in title
Search in content

How to Work with the G-code. Everything you need to know

G-code examples and images for laser engraving and laser cutting

A detailed page about g-code commands, parameters, and settings.

Useful links and detailed instructions.


Endurance laser’s plugins

How to use an Endurance plugin for an Inkscape laser software (G-code add-on generator extenstion tool)


Endurance Line Shading Extension (plugin) for an Inkscape software


What commands to use when working with the Endurance laser

In order to make a contour image for engraving or cutting, we advise preparing the G-code in advance.
The properly made G-code will allow you to choose the optimal parameters for cutting or engraving.

There are 2 plug-ins that will allow you to prepare a high-quality G-code from the Inkscape program:
Endurance Laser G-code
J Tech Photonics Laser tool


Both plug-ins and the Inkscape program are available on the Endurance website (download center):

Download center: laser engraving programs, software tools, plugins & extensions, STL files. Everything you need for your laser module, laser cutting and laser engraving.


Some time ago we made a video demonstrating how to prepare an image for laser engraving and cutting using Inkscape
watch our YouTube channel

What is GCode?

The router understands a set of commands called GCode (Geometric Code, first developed in the late 1950s, that’s over 60 years ago!) which control the motion, speeds etc. of the spindle allowing accurate and repeatable machining. It is defined in multiple standards ( but nobody paid much notice to the standard other than as a basic core. Manufacturers of CNC (Computer Numerically Controlled) machines used the core concepts but developed their own extensions and implementations. So nowadays it is more like a set of guidelines ultimately dependant on the specific router it is implemented on, think of it as English with a lot of dialects and not all words have exactly the same meanings, not all meanings use the same words.

GCode is a series of instructions which tells the router Left a bit, go faster, right a bit, go down, go slower….. The best analogy I have is like the instructions a human brain sends to the hands when they are turning the knobs on a 3 dimensional Etch-a-Sketch!

When your CAM software takes a tool path it has generated and turns it into GCode it passes it through a post processor specific to which GCode dialect your Router understands. Some specifically allow you to select a post processor, others rely on settings in the machine configuration but the process is the same. Selecting the wrong post processor or machine will cause problems and errors when the GCode is sent to the router.

GCode File Format

It’s a text file, very simple, can be displayed and edited by any text editor, the file extension can vary from .nc, .txt, .tap, .gc, ….. while the file type may be different as it’s set by the software which creates the file and recognised by the software that is going to read it the contents of the files will always be the same.

But (there’s always a but!) there are lots of standards for text files; the most important is how the end of each line is marked. Different operating systems use a different format of text files. The most common formats are Unix/Mac and Windows format. The difference is that on Unix/Mac, it’s just a LF character (\n). On Windows, it’s a sequence of two characters, CR and LF (\r\n).

Grbl recognises both but as it receives the data from the GCode sender over a serial port, it doesn’t read the files directly, however your GCode Sender or Offline controller may only recognise a specific format.

All about the G-code and commands to be used


The commands are divided into two groups:
G – Preparatory (main) commands;
М – Auxiliary (technological) commands.


Proceed with a fast and secure checkout. Free DHL shipment worldwide. Get your laser in 3-5 days.


Parameters of these commands:

X – Coordinate of the trajectory point along the X axis [G0 X100 Y0 Z0]
Y – Coordinate of the trajectory point along the Y axis [G0 X0 Y100 Z0]
Z – Coordinate of the trajectory point along the X axis [G0 X0 Y0 Z100]
E – Coordinate of the plastic extrusion point [G1 E100 F100]
P – Command parameter [M300 S5000 P280]
S – Command parameter [G04 S15]
F – Command parameter, feed (speed) [G1 Y10 X10 F1000]
G – commands
G0 – Idle pass [G 0 X 10]
G1 – Coordinated movement along the X Y Z E axes [G 1 X 10]
G4 – Pause in seconds [G4 S15]
G28 – Home command – head parking [G28 Y0 X0 Z0]
G90 – Use of absolute coordinates [G90]
G91 – Use of relative coordinates [G91]
G92 – Setting of the present given position [G92]

Additional list of commands (checked for GRBL 0.9i)

  • G-code Name – description
  • G00 Fast positioning
  • G01 Linear interpolation
  • G02 Clockwise interpolation
  • G03 Counterclockwise interpolation
  • G04 Dwell
  • G10 Programmed data input
  • G17 XY surface selection
  • G18 ZX surface selection
  • G19 YZ surface selection
  • G20 Programming in inches
  • G21 Programming in mm
  • G28 Home position return (zero)
  • G30 Secondary home return (ref pt)
  • G40 Tool radius correction off
  • G43 Negative tool hight shift compensation
  • G49 Tool length correction compensation
  • G53 Device’s coordinate system
  • G54-G59 Work coordinate systems (WCS)
  • G61 Correct stop, modal
  • G80 Cancel completed cycle
  • G90 Absolute programming
  • G90 Fixed cycle for roughing (Z-axis accent)
  • G91 Incremental programming
  • G92 The position register from zero to the top of the tool
  • G92 Threading cycle, simple cycle
  • G94 Feed rate per minute
  • M00 Mandatory stop
  • M02 End of program
  • M03 Spindle on (clockwise rotation)
  • M04 Spindle off (counter-clockwise rotation)
  • M05 Spindle (laser) stop
  • M08 Cooling system
  • M09 Cooling off
  • M30 End of the program with a return to the top part of the program

How to work G-code?

If it’s not in the list above (taken from the Grbl 1.1 release notes) it will be unrecognised and an error will be returned from the router, these invalid command errors (error:1) can normally be safely ignored.


GCode can even be generated by hand as it was in its early days. For example

  • S100
  • M3
  • G91
  • G1 Z-0.1
  • G1 X10 Y10
  • G1 Z0.1
  • M5

Means Set the Spindle speed to 100RPM, Turn the spindle motor on in a clockwise direction (Or laser On), Use relative positioning – each movement specifies an offset from the LAST position, Move the bit 0.1mm towards the bed, Move the bit 10mm to the right and 10mm up as a linear move, move the bit away from the bed by 0.1mm, turn the spindle off.

But as nowadays we have these newfangled things called ‘Computers’ for anything other than the simplest of jobs, coding this by hand this would be exceedingly tedious, there is a reason computers were invented.

So practically to generate anything much more complex in a GCode file we need software. But that unfortunately creates its own set of problems. Commercial stuff is built for precision and speed and as GCode isn’t really a standard but a set of them manufacturers are relatively free to add features, interpret things in slightly different ways…. So the CAD/CAM software has to generate the GCode specifically with each specific machine in mind. Even in the hobby world there are differences, the easiest one is does your router have limit switches which allows it to set a machine position, is it mounting a spindle motor and bit or a laser, and how powerful is it?

There are lots of GCode tutorials out there so I am not going to even attempt to duplicate them, but beware of how machine specific they are, although the general principles will be the same.

I have found however that it is useful to have at least a basic understanding especially of positioning and coordinate systems to try and work out what has gone wrong. Don’t blame the router it’s a fairly dumb machine which tries to do exactly what it is told!

How to work with the G-code for the Endurance MakeBlock XY engraver

G00 // positioning
G04 P0 // pause, delay setting at 0.
M05 S0 // laser off
G90 G21 // step specifying in mm.

G00 X5 Y5 // positioning along X and Y.
G04 P0 // pause, delay setting at 0.
M03 S255 // laser turning on and max.power setting
G04 P0 // pause, delay setting at 0.

G01 X50 Y10 F1500 // laser head shift by 5 cm along X and by 1 cm along Y, speed setting at 1500
G04 P0 // pause, delay setting at 0.
M05 S0 // laser turning off

G04 P0 // pause, delay setting at 0.
M05 S0 // laser turning off
G00 // positioning

M02 // end of the program


Our YouTube video footages >>>
An Endurance laser lens pack. 4 different lens for your diode laser.


G-code examples

G-code samples, images suitable for laser cutting/engraving, and a video guide of how to prepare g-code.

Tested and ready g-codes for your engraving frame (GRBL 1.1H firmware). Good for Ortur, Eleksmaker, Neje, Atomstack, LE5040 Sainsmart (Genmitsu), Wainlux engraving (cutting machines)

Rubber stamp

download stamp files


DIY Chess

download chess files

G-code examples and images for laser engraving and laser cutting


All about GRBl: settings, parameters, variables. 

An important things you need to know about GRBL parameters, firmware settings



Useful links and materials about G-code


If you have any questions or concerns, please share them with us!


Stay updated with Endurance newsletter.
I have read and agree with the Endurance privacy policy

    Get a quote?

    Get an individual offer now... Just leave your contacts..


      Get a quote?

      Get an individual offer now... Just leave your contacts..