MIDILLI G-Code Generator
A free and versatile command-line tool for creating G-Codes files to prepare box-shaped parts using CNC Routers.
- Introduction
- Features
- How does it work?
- Download
- Version History
- Quick Usage
- Coordinate system and effects of sizing parameters
- Command line arguments
- JSON File
- Additional Resources
Introduction
MIDILLI G-Code Generator is a free and versatile command-line tool for creating G-Codes files to prepare box-shaped parts. It supports circular drill holes, rectangular cutouts, and precise dimensions in metric units. The generated G-code files are compatible with CNC routers supporting GRBL, ensuring seamless design preparation.
Slightly changed version of the example project, with screws, screw heads, recesses, and component rotations.
Derived from the in-house MIDILLI Tech Automation Suite, this tool is a simplified yet robust solution.
It is offered free for non-commercial use. You can find the full license details here.
Warning: Operating CNC routers requires a safe environment to prevent exposure to dust, debris, and high-speed moving parts. Never place your hands near moving parts. Always ensure proper ventilation, wear safety goggles, and use hearing protection. Additionally, perform a simulation to ensure the final G-code does not attempt to drill or move into restricted and/or dangerous sections.
Please choose a topic from left to read.
Features
- Box Creation:
- Generate rectangular shapes with up to six sides to form a complete box structures.
- Option to omit any side during box design.
- Option to use the sizing for the inner volume or the outer volume.
- Customizable Cutouts:
- Create holes or rectangular cutouts (also called components) on specific sides of the box with precise locations.
- Create screw holes on top or bottom* side with the given screw diameter.
- Component Rotation:
- Rotate components to any specified angle.
- Recess Support:
- Create flush surfaces with custom dimensions that prevent movement of e.g., button caps and improve functionality.
- Create recesses for screw heads*.
- Bit Diameter Compensation:
- Compensate the bit diameter to create exactly the specified drill holes/cutouts.
- Straight and V-shaped bits are supported.
- Feedrate:
- Set feedrate for movement on axes.
- Layered Outputs:
- Separate component, recess, outline layers' outputs to only perform a single step at a time.
- Material Thickness:
- Adjust material thickness for accurate cuts and fits.
- Box Sizing:
- Automatically adjust box sizes for inner or outer edges, depending on user preference.
* Using recess for screws on bottom side requires manual flipping of the surface.
How does it work?
The tool takes a JSON file as input (example below) and generates G-Codes for up to six sides of a box, with each side containing its own drill cutouts, recesses, and engravings. These pieces can then be assembled to construct a 3D shape.
The exported .nc files must be sent/executed with a G-Code sender e.g., Candle (free and open-source) to complete the task.
Download
By downloading our free software, you agree to the license conditions.
Download (Windows, Linux, macOS)
Version History
- 1.4.0 (27.08.2026):
- Added finger joint support with
--finger-jointand per-side--no-finger-*options. - Fixed finger joint default behavior and effective settings display.
- Fixed outline profile closure loop (final edge now returns to start point).
- Aligned through-hole positions with recess offsets on Back/Front/Left/Right panels.
- Added finger joint support with
- 1.3.0 (05.11.2025):
- Now available for Windows, Linux, and macOS as well.
box-height-3d,material-thicknessandouter-sizingarguments can be also used in JSON (can be overridden via command-line argument)
- 1.2.2 (01.04.2025):
- Minor bug fixes.
- 1.2.1 (08.02.2025):
- Replaced
heightwithlengthin JSON to avoid confusion.
- Replaced
- 1.2.0 (06.02.2025):
- V-shaped endmill type added for automatic compensation.
- 1.1.0 (26.01.2025):
- Separation of feedrate for x-, y-, and z-axes for more control on speeds.
- Removed common
--feedrateargument.
- Removed common
- Minor bug fixes.
- Separation of feedrate for x-, y-, and z-axes for more control on speeds.
- 1.0.0 (22.01.2025):
- Initial version.
Quick Usage
Introduction
the ZIP file and extract to a location. Copy the Example JSON file below and save it as test.json using a simple text editor. To keep the things simple, save it at the same location as the executable.
To create your own JSON file, use our online visual box designer, or JSON Creator or refer to MIDILLI JSON Definition document to create your own from scratch.
Example JSON file
The following file generates all six sides for MyPart, placing one hole and one rectangle cutout on the Top side. The top size of the box is 5x5 cm and the components are placed at (x = 1, y = 1) and (x = 3, y = 3) respectively. The visible sizes of the components are the same as drill sizes.
{
"Generic": {
"width": 5.0,
"length": 5.0
},
"MyPart_Top": {
"myRoundComponent#1": {
"location_x": 1,
"location_y": 1,
"drill_diameter": 1,
"call_name": "Hello",
"visible_diameter": 1,
"rotation": 0
},
"myRectangleComponent#1": {
"location_x": 3,
"location_y": 3,
"drill_width": 2,
"drill_length": 1,
"call_name": "MIDILLI",
"visible_width" : 2,
"visible_length" : 1,
"rotation": 0
}
},
"MyPart_Bottom": {
},
"MyPart_Back": {
},
"MyPart_Front": {
},
"MyPart_Left": {
},
"MyPart_Right": {
}
}
Depending on the command-line options, the other sides of the part will be created using different sizing. Read Coordinate system and effect of sizing parameters for more on different results of the arguments.
Note: JSON syntax is very strict. Ensure that the last line before each '}' does not end with a comma, while all other lines should. Use an online validation tool to confirm correctness.
Note: Use dot (.) if working with decimal numbers to separate the integer part.
Command line
Assuming that the JSON file is stored at the same location as the executable file, open a command window (Command Prompt, or PowerShell), then execute the following command:
.\GCodeGenerator.exe --json-file .\test.json --output-directory . --material-thickness 3 --cut-depth-per-pass 1 --box-height-3d 30
You will be provided with an output showing the current settings as following:
~~~~~ Settings ~~~~~
Outer sizing enabled: No
Finger joints: No
Finger size: 3 mm (default: material thickness)
Finger count: Automatic
Finger clearance: 0 mm
Components enabled: Yes
Side outline enabled: Yes
Screw diameter top in mm: 0
Screw diameter bottom in mm: 0
Screw head diameter in mm: 0
Screw head height in mm: 0
Screw extra margin in mm: 0
Recess depth in mm: 0
Feedrate on X-axis: 200
Feedrate on Y-axis: 200
Feedrate on Z-axis: 100
Bit shape: straight
Bit diameter in mm: 0
Material thickness in mm: 3
Depth per pass in mm: 1
Box height in 3D in mm: 30
Cut depth per pass in mm: 1
Simulation enabled: No
Each setting on the console output can be customized with command line arguments.
Note: Use dot (.) if working with decimal numbers to separate the integer part.
After completion, 6 files starting with MyPart_ and ending with .nc will be visible under test directory. Opening MyPart_Top.nc in a program which can parse G-Codes should display a view similar to the following:
Execution of the G-Code will move at 200 feedrate and drill 1 millimeter (mm) at each pass at 100 feedrate to open the holes for the components of a material with the thickness of 3 mm. At the end, it will cut along the outline of the Top to separate it from the larger material. For more customization, read the Detailed usage section.
Hint
Tip: If you want the overall size to be exactly as you specify in the JSON file, use the --outer-sizing option. If you want the usable inner area to be the same as you define, leave it as default.
Coordinate system and effects of sizing parameters
Read more on the following page: Understanding 2D Coordinate Systems in MIDILLI Tools
Command line arguments
Introduction
If the program is executed with -h or --help option, the following quick help will be displayed:
Usage:
GCodeGenerator.exe [OPTION...]
-j, --json-file arg Project JSON file
-o, --output-directory arg Output folder
-t, --material-thickness arg Material thickness to cut in mm (default:
0)
-b, --box-height-3d arg Box height in 3D in mm (default: 0)
-d, --cut-depth-per-pass arg Depth per pass to cut in mm
-p, --bit-shape arg Bit shape for drill size compensation:
straight, or v-shaped (default: straight)
-m, --bit-diameter arg Bit diameter in mm for drill size
compensation (default: 0.01)
-k, --bit-angle arg Bit angle in degrees for v-shaped bits for
drill size compensation (default: 0)
-f, --bit-cutter-height arg Bit cutter height in mm at which the
maximum diameter is reached (default: 0)
-g, --outer-sizing Box sizes are for outside borders (inner
area will be smaller)
--finger-joint Add finger joints (box joints) to all 6 sides
so panels can be assembled without glue.
When enabled all 6 sides default on; use
--no-finger-<side> to disable a specific side
--finger-size arg Finger width in mm (0 = material thickness)
(default: 0)
--finger-count arg Number of fingers on an edge (0 = automatic
from finger size) (default: 0)
--finger-clearance arg Extra clearance added to finger slots in mm
(default: 0)
--no-finger-top Disable finger joints on the Top panel
--no-finger-bottom Disable finger joints on the Bottom panel
--no-finger-front Disable finger joints on the Front panel
--no-finger-back Disable finger joints on the Back panel
--no-finger-left Disable finger joints on the Left panel
--no-finger-right Disable finger joints on the Right panel
-r, --recess-depth arg The depth of recess in mm (0 = no recess)
(default: 0)
-x, --feedrate-x arg Feedrate to use for x-axis (default: 200)
-y, --feedrate-y arg Feedrate to use for y-axis (default: 200)
-z, --feedrate-z arg Feedrate to use for z-axis (default: 100)
-l, --outline Enable side outline cutting (default: true)
-c, --components Enable component cutting (default: true)
-e, --screw-size-top arg Screw diameter for top side in mm (0 = no
screws) (default: 0)
-w, --screw-size-bottom arg Screw diameter for bottom side in mm (0 =
no screws) (default: 0)
-i, --screw-head-diameter arg
Screw head diameter in mm (default: 0)
-a, --screw-head-height arg Screw head height in mm (default: 0)
-n, --screw-extra-margin arg Screw extra margin in mm (default: 0)
-s, --simulate Simulate, do not write NCs
-h, --help Show this help message and quit
Both short and long versions of the arguments can be used.
The arguments --json-file, --output-directory, --cut-depth-pas-pass, --material-thickness, and --box-height-3d are mandatory. The last two arguments can also be given in the JSON file. If both JSON and the command-line has these arguments, the command line values will be used. . Other arguments have default values as mentioned above. To set an argument to false, use the long version and assign the value false. For example, to disable outline cut, use --outline=false. Similarly, for activation of options, which are disabled by default, only use the argument. For example, to enable simulation, use either -s or --simulate. Argument values can be provided with a space or an equal sign if long versions are used. For instance, both --json-file test.json and --json-file=test.json are valid usage. For short versions, only space allowed, e.g., -b 30.
--json-file
A valid path to JSON file to be used as input. Can be a relative path (starting from the working directory) or an absolute path. You can use online visual box designer, JSON Creator or refer to MIDILLI JSON Definition document if you need help.
--output-directory
The directory to write the output files to. Using . (dot) will use the current working directory. The final files will be written into a new folder having the name of the --json-file.
--material-thickness
This value is used to calculate the depth required for creating holes for components and/or screws, in conjunction with the --cut-depth-per-pass argument. The value is in millimeters (mm).
Additionally, this value is used to determine the dimensions of the left, right, front, and bottom sides (if enabled) based on whether the --outer-sizing parameter is active. See Coordinate system and effects of sizing parameters for more info.
This value is mandatory.
It can be given in the JSON (under Generic, as value "material_thickness") as well as in the command line. Command line will override the value if provided.
--box-height-3d
The height of the box in millimeters (mm). If --outer-sizing is used, this will be the outer height of the box. Otherwise, it is the inner height of the box.
This value is mandatory.
It can be given in the JSON (under Generic, as value "box_height_3d") as well as in the command line. Command line will override the value if provided.
--bit-shape
The shape of the endmill/bit/cutter. Currently straight and v-shaped cutters are supported. Read this page to learn more about the effect of this parameter.
Default: straight
--bit-diameter
The diameter of the bit or cutter can affect not only the size of drilled holes but also the overall dimensions of the cuts. This may result in slightly larger or smaller dimensions than intended. G-Code already supports compensation for cutter diameter using specific commands. This argument adjusts the coordinates to account for the bit diameter, ensuring accurate cuts and dimensions in case native compensation is not desired. Read this page to learn more about the effect of this parameter.
Default: 0, no compensation
--bit-angle
Angle in degrees which forms the v-shape. Only effective for v-shaped bits. Read this page to learn more about the effect of this parameter.
Default: 0, straight cutter
--bit-cutter-height
The height of the cutter in mm at which it reaches its maximum cut width. After this height (or after reaching this depth), always --bit-diameter value will be used. Only effective for v-shaped bits. Note that this is not the total height of the bit itself.
Read this page to learn more about the effect of this parameter.
Default: 0, straight cutter, starting directly with --bit-diameter width.
--outer-sizing
If used, the sizes defined in the JSON file as well as the --material-thickness and --box-height-3d arguments will be used to create the outer volume with the given dimensions. Otherwise, these values will be used to create the inner volume with the given dimensions.
The value can be given in the JSON (under Generic, as value "outer_sizing") as well as in the command line. Command line will override the value if provided.
Default: false, use inner dimensions.
--recess-depth
The depth of the recess for components in millimeters (mm).
Recesses also take the sizing from visible_diameter (priority) or visible_width and visible_height properties. Recesses may be helpful to have slightly lowered shapes to e.g., stabilize or limit the movement of button caps. This value does not change the behavior of the screw head recess (See --screw-head-height).
Default: 0 mm, no recess for the components
Recesses also take the sizing from visible_diameter (priority) or visible_width and visible_height properties. Recesses may be helpful to have slightly lowered shapes to e.g., stabilize or limit the movement of button caps. This value does not change the behavior of the screw head recess (See --screw-head-height).
Default: 0 mm, no recess for the components
--feedrate-x
The speed at which the tool moves during cutting or engraving on x-axis, measured in units per minute (e.g., millimeters per minute). This value is crucial for controlling the precision and quality of the cut, with higher feedrates generally resulting in faster cuts but potentially lower accuracy or finish quality.
Default: 200
--feedrate-y
The speed at which the tool moves during cutting or engraving on y-axis, measured in units per minute (e.g., millimeters per minute). This value is crucial for controlling the precision and quality of the cut, with higher feedrates generally resulting in faster cuts but potentially lower accuracy or finish quality.
Default: 200
--feedrate-z
The speed at which the tool moves during cutting or engraving on z-axis, measured in units per minute (e.g., millimeters per minute). This value is crucial for controlling the precision and quality of the cut, with higher feedrates generally resulting in faster cuts but potentially lower accuracy or finish quality.
Default: 100
--outline
Enables side outline cuts, which adjust the dimensions of the sides according to the given sizes, based on the --outer-sizing property.
Default: true
--components
Enables the component output to cut circles and/or rectangular shapes through the --material-thickness.
Default: true
--screw-size-top
Screw hole diameter to be drawn as hole in millimeters (mm) on the top side of the box.
Default: 0 mm, no screws.
--screw-size-bottom
Screw hole diameter to be drawn as hole in millimeters (mm) on the bottom side of the box.
Default: 0 mm, no screws.
--screw-head-diameter
If the screws must be counterbore/recessed, any value given in millimeters (mm) (preferably greater than --screw-size-top or --screw-size-bottom) will create a circular shape to bury the head.
Default: 0 mm, protruding screw head.
--screw-head-height
The depth of the screw-head to create counterbore/recessed screws given in millimeters (mm).
Default: 0 mm, protruding screw head.
The images below show how --screw-head-diameter and --screw-head-height affect the creation of screw head related recesses.
--screw-extra-margin
By default, screws are added at the four corners of the top and/or bottom side of the box, leaving a margin of --material-thickness from the sides. If an additional margin is desired, any value given in millimeters (mm) will increase this gap.
Default: 0 mm, no additional margin.
--finger-joint
Enables finger joints (box joints) on all 6 sides of the box so panels can be assembled without glue. By default, all 6 sides are enabled. To disable finger joints on specific sides, use the `--no-finger-<side>` arguments.
Default: false, no finger joints.
--finger-size
The width of each finger in millimeters (mm). If set to 0, the `--material-thickness` value will be used as the finger width.
Default: 0 mm (uses material thickness).
--finger-count
The number of fingers on an edge. If set to 0, the number of fingers will be calculated automatically based on the `--finger-size` value and the panel dimensions.
Default: 0 (automatic).
--finger-clearance
Extra clearance added to finger slots in millimeters (mm) to ensure smooth assembly.
Default: 0 mm.
--no-finger-*
Disable finger joints per side.
When --finger-joint is enabled, all 6 sides have finger joints by default. Use the following arguments to disable finger joints on specific sides:
--no-finger-top— Disables finger joints on the Top panel--no-finger-bottom— Disables finger joints on the Bottom panel--no-finger-front— Disables finger joints on the Front panel--no-finger-back— Disables finger joints on the Back panel--no-finger-left— Disables finger joints on the Left panel--no-finger-right— Disables finger joints on the Right panel
--simulate
If used, simulates the settings, without writing to actual files.
Default: false, write to actual files.
--help
Shows the quick help with the list of arguments and their short descriptions.
JSON File
See the definition on this page: MIDILLI JSON File Definition.