CNC File OptimizerHelp

About & help

CNC File Optimizer is a free tool for making and improving CNC programs: draw a design and get G-code without CAD, turn an STL model into roughing and finishing toolpaths, or optimize G-code you already have. It runs entirely in your browser: no file is ever uploaded, and once the page has loaded it works without a network connection.

Out of the box it is set up for a LUNYEE 3018 Pro Max — an all-metal 3018-class desktop router with a GRBL controller, a 500 W spindle and an ER11 collet for 1/8 in (3.175 mm) bits. Every number in that profile can be changed under Edit machine.

From idea to first cut on a 3018

  1. Make the file. In Create, set the stock size and material, draw or import the shapes, and give each one an operation: Cut out, Cut hole, Pocket, Engrave or Drill. Press Generate G-code and read the safety check. For a 3-D model, drop the STL on the home page instead.
  2. Hold the stock down — properly. A block that is only sitting on the bed will move the moment the bit touches it, and a loose part next to a spinning cutter is how bits break and fingers get hurt. Use the clamps that came with the machine on the threaded bed (keep them outside the frame of the job), or the tape-and-glue method: painter's tape on the bed, painter's tape on the underside of the stock, a thin line of superglue between the two tapes, press for a minute. Put a sacrificial spoilboard (a flat piece of MDF or plywood) under anything you cut all the way through.
  3. Mount the bit. Push it well into the ER11 collet (at least two thirds of the shank), tighten with both wrenches, and leave only as much sticking out as the depth of cut needs.
  4. Set the zero. Every file from this site expects X0 Y0 at the front-left corner of the stock and Z0 on the top of the stock (the red corner on the drawing; the header of each file says it again). Jog the bit over that corner and zero X and Y. For Z, lower the bit onto a piece of paper on the stock until the paper just drags, then zero Z (the paper is about 0.1 mm — close enough for wood). In GRBL terms that is G10 L20 P1 X0 Y0 Z0; every sender has buttons for it.
  5. Run the frame job. Download the frame file and run it first: with the spindle off it traces the outer limits of the cut at the safe height. Watch that the bit stays over the stock and clear of every clamp.
  6. Air cut. For a first run of anything new, zero Z about 10 mm above the stock and run the real file in the air. You will see the whole job at full speed without cutting anything. Then zero Z on the stock top again.
  7. Cut. Safety glasses on, hair and sleeves away, hand near the red E-stop button on the gantry. Start the file and stay with the machine. If it sounds wrong — screaming, chattering, bogging down — pause (feed hold) and reduce the feed override, or stop and take shallower passes.
  8. Changing bits. A 3018 has no tool changer. When a design needs a second bit, you get one file per bit (or, if you prefer, one file that pauses): run the first file, change the bit, set Z0 on the stock top again — the new bit sticks out a different amount — and run the next. Do not touch the X/Y zero.
  9. Free the part. Cut-outs are held by small tabs so they cannot come loose at the last moment. Cut the tabs with a chisel or a flush-cut saw and sand them off.

Sending the file to the machine

All of them talk to GRBL over USB at 115200 baud. The files use only plain GRBL 1.1 codes — G0, G1, G20/G21, G90, G94, G17, G4, M3, M5, M0 and M30 — with no tool changes, canned cycles or tool-length offsets.

Feeds and speeds in one minute

Three numbers decide whether a cut goes well: how fast the bit moves sideways (feed), how deep each pass is, and how fast it spins. A 3018 is light and flexes, so it likes shallow passes at moderate feeds: about half a bit-diameter deep in softwood, a quarter in hardwood such as oak, a tenth or less in aluminum. The starter numbers this site fills in for each material and bit are deliberately conservative starting points, not measurements from your machine — change them freely. Signs you should back off: burning or smoke (feed too slow or bit dull), a rough fuzzy edge or loud chatter (too deep or too fast), the bit visibly bending, lost steps (the cut ends up shifted). Small bits (1 mm, 1.5 mm) snap easily: shallow passes and gentle plunges.

Spindle speed. GRBL turns the S word into spindle power through its $30 setting (“S value at full speed”). The machine profile assumes 10,000 rpm at full speed; if your controller has $30=1000, set Spindle maximum to 1000 in Edit machine so that S1000 means full speed. If the spindle is on a manual speed knob, the S word is ignored — set the knob.

Create mode

Create is a 2-D drawing of your stock seen from above, to scale, plus a list of operations.

How offsets are computed. The bit has a width, so it must run half a diameter beside the line. Instead of shifting each edge (which goes wrong on self-touching outlines, letters with counters and overlapping shapes), the design is turned into an exact distance field on a fine grid and the tool path is the contour where the distance equals the bit radius. Sharp inside corners of the path are blunted by a few hundredths of a millimeter — always away from the part.

The safety check in Create. A second, independent piece of code that shares nothing with the planner goes back to your drawing and measures every sampled tool position against it: profile and pocket cuts never enter material that must stay (limit 0.03 mm), engraving and drilling stay on their lines and points, nothing cuts deeper than asked, every holding tab is really left standing, sideways rapids happen only at the safe height, and the job fits the machine. Then the written file is parsed back and compared with the plan move for move. If any check is red, the download asks you first. What it cannot check is the real world: where the stock actually is, whether it is clamped, whether the bit in the collet is the one in the file.

Fonts. The single-line fonts are the Hershey fonts, originally created by Dr. A. V. Hershey while working at the U. S. National Bureau of Standards; the format of the font data was originally created by James Hurt, Cognition, Inc., 900 Technology Park Drive, Billerica, MA 01821. The outline font is a Latin subset of DejaVu Sans Bold (Bitstream Vera license; DejaVu changes are in the public domain) — see its license.

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-center 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:

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:

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 a size (Shrink to fit my machine scales the model down evenly until it fits the travel), a material and a preset — Standard (1/8 in flat end mill to rough, 1/8 in ball nose to finish), Quick (roughing only) or Fine — and plan. The file card shows the size the model will be cut at and warns when it does not fit. With two bits you get one file per bit, plus the frame job. You get:

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-center 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