127 Sets Processing 4000mm 127 Sets High-Precision CNC Lathes
15 Years of Experience

What is G code?

G-code is the secret magic behind all numerically controlled (CNC) machines, such as 3D printers, laser cutters, and, of course, CNC milling machines. It acts as a link between digital design and physical manufacturing, transforming those designs into precise instructions that machines can execute to bring them to life. In this article, Mohou.com will learn […]

what is g code?

G-code is the secret magic behind all numerically controlled (CNC) machines, such as 3D printers, laser cutters, and, of course, CNC milling machines. It acts as a link between digital design and physical manufacturing, transforming those designs into precise instructions that machines can execute to bring them to life.

In this article, Mohou.com will learn with youThe basics of G-code and how it works in different applications such as fused deposition modeling (FDM) 3D printing, resin-based 3D printing, and CNC milling. Additionally, we will explore some useful G-code skills, such as manually editing .gcode files, understanding their differences between machines, and how to adapt G-code to different firmware.

what isG-code?

What is G code

G-code allows us to communicate our designs to the CNC machine in a way it can understand (Source: AethericEye via Reddit)

G-code stands for “Geometry Code” and is a programming language used to control computer numerical control (CNC) machines.

You may be wondering why do we need a programming language for CNC machine tools?

If we want to useA CNC milling machine cuts a cube out of wood and it probably won’t take too much time to manually control the machine. However, if we want to cut 50 cubes (or something more complex), we can simply write a set of commands written in G-code, which will allow us to automate the control process and save a lot of time. This is why G-code plays a vital role in any modern CNC machine, including your 3D printer!

Computers originated inDeveloped in the 1950s as part of the automation revolution, it quickly became a mainstay for controlling machining tools such as lathes and mills, and later 3D printers and other manufacturing equipment. But what is it made of?

Basic Structure of G Code

G-code instructions consist of simple, friendly, easy-to-understand commands that tell the machine how to operate. Each line is called a “block” and represents an instruction or command, including:

1、order code (eg.G01、M104)

2、Parameters that specify coordinates or parameters (e.g.X10 Y20 position Z5 or feed F1500)

There are two types of commands in G code. One is “G” which controls the movement in the machine like G28 (zero on all axes). The other is “M”, which manages non-motion related functions such as temperature adjustment (M104) or tool change (M06).

Technical overview

1736407561 306 What is G code

Three-in-one 3D printing, laser engraving and CNC milling machine (Source: Aurora Tech via YouTube)

modeling of molten deposits(FDM) is a 3D printing method that builds objects layer by layer by extruding molten filaments. Even though it cannot print small details like a resin-based 3D printer, it remains a popular choice among hobbyists due to its simplicity and affordability. G-code is specific to each printer model and the print itself, since different printers have different sizes, movements (e.g. different movement systems), etc.

AndUnlike FDM 3D printers, CNC milling involves subtracting material from an existing part. Therefore, G code for CNC milling is not an instruction to add material deterministically, but is based on precise subtractive manufacturing practices.

resin based3D printing, such as stereolithography (SLA) and digital light processing (DLP), works differently than FDM 3D printing. The concept of FDM is based on extruding molten filaments through a nozzle, building an object layer by layer, like icing on a cake. Resin-based printing, on the other hand, uses a photosensitive resin that is cured (hardened) one layer at a time by exposing it to controlled light. To achieve this, the control system is primarily focused on the Z-axis movement and exposure settings, since there are no nozzles to extrude the filament.

AlthoughFDM 3D printers, CNC milling machines, and resin-based 3D printers all use G codes. However, due to the differences between these three printers, the specific controls and functions are also very different. Let’s learn more below.

1. In3D FDM printing

1736407561 869 What is G code

from a set of instructions toBenchy (Source: All3DP)

FDM 3D printing relies on G-code to manage tool head movement and precise extrusion control. Commonly used commands include:

movement and positioningG01 is used to control linear movement, specifying the X, Y and Z coordinates and the feed rate (speed of moving the tool holder) F. For example, G01 X50 Y25 Z0.3 F1200 moves the tool holder towards X=50 mm, Y=25 mm, Z=0.3 mm at a feed speed of 1,200 mm/min.

