🤖 ⭐ 14-Day Free Trial
Install Extension Free →
AI Assistant for Engineers
🧮 Tools 🧮 Calc 📐 Sections 🔄 Convert 🤖 AI Chat 📊 RFQ 🖱️ Right-Click Tools — Any Webpage
Free · 🎁 Free 14-Day Trial — No Premium License Key Required. Just add your own API key for AI features.
Premium: $5/mo | 📘 Guide | 🔒 Privacy | ⬇️ Available on Chrome · Edge · Firefox

Free CNC G-Code Generator & Toolpath Creator | Drilling, Milling & Lathe

Free online CNC G-Code generator for drilling cycles, pocket milling, slotting, facing, and lathe operations. Supports Fanuc, Haas, GRBL & more.
Find Me: Google Knowledge Panel
Common Questions about SteelSolver.com: More
We independently provide precision steel tools, calculators, and expert resources for steel, metalworking, construction, and industrial projects. Learn More.
Published -
Updated -
Estimated read time

Create professional CNC G-code instantly with this free online toolpath creator. Whether you need drilling cycles, pocket milling, slot milling, surface facing, or lathe operations (turning, threading, and grooving), this powerful utility generates complete, ready-to-run programs in seconds.

Supports major controllers including Fanuc, Haas, GRBL, Mach3, LinuxCNC, and Siemens. Features include multiple hole patterns, peck drilling, multi-depth strategies, feeds & speeds calculator, coordinate tables, and visual canvas previews.

Perfect for machinists, hobbyists, and CNC beginners, no expensive CAM software required. Simply enter your parameters, generate, copy, or download your G-code instantly.

CNC G-Code Generator

Free online toolpath creator & CNC programming utility. Generate drilling, bolt circle, pocket milling, lathe, and engraving G-code for Fanuc, Haas, GRBL, Mach3, LinuxCNC, and Siemens controllers.

Drilling G-Code — Parameters

Machine & Controller
Drill Cycle Type
Hole Coordinates
Depth & Safety
Tool & Spindle
Options
💾

G-Code Output

Holes
Depth
mm
Est. Time
sec
Lines
drilling.nc
Click "Generate G-Code" to produce output.
Coordinate Table
#XYZ Depth
Generate code to populate table

Bolt Circle G-Code — Parameters

Pattern Definition
Drilling Parameters
💾

Bolt Circle Output

Holes
Radius
mm
Spacing
°
Est. Time
sec
bolt_circle.nc
Click "Generate G-Code" to produce output.
Hole Coordinates
#XYAngle °
Generate to populate

Pocket Milling — Parameters

Pocket Type & Dimensions
Tool & Cutting Parameters
💾

Pocket G-Code Output

Z Passes
Stepover
mm
Est. Time
min
MRR
cm³/min
pocket.nc
Click "Generate Pocket G-Code" to produce output.

Slot Milling — Parameters

Slot Geometry
Tool & Depth
💾

Slot Output

Length
mm
Passes
Est. Time
sec
slot.nc
Click "Generate Slot G-Code" to produce output.

Facing Operation — Parameters

Stock Dimensions
Tool & Strategy
💾

Facing Output

Passes
Path Length
mm
Est. Time
min
facing.nc
Click "Generate Facing G-Code" to produce output.

Lathe G-Code — Parameters

Operation
Stock & Dimensions
Cutting Parameters
💾

Lathe G-Code Output

Passes
Material Removed
mm
Est. Time
min
lathe.nc
Click "Generate Lathe G-Code" to produce output.
📈

Feeds & Speeds Calculator

Tool & Material
📊

Results & Recommendations

Spindle Speed (S / RPM)
RPM
Feed Rate (F)
mm/min
Plunge Rate (40% of Feed)
mm/min
Surface Speed
m/min
Formulas Used

Spindle Speed (RPM)

$$S = \frac{V_c \times 1000}{\pi \times D}$$

Where $V_c$ = cutting speed (m/min), $D$ = tool diameter (mm)

Feed Rate

$$F = S \times f_z \times z$$

Where $f_z$ = chip load (mm/tooth), $z$ = number of flutes

Calculated values are starting recommendations. Always verify with toolmaker specifications and adjust based on material condition, machine rigidity, and tool runout.
📚

G-Code & M-Code Cheat Sheet

CodeCategoryDescriptionExample
G00MotionRapid positioning — non-cutting move at max machine speedG00 X100 Y50 Z5
G01MotionLinear interpolation — controlled cutting feed moveG01 X80 Y30 F300
G02ArcCircular interpolation — clockwise arcG02 X20 Y0 R10 F200
G03ArcCircular interpolation — counter-clockwise arcG03 I5 J0 F200
G04ControlDwell — pause program for P milliseconds or secondsG04 P500
G17PlaneSelect XY plane (default for milling)G17
G18PlaneSelect XZ planeG18
G19PlaneSelect YZ planeG19
G20UnitsSet units to InchesG20
G21UnitsSet units to MillimetersG21
G28ControlReturn to machine home positionG91 G28 Z0
G40CompCancel cutter radius compensationG40
G41CompCutter compensation — left of pathG41 D01
G42CompCutter compensation — right of pathG42 D01
G43CompTool length compensation positive offsetG43 H01 Z5.0
G49CompCancel tool length compensationG49
G54WCSWork coordinate system #1 (most common)G54
G55–G59WCSWork coordinate systems #2–#6G55
G73CycleHigh-speed peck drilling — partial retract chip breakG73 Z-25 R2 Q5 F120
G80CycleCancel canned drilling cycleG80
G81CycleStandard drilling cycle — plunge and retractG81 Z-20 R2 F120
G82CycleSpot drilling with dwell at bottomG82 Z-5 R2 P500 F120
G83CyclePeck drilling — full retract each peckG83 Z-40 R2 Q5 F100
G84CycleRigid tapping cycleG84 Z-20 R2 F1.5
G90ModeAbsolute positioning (coordinates from WCS origin)G90
G91ModeIncremental positioning (coordinates relative to current position)G91
G98CycleCanned cycle return to initial Z levelG98
G99CycleCanned cycle return to R-planeG99
M-CODES (Miscellaneous Functions)
M00ControlProgram stop — requires operator to press cycle startM00
M01ControlOptional stopM01
M03SpindleSpindle on — clockwise (CW)M03 S1200
M04SpindleSpindle on — counter-clockwise (CCW)M04 S800
M05SpindleSpindle stopM05
M06ToolTool changeT01 M06
M07CoolantMist coolant onM07
M08CoolantFlood coolant onM08
M09CoolantCoolant offM09
M30ControlEnd of program + rewindM30
M98SubCall subprogramM98 P0100 L3
M99SubReturn from subprogramM99
📜

