Kerfwise CNC G-code Generator
Nest parts and get CNC router G-code: compensated profiles, tabs, ramps, drilling cycles, time.
Try an example: Wardrobe side panels with shelf-pin rows (GRBL) · Doors with Ø35 hinge cups (LinuxCNC, G81 cycles) · L-shaped desk top and corner shelves (Fanuc-style)
How it works
Turns a part list into a CNC router program: parts (rectangles, L-shapes, corner cuts, quarter rounds) are nested with a gap of one cutter diameter, then every part gets an outside profile with the tool-radius offset already in the path (arcs around corners), multiple depth passes with a ramped entry, holding tabs or an onion skin, and the cut order small parts first. Holes become drilling cycles (G81, or G83 peck for deep holes) for LinuxCNC / Fanuc-style controls, or expanded moves for GRBL. You get the G-code, a toolpath preview, a DXF per sheet and the estimated machining time.
- Nesting: the kerfwise sheet nesting optimiser (MaxRects) with the kerf set to the cutter diameter, so the slots of neighbouring parts never overlap; the margin to the sheet edge must be ≥ the cutter radius.
- Tool-radius compensation in the path: each outside profile is the part outline offset outward by the radius — straight edges shifted along their outward normal, an arc (G2/G3, centre = part corner) around every convex corner and a line intersection at inside corners of L-shapes. Inner contours are offset inward. The controller runs with G40 (no G41/G42).
- Passes: n = ⌈(thickness + 0.3 mm overcut) / depth per pass⌉, equal steps. Entry ramps down along the first edge (40 mm), the ramp wedge is cleaned at the end of each pass. Tabs: 2–6 per part on the longest edges, raised to 2 mm above the spoilboard in the passes below that height. Onion skin: the last pass stops 0.3 mm above the bottom.
- Climb milling: outside profiles run clockwise, inner contours counter-clockwise (conventional = reversed). Order: drilling (one tool at a time, nearest-neighbour tour), helical bores, inner contours, outside profiles from the smallest part to the largest.
- Drilling: holes go to the drill whose diameter matches (±0.25 mm) — G98 G81 (G83 peck for holes deeper than 3 × Ø) on LinuxCNC/Fanuc, expanded G0/G1 plunges on GRBL. Holes without a matching drill are helically bored with the end mill. Rapids (G0) are only used at or above the clearance height (3 mm) once over the material.
- Time = feed moves ÷ their feed rate + rapids ÷ 10 m/min + 22 s per tool change; acceleration is ignored, so real machines take longer (add 20–40 %).
Simulate every program in your CAM or controller before running it. Check work zero, tool lengths, feeds and speeds for your machine and material. Kerfwise is not responsible for crashes, broken tools or scrapped material.
Sources
- LinuxCNC G-code reference (G0/G1, G2/G3 arcs, G81/G83 drilling cycles, G98/G99, G40/G43) (LinuxCNC)
- Grbl v1.1 commands — supported G-codes (no canned drilling cycles) (gnea/grbl wiki)
- Climb milling vs. conventional milling (Wikipedia)
- A Thousand Ways to Pack the Bin – A Practical Approach to Two-Dimensional Rectangle Bin Packing (J. Jylänki) (GitHub juj/RectangleBinPack)
For scripts and AI agents
- JSON API:
POST https://apps.usefulweb.site/api/v1/tools/kerfwise-cnc-gcode/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://apps.usefulweb.site/mcp· tool namekerfwise_cnc_gcode
Example request
curl -s -X POST https://apps.usefulweb.site/api/v1/tools/kerfwise-cnc-gcode/calculate \
-H 'content-type: application/json' \
-d '{"parts":[{"name":"Side","length":2000,"width":580,"qty":2},{"name":"Shelf","length":764,"width":560,"qty":3}],"holes":[{"part":1,"x":300,"y":37,"diameter":5,"depth":12},{"part":1,"x":332,"y":37,"diameter":5,"depth":12},{"part":1,"x":300,"y":543,"diameter":5,"depth":12},{"part":1,"x":332,"y":543,"diameter":5,"depth":12}],"sheetLength":2800,"sheetWidth":2070,"thickness":18,"dialect":"grbl"}'Related tools
- Kerfwise Sheet Nesting Optimizer – Nest rectangular and shaped parts on sheets: kerf, grain, yield, lower bound, offcuts, SVG + DXF.
- Kerfwise Cut List & Cost – Cabinets or a Kerfwise project → cut list, edge banding, hardware, sheets and costs.
- Kerfwise Cabinet Builder – Parametric cabinet → every part with cut sizes, edge banding, drilling and hardware.