Extrude:The E parameter is used with G01 to extrude or retract the filament. For example, the G01 X60 Y25 E5 F1500 moves to Retraction can be performed using the G01 E-1 F1800, which retracts a 1mm filament at a feed rate of 1800mm/min.

Temperature settings:Controls such as M104 are used to adjust the nozzle temperature, while M140 is used to heat the bed. For example, the M104 S200 sets the nozzle temperature to 200°C and the M140 S60 sets the bed temperature to 60°C.

Fan control:M106 turns the fan on and adjusts its speed, M107 turns it off. For example: M106 S128 sets fan speed to 50% (S128, maximum is S255).

FDM-specific G-codes typically contain settings to manage print speed, shrink settings, and other print-specific operations such as pause (M0) or filament change (M600). Since FDM printers work by adding material to the build area, G-Code focuses on additive manufacturing methods.

2. InCNC milling

1736407561 94 What is G code

CNC milling machines “cut” the metal from objects (Source: CAD/CAM Solutions on YouTube)

As mentioned above, forIn CNC milling, movement is related to the removal of material from the workpiece. For example:

Toolpath control:Commands such as G17, G18 and G19 select the artboard. G17 sets the XY plane, G18 sets the XZ plane and G19 sets the YZ plane to ensure precise positioning of the cutting tool.

Feed and depth of cut:The F parameter specifies the feed rate, while the S parameter defines the spindle speed (the rotational speed of the cutting tool). For example, the F1000 sets the feed rate to 1000 mm/min and the S1200 spindle speed to 1200 rpm. These settings are essential for controlling cutting speed and depth.

Advanced operations:Commands such as G02 and G03 control circular interpolation. G02 specifies a clockwise arc, while G03 specifies a counterclockwise arc. Cutter compensation is handled by G41, which shifts the tool to the left of the cutting path, and by G42, which shifts the tool to the right, allowing precise adjustments to the tool size.

3. Resin-based3D printing

1736407562 54 What is G code

AndCompared to FDM, resin printers can print amazing details… (Source: DaveMakesStuffBC via Reddit)

we already knowWhat typical G-code operations for FDM printing look like. Resin printers typically use the following G codes:

Z axis movement: These should only be placed between layers alongThe Z axis moves the build platform, which simplifies the G-code structure compared to FDM since the X and Y axes are not required. For example, the G1 Z1.2 F150 moves the build platform at Z=1.2mm at 150mm/min.

Solidification of layers:The controls include various exposure time settings that control the time it takes for the resin to cure via UV light to create each layer. For example, there are different options for the initial layer and subsequent layers. For example,M106 S255 P10 activates UV for 10 seconds.

Stripping and lifting operations:Resin printers may containG-code controls to peel or lift between layers to reduce suction and prepare the next layer. For example, the G1 Z1.5 F100 slightly lifts the platform at Z=1.5 mm to peel off this layer.

As you can imagine,FDM’s G-code is generally more detailed because it contains temperature, extrusion, and motion controls on all three axes. On the other hand, G-code for resin 3D printing mainly includes Z-axis positioning controls and exposure settings. Since there is no filament extrusion, there are no controls related to extrusion or retraction.

4. Manufacturing method

1736407562 140 What is G code

Click the start and end boxes of the script to save your changes (Source:All 3DP)

If you’re wondering if you should learn everythingG-code commands are required to print or mill your model, so you don’t have to worry.

G-code for FDM and resin-based printing is generated by slicing software, where you import the model, specify 3D printing parameters, and convert (aka slice!) the process into G-code to your printer.

ForFor FDM, popular programs include Cura and PrusaSlicer, both of which are open source and support a large number of printers on the market. Resin printing uses its own slicer, such as the Chitubox and Lychee Slicer. As mentioned above, FDM printing has many parameters to consider, while resin-based 3D printing does not have as many parameters, but there are still a number of parameters to consider .

ForCNC milling machines and computer-aided machining (CAM) software can help prepare the appropriate G-code based on the design. Autodesk Fusion includes CAD and CAM capabilities, making it the first choice for CNC projects. As expected, there are plenty of other options, many of which are free.

That you wantPreparing G-code for a CNC machine or 3D printer can usually be done automatically using the software mentioned above. That said, learning how to manually edit G-code is a valuable skill. Let’s take a closer look.