CNC Machining Formulas & Calculations

Spindle Speed (RPM)

Metric (m/min cutting speed)

$$S = \frac{V_c \times 1000}{\pi \times D}$$

$S$ = spindle speed (RPM)  |  $V_c$ = cutting speed (m/min)  |  $D$ = tool diameter (mm)

Imperial (SFM cutting speed)

$$S = \frac{\text{SFM} \times 3.82}{D}$$

$S$ = spindle speed (RPM)  |  SFM = surface feet per minute  |  $D$ = tool diameter (inches)

Feed Rate Calculation

Feed Rate (mm/min or IPM)

$$F = S \times f_z \times z$$

$F$ = feed rate  |  $S$ = spindle RPM  |  $f_z$ = chip load per tooth  |  $z$ = number of flutes

Bolt Circle Hole Coordinates

Hole Position on Bolt Circle

$$X_n = X_c + R \cos\!\left(\theta_0 + \frac{360°\,(n-1)}{N}\right)$$ $$Y_n = Y_c + R \sin\!\left(\theta_0 + \frac{360°\,(n-1)}{N}\right)$$

$X_c, Y_c$ = circle center  |  $R$ = bolt circle radius  |  $\theta_0$ = start angle  |  $N$ = number of holes  |  $n$ = hole index

Arc Center Offsets I, J, K

I, J Calculation for G02/G03 (Mill)

$$I = X_{\text{center}} - X_{\text{start}} \qquad J = Y_{\text{center}} - Y_{\text{start}}$$

$I$ = X offset from arc start to arc center  |  $J$ = Y offset from arc start to arc center

For lathe (G02/G03): $I = X_{\text{center}} - X_{\text{start}}$  |  $K = Z_{\text{center}} - Z_{\text{start}}$

Material Removal Rate (MRR)

MRR — Milling

$$\text{MRR} = \text{DOC} \times \text{WOC} \times F$$

DOC = axial depth of cut (mm)  |  WOC = width of cut / stepover (mm)  |  $F$ = feed rate (mm/min)

Result in mm³/min. Divide by 1000 for cm³/min.

Cycle Time Estimation

Estimated Cycle Time

$$T = \frac{L_{\text{rapid}}}{V_{\text{rapid}}} + \frac{L_{\text{feed}}}{F} + \sum P_i$$

$L_{\text{rapid}}$ = total rapid distance  |  $V_{\text{rapid}}$ = machine rapid speed  |  $L_{\text{feed}}$ = total cutting path length  |  $F$ = average feed rate  |  $P_i$ = dwell times

Peck Drilling Cycle Count

Number of Pecks (G83)

$$\text{PeckCount} = \left\lceil \frac{Z_{\text{total}}}{Q} \right\rceil$$

$Z_{\text{total}}$ = total drill depth  |  $Q$ = peck depth increment  |  $\lceil \cdot \rceil$ = ceiling (round up)

Thread Milling Helix Radius

Arc Radius for Thread Milling Entry

$$R_{\text{arc}} = \frac{D_{\text{hole}} - D_{\text{tool}}}{2}$$

$D_{\text{hole}}$ = hole diameter  |  $D_{\text{tool}}$ = thread mill tool diameter

Tapping Feed Rate (Rigid Tap G84)

$$F = \text{RPM} \times \text{Pitch}$$

Pitch in mm/rev (metric) or inches/rev (imperial)

Stepover & Pass Calculation

Absolute Stepover from Percentage

$$\text{WOC} = D \times \frac{\%}{100}$$

$D$ = tool diameter  |  $\%$ = stepover percentage (typically 40–60% for roughing)

Number of Z Passes

$$\text{Passes} = \left\lceil \frac{|Z_{\text{depth}}|}{\text{StepDown}} \right\rceil$$
User Pain Points Solved by This Tool

Manual G-Code Writing is Slow

Users waste time hand-coding G00, G01, drilling cycles, and repetitive coordinates. This tool auto-generates complete programs instantly.

🚫

Syntax Errors Cause Crashes

Wrong decimal placement, missing safety lines, or bad modal codes cause tool crashes and scrapped parts. Our generator validates all output.

🎓

Beginners Don't Know G-Code

New machinists struggle with arc commands, canned cycles, and coordinate modes. This guided form-based tool removes the learning curve.

💰

CAM Software is Too Expensive

Full CAM packages cost thousands. This free browser-based utility handles common operations without any software installation.

Repetitive Hole Patterns are Tedious

Bolt circles, grid arrays, and linear patterns require many calculations. This tool computes all X/Y positions automatically using the standard formula.

🔌

Controller Compatibility Confusion

Fanuc, Haas, GRBL, LinuxCNC all have dialect differences. Post-processor selection tailors output syntax to your exact machine.

🛠

Supported Operations & Features

