1 second by cncdivi

g code example g code file

So you’d like to play with a g-code file (the numerical control programming language used by cnc machines) but don’t have any sample g-code?

For starters, be sure to check out our Free G-Code Tutorial.  It’s full of examples on a case-by-case basis for all the common g code commands used by your machine tool.

Want completed programs?

No worries, here’s a bunch of example gcode files you can try on your cnc machine to gain a better understanding of g-codes.  Note that each specific machine may have its own dialect for g-codes.  Be sure to check the example program before you run it in earnest to make sure it’ll perform the right machining operations for your particular machine.



G-Code Examples for Milling Machines

boomerangv4.ncc: 3D profiling job on a boomerang.

Griffin Relief.ncc: 3D profiling job for a gryphon logo.

HomeSwitchRearPanelEngrave.NCC: A control panel for my CNC electronics.

SupportLogo.ncc: This g code file is a CNCCookbook logo for my tooling rack.

G-Code Macro Examples

Warm Up Program: This g code file runs your spindle and axes to warmup the CNC machine.

Circle Cutter:  Parameterized program to cut out a circle with optional drill in center.

Examples for Specific G-Codes and M-Codes

Our handy g-code reference lists have links to specific examples for all of the g-codes and m-codes.

Examples for 3D Printers

One thing you won’t find here are gcode files for 3D printers.  No print bed leveling, bed temperature, or other examples are available.  That’s because there are so many other resources for tracking down these other file formats needed by your 3D printer so you can get a perfect print.

How about a Free G-Code Viewer? Check this out:

Our g code editor is way better than a text editor for working with any gcode file.  Load up your file in G-Wizard Editor and it will explain what the g code commands do in plain English.  Since g code file formats are just text files, it can load any common file format.

Create your own Examples with Conversational Programming

conversational programming cnc software

With Conversational Programming, it’s easy to create your own examples…

Conversational Programming is a way to create simple g-code programs with CADCAM software.  You simply answer questions in a simple Wizard format and it will generate the g-code for the operation.  Our G-Wizard Editor Software has a free built-in Conversational Programming Module you can use to generate all sorts of examples.

More G-Code Resources


Do You Have Some Cool G-Code?

We’re always on the lookout for cool g-code files to add to this page.  If you have something you think is worthy, we’re interested.  If we wind up adding it to this page for download, we’ll give you a free lifetime copy of our G-Wizard Editor.

Here’s the sort of thing we’re looking for:

  • Quick fun projects someone could CNC in a weekend.
  • Useful g-code utilities such as subprograms that perform certain tasks that others may want to include in their own g-code.
  • G-Code that demonstrates some clever technique or a better experience others can learn from.
  • 3D Printer G-Code from slicing software.  I don’t yet have anything for a 3D Printer.

If you think you’ve got just the ticket, send me an email via bob@cnccookbook.com.  Include your g-code, tell me what sort of control it runs on, what it is, and briefly say why you think it should be added to our g-code page.  I’ll let you know quickly whether I’m going to add it and whether you get your free copy of G-Wizard Editor.




Where Can I Get Free G Code Files for 3d Printer?

The easiest way to get g-code files for 3D Printers is to use Slicer software on an STL file.


G-code files typically come from one of these sources:

  • CAM Software can produce g-code from a CAD model.
  • Conversational CNC can produce g-code when you answer a few simple questions in a Wizard-like format.
  • You can write g-code by hand, perhaps using a GCode Editor and Simulator to help.
  • You can download g-code files from sources like this article.

No, STL is a CAD file format.  It defines the geometry of the part you want to create.

G-code files are most commonly opened by Machine Controller Software, such as GRBL, or by NC Viewer Software such as our G-Wizard Editor.

For 3D Printers, you typically use Slicer Software to convert a 3D Model to G-Code.

For other CNC Machines, you typically use CAM Software to convert a 3D Model to G-Code.


Like what you read on CNCCookbook?

Join 100,000+ CNC'ers!  Get our latest blog posts delivered straight to your email inbox once a week for free. Plus, we’ll give you access to some great CNC reference materials including:

  • Our Big List of over 200 CNC Tips and Techniques
  • Our Free GCode Programming Basics Course
  • And more!

Just enter your name and email address below:

Full Name
Email *
100% Privacy: We will never Spam you!

4.4/5 - (24 votes)

Recently updated on April 27th, 2024 at 03:55 pm