5. Manual editingG-code

1736407562 689 What is G code

You can use any text editor that supports plain text to editCode G (Source: Shayon Khaled via All3DP)

As mentioned above, modifyG-coding is a useful skill. Indeed, it allows you to customize your printing or processing operations much further than slicing or CAM software allows you to do, and you can also adjust settings on the fly or troubleshoot any issues.

to modifyG-code is very simple, because generally any text editor that supports plain text can open .gcode files. You can use Notepad++, Visual Studio Code or any other text editor of your choice. However, if you want to do more than simple edits, it’s best to use a specialized G-code editor (such as Repetier-Host or PrusaSlicer). They provide useful features such as syntax highlighting and automatic error detection, so that complex edits can be made easily and securely.

After making changes, you also need to navigate through the viewerG code to ensure there are no errors. For example, a simple missing number in a tool head movement command could cause it to hit something and cause costly damage. Today, most slicers and CAM tools come with their own G-code viewer. If you want to use a separate viewer, OctoPrint’s G-code viewer or Repetier-Host are handy.

6. Why eachG code files are all unique

1736407563 127 What is G code

Although there are some similarities, the differences are significant (source:Jasper-CC via Reddit)

As mentioned above, eachEach G-code file is unique because it is customized based on the specific machine, materials and settings for which it was created. If you try to use it on a machine for which it is not designed, it may at least cause a malfunction – and at worst, it could damage the machine or the tool holder, requiring a costly and time-consuming repair.

The following concerns the differentSome common differences in G-code files created by FDM machines:

1Machine specific parameters:These often include unique settings such as build plate size, axis limits, and tool offsets, all of which can vary from model to model.

2Firmware differences:Different firmware (eg.Marlin, Klipper, GRBL) interpret and support various G-code commands differently (or not at all), thus affecting compatibility.

3、Hardware requirements:The G-code includes temperature and speed settings specific to the material used (e.g. PLA or ABS). Other materials may not work properly, or at all, due to improper configuration.

4Printer Features:Machines with features like dual extrusion or automatic bed leveling should haveDifferent commands are used in G-code.

WillAdapting G-code to another machine requires adjusting these settings to match the new configuration, and it is generally not worth the effort to manually edit the G-code file. If you want to print on another machine, an easier way is to recreate the G-code in slicing software and choose the right 3D printer or cut the model directly.

Daguang focuses on providing solutions such as precision CNC machining services (3-axis, 4-axis, 5-axis machining), CNC milling, 3D printing and rapid prototyping services.

CNC Experts

Picture of JinShui Chen

JinShui Chen

Rapid Prototyping & Rapid Manufacturing Expert

Specialize in CNC machining, 3D printing, urethane casting, rapid tooling, injection molding, metal casting, sheet metal and extrusion

CNC Recent Posts

CNC News

Welcome to GreatLight Metal,Maximum Processing Size 4,000 mm

Precision Machining CNC Quote Online

Loading file

Upload Click here to upload or drag and drop your model to the canvas.

The model is too large and has been resized to fit in the printer's build tray. [Hide]

The model is too large to fit in the printer's build tray. [Hide]

The model is too large, a fitting printer is selected. [Hide]

The model is too small and has been upscaled. [Hide]

Warning: The selected printer can not print in full color [Hide]

Warning: obj models with multiple meshes are not yet supported [Hide]

Warning: Unsupported DXF entity  [Hide]

Warning: could not arrange models [Hide]


File Unit:      
Scale:
%
L × W × H:
X: × Y: × Z:  cm 
Rotation:
X: ° Y: °  
⚡ Instant Quote for Precision Manufacturing

Submit your design files (STEP/IGES/DWG) and receive a competitive quote within 1 hour, backed by ISO 9001-certified quality assurance.

📋 How It Works

  1. Upload & SpecifyShare your 3D model and select materials (Aluminum/Stainless Steel/Titanium/PEEK), tolerances (±0.002mm), and surface treatments.

  2. AI-Powered AnalysisOur system calculates optimal machining strategy and cost based on 10+ years of automotive/aerospace data.

  3. Review & ConfirmGet a detailed breakdown including:
    - Volume pricing tiers (1-10,000+ units)
    - Lead time (3-7 days standard)
    - DFM feedback for cost optimization