Drilling Cycles
  • G81 — Standard plunge drill
  • G83 — Deep hole peck drilling
  • G73 — High-speed chip-break peck
  • G82 — Spot drill with dwell
  • G84 — Rigid tapping
Hole Patterns
  • Single hole — manual X/Y
  • Linear array — N holes, spacing
  • Rectangular grid — rows × columns
  • Bolt circle (PCD) — any # of holes
  • Clockwise & counter-clockwise
Milling Operations
  • Rectangular pocket (zig-zag)
  • Circular pocket (G02/G03)
  • Slot milling (multi-pass)
  • Surface facing (raster)
  • Multi-level Z step-down
Lathe Operations
  • OD turning (multi-pass)
  • Facing operation
  • Threading (G76 cycle)
  • Grooving
  • Roughing + finishing passes
Controllers Supported
  • Fanuc / Haas (standard)
  • GRBL (Arduino CNC)
  • Mach3 / Mach4
  • LinuxCNC (.ngc)
  • Siemens Sinumerik
Calculators Included
  • Feeds & speeds calculator
  • RPM from cutting speed
  • Feed from chip load
  • Cycle time estimation
  • MRR (material removal rate)

CNC G-Code Generator — Complete User Guide Free online CNC programming tool & toolpath creator for milling, drilling, lathe, plasma, router, and laser machining

Free & Browser-Based No Download Required Fanuc / Haas / GRBL / Mach3 Beginners & Professionals Drilling + Bolt Circle + Pocket + Slot + Lathe Feeds & Speeds Calculator

This free online CNC G-Code Generator is a browser-based CAM utility and digital toolpath creator that converts your machining parameters into ready-to-run G-code programs — without expensive software, complex CAD/CAM systems, or manual scripting. Whether you are a beginner learning CNC numerical control or a professional machinist needing fast code generation for production runs, this tool covers the full workflow from geometry definition through post-processor output and file download.

The generator supports CNC mills, drill presses, lathes, plasma cutters, routers, and laser engravers, producing G-code compatible with Fanuc, Haas, GRBL, Mach3, LinuxCNC, and Siemens Sinumerik controllers. It handles drilling cycles, bolt circle patterns, pocket milling, slot cutting, facing operations, lathe turning, threading, and grooving — with a built-in feeds & speeds calculator and visual toolpath preview.

CNC G-Code Workflow: From CAD Design to Machine Motion

The diagram below illustrates the complete digital-to-physical manufacturing pipeline — from your part design through the G-code generator and post-processor to the CNC machine controller and final fabrication.

CNC G-CODE GENERATION WORKFLOW CAD / Design STL / SVG / DXF Geometry & Coordinates G-Code Generator This Free Online Tool Toolpath + Parameters Feeds, Speeds, Cycles Post Processor Fanuc / Haas / GRBL Dialect Formatting 📄 .nc / .tap File G00 G01 G02 G83 Download / Copy 💾 CNC Machine Mill / Lathe / Router Plasma / Laser / Drill Precision Fabrication KEY G-CODE MOTION COMMANDS GENERATED G00 Rapid Positioning Non-cutting speed G01 Linear Interpolation Controlled feed cut G02 Clockwise Arc Circular interpolation CW G03 Counter-CW Arc Circular interpolation CCW G81/G83 Canned Drill Cycles Auto peck drilling M03 / M08 / M30 Spindle / Coolant / End Machine auxiliary control SUPPORTED MACHINING OPERATIONS ● DrillingG81 / G83 / G73 ● Bolt CirclePCD / Pattern ● PocketRect / Circular ● Slot MillingMulti-pass ● FacingRaster passes ● Lathe / TurnOD / Thread ● EngravingRouter / Laser ● Feeds &Speeds Calc

ⓘ The complete digital engineering workflow: CAD geometry → G-Code Generator → Post-Processor → .nc File → CNC Machine production

Key User Pain Points — and How This CNC G-Code Generator Solves Them

Manual G-Code Writing is Slow

Writing hundreds of lines of G00, G01, drilling cycles, and coordinate math by hand wastes shop time and productivity in every job.

🚫

Syntax Errors Cause Machine Crashes

Wrong decimal placement, missing G80 cycle cancels, or incorrect modal commands cause tool crashes, broken cutters, and scrapped material.

🎓

Beginners Don't Understand G-Code Language

CNC programming syntax, arc interpolation, canned cycles, and coordinate systems have a steep learning curve for new machinists and students.

💰

Full CAM Software is Expensive

Professional CAM systems like Mastercam or Fusion 360 cost hundreds per year. This free browser-based tool handles most common operations instantly.

Repetitive Hole Patterns are Tedious

Bolt circles, linear arrays, and grid patterns require manual coordinate calculation for every hole. The bolt circle module computes all X/Y positions automatically.

🔌

Controller Compatibility Confusion

Fanuc, Haas, GRBL, LinuxCNC, and Siemens all use slightly different dialect syntax. The post-processor selector adapts output for each system automatically.

