About & help
CNC File Optimizer is a free tool that makes CNC programs smaller, faster and more compatible, and turns STL models into ready-to-run 3-axis toolpaths. It runs entirely in your browser: no file is ever uploaded, and once the page has loaded it works without a network connection.
Optimizing G-code
Drop any G-code file (.nc, .gcode, .tap, .ngc, .cnc, .txt, .mpf …). The file is read by a real modal interpreter — it tracks G0–G3, G90/G91, planes, units, arc-centre modes, canned cycles, cutter compensation, tool offsets and work offsets — so every move has a known start and end point before anything is changed. Then, depending on your settings:
- Arc fitting replaces runs of short straight moves that lie on a circle with one G2/G3 arc, within the tolerance you set. Generated arcs start exactly where the machine is.
- Simplification removes points that move the path by less than the line tolerance (Douglas–Peucker, in 3-D).
- Pass thinning keeps every n-th raster pass of finishing operations to reach a coarser stepover. Roughing and drilling are never thinned.
- Fusion 360 Personal files, which write rapids as G1 at the top feed rate, are detected; the link moves can be turned back into real G0 rapids.
- Retracts can be lowered to a safe height; canned cycles are expanded into plain moves for controllers without G81–G89; unsupported words are adapted for the target; 3D-printer commands are stripped from slicer files; numbers are normalised; a rotary wrap maps a flat axis onto a cylinder.
Moves inside cutter compensation (G41/G42), incremental (G91) sections, canned cycles and unknown syntax are always passed through untouched.
The safety self-check
Every result is re-parsed and compared with the original program before you see it:
- Envelope — the output never moves outside the original program's bounding box.
- Depth — the deepest Z is unchanged.
- Arcs — every generated arc resolves to a valid centre and radius.
- Syntax — the output parses cleanly with no new warnings.
- Path — every cutting vertex and segment midpoint of the output lies within the configured tolerances (plus rounding) of the original cutting path, and — unless passes were deliberately thinned — every original cutting vertex is still on the output path. This is the check that catches a wrong arc or a mis-simplified corner.
If any check fails the download button turns amber and the failing check is explained. Please review such a file before running it — or loosen the settings and run again. As with any CAM output, always dry-run new programs above the stock first.
STL to toolpaths
Drop an STL model (binary or ASCII). Tell the tool which way is up and what units the model uses, choose stock, a roughing tool and a finishing tool, and plan. You get:
- Roughing — Z-level clearing with a flat, bull-nose or ball tool: raster plus a wall pass on every level, ramped entries, and links that climb only as high as the remaining stock requires. Each pocket is cleared completely before the tool moves on.
- Finishing — surface-following parallel passes, waterline contours, or a steep-and-shallow split, with a ball, bull-nose, flat or V tool.
- A gouge check on every move: roughing moves and all rapids are verified over every height-map cell they touch (cells are upper bounds of the surface, so this is a proof, not a sample); parallel finishing is verified by dense sampling against the exact triangle geometry. A path that fails this check is never offered without a warning.
Accuracy. Parallel finishing is computed with an exact drop-cutter against the model's triangles: the path stays within the path tolerance (0.01 mm by default) of the true tool-centre surface, and never below it, on flat, sloped and near-vertical faces alike; it is then verified by dense sampling against the same exact geometry. Roughing, waterline finishing and all linking moves use the conservative height-map bound, so vertical walls there are resolved to about 1.5 × the grid resolution. Use the “Fine” grid for small, detailed parts; “Auto” picks a cell size that keeps planning to a few seconds. Roughing leaves the configured stock for finishing; a warning tells you where the finishing tool has to cut deeper than the roughing terraces (features the roughing tool could not enter).
Supported controllers
The target controller sets comment style, canned-cycle and tool-length-offset support, program end and line numbering:
Presets, privacy, offline
Settings and named presets are stored in your browser only (localStorage); you can export and import them as JSON. The site sets no cookies and loads nothing from third parties. It is a static page — you can save it and run it from a folder.
Tips
- Paste G-code text anywhere on the page to load it without a file.
- In the 3-D preview: drag to orbit, shift-drag or right-drag to pan, wheel to zoom,
Fto fit,1/3/5/7for top/right/front/iso. The Z slider peels the program layer by layer. - Click a line in the text view to highlight that point in the 3-D preview.
- Big files (hundreds of thousands of lines) are fine — everything runs in a background thread and can be cancelled.