Unit Price: 

Loading price
5 Axis CNC Machining Equipment
4 Axis CNC Machining Equipment
3 Axis CNC Machining Equipment
CNC Milling & Turning Equipment
Prototype and Short-Run Injection Moldings Exact plastic material as final design
Volume Metal Die Casting Services - Precision Cast Parts
Bridge the Gap From Prototype to Production – Global delivery in 10 days or less
Custom high-precision sheet metal prototypes and parts, as fast as 5 days.
Custom Online 3D Printing Services
Custom Online 3D Printing Services
Custom Online 3D Printing Services
Design Best Processing Method According To 3D Drawings
Alloys Aluminum 6061, 6061-T6 Aluminum 2024 Aluminum 5052 Aluminum 5083 Aluminum 6063 Aluminum 6082 Aluminum 7075, 7075-T6 Aluminum ADC12 (A380)
Alloys Brass C27400 Brass C28000 Brass C36000
Alloys Stainless Steel SUS201 Stainless Steel SUS303 Stainless Steel SUS 304 Stainless Steel SUS316 Stainless Steel SUS316L Stainless Steel SUS420 Stainless Steel SUS430 Stainless Steel SUS431 Stainless Steel SUS440C Stainless Steel SUS630/17-4PH Stainless Steel AISI 304
Inconel718
Carbon Fiber
Tool Steel
Mold Steel
Alloys Titanium Alloy TA1 Titanium Alloy TA2 Titanium Alloy TC4/Ti-6Al 4V
Alloys Steel 1018, 1020, 1025, 1045, 1215, 4130, 4140, 4340, 5140, A36 Die steel Alloy steel Chisel tool steel Spring steel High speed steel Cold rolled steel Bearing steel SPCC
Alloys Copper C101(T2) Copper C103(T1) Copper C103(TU2) Copper C110(TU0) Beryllium Copper
Alloys Magnesium Alloy AZ31B Magnesium Alloy AZ91D
Low Carbon Steel
Alloys Magnesium Alloy AZ31B Magnesium Alloy AZ91D
ABS Beige(Natural) ABS Black ABS Black Antistatic ABS Milky White ABS+PC Black ABS+PC White
PC Black PC Transparent PC White PC Yellowish White PC+GF30 Black
PMMA Black PMMA Transparent PMMA White
PA(Nylon) Blue PA6 (Nylon)+GF15 Black PA6 (Nylon)+GF30 Black PA66 (Nylon) Beige(Natural) PA66 (Nylon) Black
PE Black PE White
PEEK Beige(Natural) PEEK Black
PP Black PP White PP+GF30 Black
HDPE Black HDPE White
HIPS Board White
LDPE White
This is a finish of applying powdered paint to the components and then baking it in an oven, which results in a stronger, more wear- and corrosion-resistant layer that is more durable than traditional painting methods.
No coating required, product’s natural color!
This is a finish of applying powdered paint to the components and then baking it in an oven, which results in a stronger, more wear- and corrosion-resistant layer that is more durable than traditional painting methods.
This finishing option with the shortest turnaround time. Parts have visible tool marks and potentially sharp edges and burrs, which can be removed upon request.
Sand blasting uses pressurized sand or other media to clean and texture the surface, creating a uniform, matte finish.
Polishing is the process of creating a smooth and shiny surface by rubbing it or by applying a chemical treatmen
A brushed finish creates a unidirectional satin texture, reducing the visibility of marks and scratches on the surface.
Anodizing increases corrosion resistance and wear properties, while allowing for color dyeing, ideal for aluminum parts.
Black oxide is a conversion coating that is used on steels to improve corrosion resistance and minimize light reflection.
Electroplating bonds a thin metal layer onto parts, improving wear resistance, corrosion resistance, and surface conductivity.
This is a finish of applying powdered paint to the components and then baking it in an oven, which results in a stronger, more wear- and corrosion-resistant layer that is more durable than traditional painting methods.
This is a finish of applying powdered paint to the components and then baking it in an oven, which results in a stronger, more wear- and corrosion-resistant layer that is more durable than traditional painting methods.
Please provide additional text description for other surface treatment requirements!
Material
Material
  • CNC Metals
    • Aluminum
    • Brass
    • Stainless steel
    • Inconel718
    • Carbon Fiber
    • Tool Steel
    • Mold Steel
    • Titanium
    • Alloy Steel
    • Copper
    • Bronze
    • Low Carbon Steel
    • Magnesium
  • CNC Plastics
    • ABS
    • PC
    • PMMA (Acrylic)
    • PA (Nylon)
    • PE
    • PEEK
    • PP
    • HDPE
    • HIPS
    • LDPE