Step-by-Step User Guide — How to Use the CNC G-Code Generator

  • 1
    Select Your Machining Module (Tab)

    At the top of the tool, choose the correct operation tab for your job: Drilling, Bolt Circle, Pocket, Slot, Facing, Lathe, Feeds & Speeds, or the G-Code Cheat Sheet. Each module generates a specific toolpath type optimised for that machining operation. Beginners should start with the Drilling tab, which auto-generates a working example on load.

    Do not mix up the Drilling tab (which uses canned cycles like G81/G83) with the Pocket tab (which generates zig-zag or circular toolpaths). They serve different cutting operations.
  • 2
    Choose Controller and Units

    Under Machine & Controller, select your CNC machine's control dialect from the dropdown: Fanuc / Haas (standard industry syntax), GRBL (Arduino-based CNC routers), Mach3 / Mach4, LinuxCNC, or Siemens Sinumerik. Then choose Millimeters (G21) or Inches (G20). This affects all coordinate output, depth values, feed rates, and safe-Z heights throughout the generated program.

    Common mistake: Selecting the wrong units. If your machine is metric but you generate inch G-code (G20), the tool will move 25.4× too far and crash. Always confirm your machine's unit setting first.
  • 3
    Select Drilling Cycle Type (Drilling Tab)

    Choose the appropriate canned cycle for your operation: G81 for standard plunge drilling, G83 for deep hole peck drilling (full retract each peck), G73 for high-speed chip-break peck (partial retract), G82 for spot drilling with a dwell pause, or G84 for rigid tapping. Use G83 for any hole deeper than 3× the tool diameter to prevent chip packing and tool breakage.

    Rule of thumb: Hole depth > 3× drill diameter = always use G83 peck drilling. Forgetting this is the most common reason for drill breakage in deep holes.
  • 4
    Select Hole Pattern and Enter Coordinates

    Choose Single Hole, Linear Array, or Rectangular Grid. For a single hole, enter the X and Y coordinate. For a linear array, enter start X/Y, spacing between holes, hole count, and axis direction. For a grid, enter origin, number of rows and columns, and X/Y spacing. All coordinates are in the selected unit (mm or inch) relative to your Work Coordinate System (WCS) origin (G54 by default).

    For bolt circle / PCD patterns (flanges, pipe flanges), use the dedicated Bolt Circle tab — it automatically calculates all X/Y positions using the polar coordinate formula.
  • 5
    Set Z-Axis Depth, Safe Z, and Peck Parameters

    Enter three critical Z values: Z Top (surface of the material, typically 0.000), Z Depth (final drill depth — must be a negative number, e.g. −20), and Safe Z (clearance height above the part for rapid moves, e.g. 5). For G83/G73 peck cycles, also enter the Peck Depth Q (how deep each peck goes before retracting) and optional Dwell P in seconds for G82.

    Z Depth must be negative (below the surface). A positive Z depth value means you are cutting upward into air, not into the material — a very common beginner mistake.
  • 6
    Enter Tool Number, Spindle Speed, and Feed Rate

    Enter the Tool Number (T) (1–99), which sets both the tool change command and tool length offset register. Enter Spindle Speed (S) in RPM and Feed Rate (F) in mm/min or IPM. Not sure of the correct values? Switch to the Feeds & Speeds tab first — enter your tool diameter, material, and chip load to get automatic RPM and feed rate recommendations using the built-in calculator formulas.

    Feed rate of 0 will cause a syntax error in most controllers. If you do not know the feed rate, use the Feeds & Speeds tab to calculate it before returning to generate your drilling code.
  • 7
    Configure Options: WCS, Retract Mode, Coolant, Line Numbers

    Select the Work Coordinate System (WCS) — G54 through G59 — matching your fixture offset on the machine. Choose G98 (return to initial Z height between holes) or G99 (return to R-plane only) retract mode. Toggle Flood Coolant (M08), Line Numbers (N-codes), Comments in parentheses, and Tool Length Compensation G43 on or off using the switch toggles.

    Use G98 when the fixture or clamps protrude above the part — it ensures the tool retracts fully above them between holes. Use G99 on flat plates for faster cycle times.
  • 8
    Click Generate G-Code and Review the Output

    Click the orange Generate G-Code button. The tool validates all inputs (checks for positive Z depth, non-zero feeds, safe Z above surface), then generates the complete G-code program in the output panel. Review the Results Summary (hole count, depth, estimated cycle time, line count), examine the Coordinate Table for all X/Y/Z positions, and inspect the Toolpath Preview canvas showing the visual drill pattern.

  • 9
    Copy to Clipboard or Download the .nc File

    Click 📋 Copy to send the G-code to your clipboard for pasting directly into your machine controller editor, or click ↓ Download to save a ready-to-load .nc file. The filename reflects the operation type (e.g. drilling.nc, bolt_circle.nc, pocket.nc). Most CNC controllers accept .nc, .tap, .txt, or .ngc formats — rename the extension if needed.

    Always run the program in DRY RUN or AIR CUT mode on your machine first (spindle on, no material) to verify all movements are correct before cutting actual stock.
  • 10
    Use the Feeds & Speeds Calculator Tab

    Navigate to the Feeds & Speeds tab. Select your material from the pre-loaded library (Aluminum, Mild Steel, Stainless, Brass, Titanium, Plastic, Wood), choose your cutter type (End Mill, Ball Nose, Drill, Face Mill), enter tool diameter and flute count. The calculator applies the standard spindle speed and feed rate formulas automatically. Use the results as starting values in your drilling or milling code — always verify against your toolmaker's specifications.

All Formulas Used — Calculation Reference with Units

Every result produced by this CNC G-Code Generator is computed using the following standard machining formulas. These are the same calculations used in professional CAM software and CNC programming textbooks. All formula variables are defined with their units for clarity and trust.

1Spindle Speed (RPM) — S Parameter

The spindle speed formula converts the recommended cutting speed for a material/tool combination into the rotational speed (RPM) the CNC machine spindle must turn at. This value becomes the S word in the G-code (e.g. S1200 M03).

Metric — Spindle Speed from Cutting Speed
$$S \;(\text{RPM}) = \frac{V_c \times 1000}{\pi \times D}$$
S = Spindle speed (RPM — revolutions per minute) Vc = Cutting speed (m/min — meters per minute, material-specific) D = Tool diameter (mm — millimeters) π = Pi (3.14159...)
Imperial — Spindle Speed from Surface Feet per Minute (SFM)
$$S \;(\text{RPM}) = \frac{\text{SFM} \times 3.82}{D \;(\text{inches})}$$
SFM = Surface Feet per Minute (imperial cutting speed) 3.82 = Constant = 12 / π (unit conversion factor) D = Tool diameter (inches)