Printer
Printer
  • CNC Metals
    • 5 Axis CNC Machining
    • 4 Axis CNC Machining
    • 3 Axis CNC Machining
    • CNC Milling & Turning
    • Rapid Tooling
    • Metal Die Casting
    • Vacuum Casting
    • Sheet Metal Fabrication
    • SLA 3D Printing
    • SLS 3D Printing
    • SLM 3D Printing
  • Rapid Prototyping
    • Design Best Processing Method According To 3D Drawings
Post-processing
Post-processing
  • As Machined(Product’s natural color)
  • Sand Blasting
  • Polishing
  • Brushed Finish
  • Anodizing
  • Black Oxide
  • Electroplating
  • Paint Coating
  • Powder Coating
  • Other surface treatment requirements
Finalize
The world's first CNC machining center that dares to provide free samples!

Free for first product valued at less than $200. (Background check required)

precision machining cnc quote online

15 Years CNC Machining Services

When you’re ready to start your next project, simply upload your 3D CAD design files, and our engineers will get back to you with a quote as soon as possible.
Scroll to Top

ISO 9001 Certificate

ISO 9001 is defined as the internationally recognized standard for Quality Management Systems (QMS). It is by far the most mature quality framework in the world. More than 1 million certificates were issued to organizations in 178 countries. ISO 9001 sets standards not only for the quality management system, but also for the overall management system. It helps organizations achieve success by improving customer satisfaction, employee motivation, and continuous improvement. * The ISO certificate is issued in the name of FS.com LIMITED and applied to all the products sold on FS website.

greatlight metal iso 9001 certification successfully renewed
GB T 19001-2016 IS09001-2015
✅ iso 9001:2015
greatlight metal iso 9001 certification successfully renewed zh

IATF 16949 certificate

IATF 16949 is an internationally recognized Quality Management System (QMS) standard specifically for the automotive industry and engine hardware parts production quality management system certification. It is based on ISO 9001 and adds specific requirements related to the production and service of automotive and engine hardware parts. Its goal is to improve quality, streamline processes, and reduce variation and waste in the automotive and engine hardware parts supply chain.

automotive industry quality management system certification 01
Certification of Production Quality Management System for Engine Hardware Parts Engine Hardware Associated Parts
automotive industry quality management system certification 00
发动机五金零配件的生产质量管理体系认证

ISO 27001 certificate

ISO/IEC 27001 is an international standard for managing and processing information security. This standard is jointly developed by the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC). It sets out requirements for establishing, implementing, maintaining, and continually improving an information security management system (ISMS). Ensuring the confidentiality, integrity, and availability of organizational information assets, obtaining an ISO 27001 certificate means that the enterprise has passed the audit conducted by a certification body, proving that its information security management system has met the requirements of the international standard.

greatlight metal technology co., ltd has obtained multiple certifications (1)
greatlight metal technology co., ltd has obtained multiple certifications (2)

ISO 13485 certificate

ISO 13485 is an internationally recognized standard for Quality Management Systems (QMS) specifically tailored for the medical device industry. It outlines the requirements for organizations involved in the design, development, production, installation, and servicing of medical devices, ensuring they consistently meet regulatory requirements and customer needs. Essentially, it's a framework for medical device companies to build and maintain robust QMS processes, ultimately enhancing patient safety and device quality.

greatlight metal technology co., ltd has obtained multiple certifications (3)
greatlight metal technology co., ltd has obtained multiple certifications (4)

Get The Best Price

Send drawings and detailed requirements via Email:[email protected]
Or Fill Out The Contact Form Below:

All uploads are secure and confidential.