Worked Example — Spindle Speed

Problem: 10mm carbide end mill cutting Aluminum 6061. Recommended cutting speed = 300 m/min.

Calculation: \( S = \frac{300 \times 1000}{\pi \times 10} = \frac{300{,}000}{31.416} \approx \mathbf{9{,}549 \text{ RPM}} \)

G-code output: S9549 M03

2Feed Rate (F Parameter) — mm/min or IPM

The feed rate is the speed at which the cutter moves through the material. It is derived from the spindle RPM, chip load per tooth, and number of cutter flutes. This becomes the F word in all G01, G02, G03, and canned cycle commands.

Feed Rate Formula
$$F = S \times f_z \times z$$
F = Feed rate (mm/min or IPM — inches per minute) S = Spindle speed (RPM) fz = Chip load per tooth (mm/tooth or inch/tooth — tool/material specific) z = Number of cutting flutes (integer, typically 2–6)

Worked Example — Feed Rate

Problem: 4-flute carbide end mill in Aluminum, S = 9,549 RPM, chip load = 0.04 mm/tooth.

Calculation: \( F = 9549 \times 0.04 \times 4 = \mathbf{1{,}527 \text{ mm/min}} \)

G-code output: G01 X50 Y0 F1527

3Bolt Circle / PCD Hole Coordinates

The bolt circle (Pitch Circle Diameter) formula calculates the X and Y coordinates of each equally-spaced hole around a circle. This is the core calculation behind the Bolt Circle G-Code Generator tab and is used to produce the X and Y coordinate words for each drilling position.

Bolt Circle — Hole Coordinate Formula
$$X_n = X_c + R \cos\!\left(\theta_0 + \frac{360°\,(n-1)}{N}\right)$$ $$Y_n = Y_c + R \sin\!\left(\theta_0 + \frac{360°\,(n-1)}{N}\right)$$
Xn, Yn = Coordinates of hole number n (mm or inches) Xc, Yc = Center point of the bolt circle (mm or inches) R = Bolt circle radius = PCD / 2 (mm or inches) θ0 = Start angle in degrees (0° = positive X axis, 3 o'clock position) N = Total number of holes (integer) n = Hole index number (1, 2, 3, ..., N)

Worked Example — Bolt Circle (6 holes, PCD 100mm)

Problem: 6 equally-spaced holes on a 100mm PCD, center at X0 Y0, start angle 0°.

\( R = 100/2 = 50\text{mm} \quad\) Angle step \(= 360/6 = 60°\)

Hole 1: \( X = 50\cos(0°) = 50.0000, \quad Y = 50\sin(0°) = 0.0000 \)

Hole 2: \( X = 50\cos(60°) = 25.0000, \quad Y = 50\sin(60°) = 43.3013 \)

Hole 3: \( X = 50\cos(120°) = -25.0000, \quad Y = 50\sin(120°) = 43.3013 \)

...and so on for all 6 holes.

4Arc Center Offsets I, J, K — Circular Interpolation

For G02 (clockwise arc) and G03 (counter-clockwise arc) commands, the controller needs to know the arc center position relative to the start point. The generator calculates I and J offsets automatically so you never have to do this complex geometry manually.

Arc Center Offset — Mill (XY Plane, G17)
$$I = X_{\text{center}} - X_{\text{start}} \qquad J = Y_{\text{center}} - Y_{\text{start}}$$
I = X distance from arc start point to arc center point (mm or inches) J = Y distance from arc start point to arc center point (mm or inches) Xcenter, Ycenter = Absolute coordinates of the arc center Xstart, Ystart = Absolute coordinates of the arc starting point For lathe (XZ plane, G18): I = Xcenter − Xstart and K = Zcenter − Zstart

5Number of Peck Passes — G83 Deep Hole Drilling

When using the peck drilling cycle (G83), the generator calculates how many individual peck increments are needed to reach the final hole depth, then outputs the Q parameter accordingly.

Peck Count Calculation
$$\text{PeckCount} = \left\lceil \frac{|Z_{\text{depth}}|}{Q} \right\rceil$$
|Zdepth| = Total drill depth, absolute value (mm or inches) Q = Peck depth per increment (mm or inches — entered in the Peck Depth field) ⌈ · ⌉ = Ceiling function (round up to nearest whole number)

6Material Removal Rate (MRR) — Pocket Tab

The Material Removal Rate measures how efficiently the cutter is removing stock, calculated from the axial depth of cut (step-down), stepover width, and feed rate. The Pocket tab displays this result in cm³/min.

Material Removal Rate — Milling
$$\text{MRR} = \text{DOC} \times \text{WOC} \times F \div 1000$$
MRR = Material removal rate (cm³/min) DOC = Axial depth of cut per pass / step-down (mm) WOC = Width of cut / stepover (mm) = Tool Diameter × (Stepover% / 100) F = Feed rate (mm/min) Divide by 1000 to convert mm³/min to cm³/min

7Stepover (WOC) and Z-Pass Count — Pocket & Facing

Absolute Stepover from Percentage
$$\text{WOC} = D \times \frac{\text{Stepover\%}}{100}$$
D = Tool diameter (mm) Stepover% = User-entered stepover percentage (typically 40–60% for roughing, 10–20% for finishing)
Number of Z Depth Passes
$$\text{Passes} = \left\lceil \frac{|Z_{\text{depth}}|}{\text{StepDown}} \right\rceil$$
|Zdepth| = Total pocket or slot depth (mm, absolute value) StepDown = Maximum cut depth per Z pass (mm — entered by user)

8Estimated Cycle Time Calculation

The generator estimates the drilling program cycle time using the total cutting distance divided by the feed rate, plus rapid move overhead. This is shown in the Results Summary section as Est. Time (sec).

Simplified Cycle Time Estimate — Drilling
$$T \approx N_h \times \frac{|Z_{\text{depth}}|}{F} \times 60 \;+\; N_h \times t_{\text{rapid}}$$
T = Estimated cycle time (seconds) Nh = Number of holes |Zdepth| = Hole depth (mm) F = Feed rate (mm/min) 60 = Converts minutes to seconds trapid = Estimated rapid move overhead per hole (≈0.5 seconds)

9Threading & Tapping Formulas

Rigid Tapping Feed Rate (G84)
$$F_{\text{tap}} = S_{\text{RPM}} \times \text{Pitch}$$
Ftap = Tapping feed rate (mm/min or IPM) SRPM = Spindle speed in RPM Pitch = Thread pitch in mm/rev (metric) or inches/rev (imperial) Example: M10×1.5 thread at 600 RPM → F = 600 × 1.5 = 900 mm/min
Thread Mill Helical Arc Radius
$$R_{\text{arc}} = \frac{D_{\text{hole}} - D_{\text{tool}}}{2}$$
Rarc = Helical interpolation radius used in G02/G03 arc motion (mm) Dhole = Target hole or thread major diameter (mm) Dtool = Thread mill tool diameter (mm)
📊

Accuracy Note: All formulas in this generator follow ISO 841 and industry-standard CNC programming mathematics. Spindle speed and feed rate calculations produce theoretically correct starting values based on the cutting speed and chip load you enter. In practice, actual optimal values depend on machine rigidity, tool runout, workholding, coolant, and material batch variation. Treat all calculated values as starting points — always verify with a dry run and adjust based on observed cut quality, tool temperature, and surface finish. The generator validates all inputs before generating code and will flag errors such as zero feed rates, positive Z depth values, and unsafe clearance heights.

Input Parameters Reference — Units, Valid Ranges, and Descriptions

Parameter Unit Typical Range Description G-Code Word
X Coordinatemm / inchAnyHorizontal position of hole or toolpath point relative to WCS originX
Y Coordinatemm / inchAnyVertical position of hole or toolpath point relative to WCS originY
Z Depthmm / inchNegative valueFinal drill or cutting depth below Z Top surface. Must be negative.Z
Safe Zmm / inch3–10 mm typicalClearance height above part for rapid (G00) positioning between holesR / Z
Peck Depth Qmm / inch2–8 mm typicalIncrement depth per peck in G83/G73 cycles before chip-clearing retractQ
Dwell Pseconds0.2–2.0 secPause time at bottom of hole in G82 spot drill or G04 dwell commandP
Spindle Speed SRPM100–30,000 RPMSpindle rotational speed. M03 = CW, M04 = CCWS
Feed Rate Fmm/min / IPM20–5,000 mm/minCutting feed rate for G01/G02/G03 and canned cycle plungeF
Tool Number TInteger1–99Tool number for automatic tool changer (ATC) or manual tool change (M06)T
PCD DiametermmAny positivePitch Circle Diameter for bolt circle pattern — diameter of the circle all holes lie onCalculated to X,Y
Start Angledegrees0–360°Angle of first hole in bolt circle (0° = 3 o'clock / positive X axis)Calculated to X,Y
Step-Downmm0.5–5 mm typicalMaximum depth of cut per Z-level pass in pocket or slot millingCalculated to Z
Stepover %%30–60% roughingPercentage of tool diameter used as lateral path spacing in pocket operationsCalculated to X,Y
Cutting Speed V₃m/min50–800 m/minRecommended surface speed for the material/tool combination (from machining data tables)Used to calculate S
Chip Load fᵣmm/tooth0.01–0.15 mm/toothMaterial thickness removed per tooth per revolution. Determines feed rate.Used to calculate F

Controller Compatibility — Post-Processor G-Code Dialects

This CNC G-Code generator supports multiple machine controller dialects through its built-in post-processor selector. Choose the correct controller to ensure generated syntax matches your machine's interpreter requirements for numerical control commands, arc formatting, and canned cycle parameters.

Fanuc 0i / 30i Haas VF Series GRBL 1.1 Mach3 / Mach4 LinuxCNC 2.x Siemens 840D
Controller Canned Cycle Syntax Arc Format Key Differences File Extension
Fanuc / Haas G83 Z-25 R2 Q5 F120 I/J or R Industry standard. Leading zeros required. O-number program header. .nc / .tap
GRBL Expanded to G00/G01 moves (no native canned cycles) I/J incremental No G81/G83 support — generator expands to individual axis moves automatically .nc / .gcode
Mach3 / Mach4 G83 Z-25 R2 Q5 F120 I/J or R Similar to Fanuc. Uses % delimiters. Some M-codes differ. .tap / .nc
LinuxCNC G83 Z-25 R2 Q5 F120 I/J or R RS274 dialect. Uses .ngc extension. Very Fanuc-compatible. .ngc
Siemens 840D CYCLE83() function calls I/J absolute Entirely different syntax. CYCLE commands instead of G8x. Significant format change. .mpf

G-Code & M-Code Quick Reference — Commands Generated by This Tool

The following table covers every G-code and M-code command that this generator produces. Understanding these commands helps you verify the output, edit programs for your specific requirements, and understand the machine motion sequence.

CodeCategoryFunctionKey Parameters
G00MotionRapid positioning — moves at maximum machine speed without cutting. Used for tool positioning between holes.X Y Z
G01MotionLinear interpolation — straight-line cutting motion at a controlled feed rate. Used for slot cutting, lathe turning, and plunge moves.X Y Z F
G02ArcClockwise circular interpolation. Used for circular pocket perimeters and arc contours.X Y I J R F
G03ArcCounter-clockwise circular interpolation. Used for circular pocket entry moves and inside arc profiles.X Y I J R F
G17PlaneSelect XY working plane — standard for all milling operations. Required in safety header.
G20 / G21UnitsG20 = Inch mode. G21 = Metric (mm) mode. Set in safety header — all subsequent coordinates use this unit.
G40CompCancel cutter radius compensation. Included in safety header to ensure clean start.
G43CompApply tool length compensation (positive direction). Activates H register for tool length offset.H Z
G49CompCancel tool length compensation. Included in safety header.
G54–G59WCSWork Coordinate System selection. G54 is the most common. Defines the part zero (datum) location.
G73CycleHigh-speed peck drilling. Partial chip-break retract (faster than G83). Good for shallow peck depths in aluminium.Z R Q F
G80CycleCancel canned cycle. Always output after the last hole in any drilling cycle block.
G81CycleStandard drilling cycle. Plunge to depth at feed rate, rapid out. For holes ≤ 3× drill diameter.Z R F
G82CycleSpot drilling cycle with programmable dwell at bottom. P parameter = dwell time in milliseconds.Z R P F
G83CyclePeck drilling — full retract to R-plane between each peck for chip evacuation. Best for deep holes.Z R Q F
G84CycleRigid tapping cycle. Feed = RPM × Pitch. Spindle reverses automatically at bottom to extract tap.Z R F
G90 / G91ModeG90 = Absolute positioning (all coordinates from WCS origin). G91 = Incremental (relative to current position).
G98 / G99CycleG98 = After cycle, retract Z to initial height. G99 = retract only to R-plane. G98 safer for complex fixtures.
M-CODES — Miscellaneous Machine Functions
M03SpindleStart spindle clockwise (CW). Always includes S word for speed.S
M04SpindleStart spindle counter-clockwise (CCW). Used for left-hand tools or tapping retract.S
M05SpindleStop spindle. Output at end of program before machine home return.
M06ToolTool change command. Combined with T word: T01 M06 or M06 T01 (controller-specific order).T
M08 / M09CoolantM08 = Flood coolant on. M09 = All coolant off. M07 = Mist coolant.
M30ControlEnd of program and memory rewind. Always the final line in a CNC program.

Common Mistakes — Microcopy & Input Validation Guide

⚠ Positive Z Depth Value

Z Depth must always be negative for milling and drilling (cutting goes below the surface). Entering Z = +20 instead of Z = −20 will generate code that moves the tool upward into the air. The generator validates this and displays an error before generating code.

⚠ Safe Z Below the Material Surface

Safe Z must be greater than Z Top (the material surface, usually 0). If Safe Z = −2 and the surface is at Z = 0, the rapid move will plunge into the part. Use at least 3–5mm above the highest workpiece feature.

⚠ Wrong Units Selection

If your machine runs in millimeters but you generate code with Inches (G20) selected, all coordinates will be 25.4× too small and all depths too shallow. Verify your controller's active unit mode before generating code.

⚠ Tool Diameter Larger Than Pocket or Slot Width

In the Pocket and Slot tabs, the tool diameter must be smaller than the pocket width/diameter. A 10mm end mill cannot cut a 6mm-wide pocket. The generator does not validate geometry constraints in all cases — check tool-to-feature size manually.

⚠ Forgetting G80 After Drilling Cycle

If G80 (cancel canned cycle) is missing from the program, the machine will attempt to drill at every subsequent X/Y move, causing unintended holes throughout the part. This generator always outputs G80 automatically.

⚠ GRBL Does Not Support Canned Cycles

When GRBL is selected as the controller, the generator automatically expands G81/G83 canned cycles into individual G00/G01 moves. This is correct behaviour — do not attempt to run standard Fanuc-format canned cycle code on a GRBL controller.

Frequently Asked Questions (FAQ) — CNC G-Code Generator

  • A CNC G-Code Generator is a software utility — in this case a free browser-based tool — that converts machining parameters (coordinates, tool dimensions, speeds, depths, and operation type) into ready-to-run G-code programs. G-code is the standardised numerical control language that CNC machines — mills, lathes, routers, plasma cutters, laser engravers, and drill presses — use to control motor movements, spindle speed, and coolant.

    Instead of manually writing every G00, G01, and G83 command line-by-line (a process that is time-consuming and error-prone), you fill in a form with your job parameters and the generator produces the complete, validated code automatically. This is the same function that professional CAM software (Computer-Aided Manufacturing) performs, but focused on common operations that do not require full 3D CAD/CAM integration.

  • Yes — this is a completely free, browser-based online CNC G-Code Generator. There is no software download, no installation, no account required, and no usage limits. It runs entirely in your web browser using standard HTML, CSS, and JavaScript. You can use it on any desktop computer, laptop, or mobile device — including on the workshop floor directly from a tablet or phone.

  • The generator includes a post-processor selector supporting: Fanuc / Haas (the most common industrial standard), GRBL (used in Arduino-based CNC routers and engravers), Mach3 / Mach4 (common in hobby and small shop CNC mills), LinuxCNC (open-source controller using RS274 dialect), and Siemens Sinumerik 840D (European industrial machines using CYCLE-based programming).

    For GRBL machines specifically, the generator expands canned drilling cycles (G81/G83) into individual linear moves since GRBL does not natively support canned cycles. All other controllers use standard G-code syntax with minor dialect differences in header formatting and comment style.

  • G81 — Standard Drilling: The tool plunges to the programmed Z depth in one continuous motion at the specified feed rate, then retracts at rapid speed. Suitable for holes up to approximately 3× the drill diameter deep, where chip evacuation is not a problem.

    G83 — Peck Drilling: The tool plunges to a programmable peck depth (Q value), then fully retracts to the R-plane to clear chips from the flutes, then plunges again. This cycle repeats until the final Z depth is reached. Essential for deep holes (greater than 3–5× diameter), through-holes in difficult materials, or any situation where chip packing could break the drill.

    G73 — High-Speed Peck: Similar to G83 but only partially retracts (a small break) rather than fully retracting. Faster cycle time but less effective chip clearance. Good for shallow peck depths in aluminium.

  • The bolt circle module uses the standard polar-to-Cartesian coordinate conversion formula. Given the circle center coordinates, the Pitch Circle Diameter (PCD), the number of holes, and the start angle, each hole's X and Y position is calculated as:

    \( X_n = X_c + R\cos(\theta_0 + (n-1) \times 360°/N) \) and \( Y_n = Y_c + R\sin(\theta_0 + (n-1) \times 360°/N) \)

    Where R = PCD/2. This is the same calculation performed manually from engineering drawings. The generator does this for all N holes simultaneously and outputs the complete G-code drilling program with accurate coordinates to 4 decimal places.

  • Use the built-in Feeds & Speeds Calculator tab. Select your material from the library (Aluminum, Steel, Stainless, Brass, Titanium, Plastic, Wood), choose your cutter type, enter the tool diameter and flute count. The calculator pre-loads recommended cutting speeds and chip loads from the material database, then applies the formulas:

    \( S = (V_c \times 1000) / (\pi \times D) \) for spindle speed and \( F = S \times f_z \times z \) for feed rate.

    The results give you recommended starting RPM and feed rate values. Copy these into your drilling or milling operation parameters. Always start at 70–80% of the calculated value on your first test cut, then increase gradually.

  • The generator produces standard ASCII text G-code that can be saved as .nc, .tap, .txt, or .gcode files. Click the Download button to save the file directly to your computer. To load it onto your CNC machine, use one of these methods:

    • USB/Flash Drive: Copy the .nc file to a USB stick and load via the controller's USB port (Haas, Fanuc with USB option).
    • Serial/DNC Transfer: Use DNC software to transfer the file via RS-232 serial connection to older controllers.
    • Ethernet/Network: Many modern controllers support network file transfer via FTP or proprietary software.
    • Direct Paste: For GRBL machines using software like Universal G-Code Sender (UGS), copy the code to clipboard and paste directly into the sender program.
    • SD Card: Common for Mach3/GRBL routers — save the file to an SD card.
  • Yes. The core G-code motion commands — G00 rapid positioning, G01 linear cutting, G02/G03 arc interpolation — are the same across CNC mills, routers, plasma tables, and laser engravers. The key differences are: plasma and laser machines do not use Z-axis depth cutting in the same way (they use torch height/focal distance control), and they use different M-codes for torch/laser on/off (typically M03/M05 or custom M-codes).

    For plasma and laser operations, generate the drilling or slot milling code that matches your cutting path geometry, then manually edit the Z references and add your machine's specific torch-on/torch-off commands. The generated linear and arc motion code (G00, G01, G02, G03, feed rates, and coordinates) will be directly usable.

  • The Work Coordinate System (WCS) defines where X0, Y0, Z0 (part zero / datum) is located on your machine. G54 is the most commonly used work offset register. All coordinates in the generated G-code are relative to this zero point.

    To set G54 on your machine: (1) Physically touch-off your reference point (usually a corner or center of the workpiece) with a tool or edge finder. (2) Go to the machine's Work Offsets page. (3) Record the machine coordinates at that position into the G54 X, Y, Z registers. (4) The generator uses G54 in the program header, so all X/Y/Z moves are automatically relative to your set zero point. G55 through G59 are used for multiple fixtures or setups on the same machine table.

  • The cycle time estimate is a simplified approximation based on total cutting distance divided by feed rate, plus a small overhead per hole for rapid moves and acceleration/deceleration. It does not account for: tool change time, spindle ramp-up time, machine acceleration/deceleration limits, or air-cut distances between separate features.

    For a 6-hole drilling program, the estimate is typically accurate to within ±20–30% of actual machine time. For production planning and quoting, multiply the estimated time by 1.3–1.5 as a safety factor. The estimate improves in accuracy as hole count increases.

Explore More Free CNC Programming & Machining Calculation Tools

This G-Code Generator is part of a complete suite of free online CNC utilities. Use our related tools for bolt circle coordinate calculation, tap drill chart lookup, surface finish conversion, and more.

📧 Never Miss a Great Calculator

Get weekly picks, new releases, and updates straight to your inbox. No spam, ever.

About Me – Muhiuddin Alam

Hello, I am Muhiuddin Alam, Founder and Chief Editor of SteelSolver.com.

With over two decades of experience in engineering, metalworking, and technical content creation, I build precision tools and calculators that help professionals optimize their projects.

What I Do: Structural design calculators, material optimization guides, and practical engineering resources — all free to use.

I consistently contribute to:

Explore our suite of calculators and tools to optimize construction, fabrication, architecture, and industrial projects for engineers, architects, fabricators, and metalworking professionals.

💌 Follow Me: LinkedIn | Google Knowledge Panel

Ready to Optimize Your Projects?

Start using our precision calculators today and experience the difference in accuracy, efficiency, and cost savings.

About – SteelSolver.com

300+ Calculators
100+ Guides
Free To Use

Precision Engineering Tools • Calculators • Expert Guidance

I am Muhiuddin Alam, Founder and Chief Editor of SteelSolver.com. My mission is to provide precision engineering tools, calculators, and expert resources that simplify metalworking, structural design, and industrial applications.

I've built a course-style learning ecosystem — a step-by-step roadmap from steel fundamentals to advanced applications. Each topic builds on the last, covering theory, practical calculations, tool-specific guides, real-world optimization, common mistakes, and cost management.

Every guide and calculator is part of a progressive learning series, taking you from awareness to mastery. With SteelSolver.com, you can save time, reduce waste, optimize materials, and ensure safety, making each project cost-effective, high-quality, and precise.

⚡ Trusted by Engineers Worldwide