Batch Convert SVG to DXF in Illustrator (Free Script)
Free Adobe Illustrator script that converts a folder of SVG files to DXF for Silhouette Studio, laser cutters, CNC machines and CAD software.
Download illustrator-batch-svg-to-dxf.jsxJavaScript (ExtendScript) · 73 lines · 3 KB · free
Cut-file sellers and makers often need DXF as well as SVG. The free edition of Silhouette Studio opens DXF but not SVG, and many laser cutters, CNC routers and CAD programs prefer it. This script converts a whole folder of SVG files to DXF in one run.
What it does
- Converts every
.svgin one folder to a.dxfwith the same name - Lets you choose a separate folder for the DXF files
- Exports with maximum editability, so shapes stay as paths
- Uses an older, widely supported DXF version
- Carries on if one file fails, and lists any failures at the end
- Never modifies the original SVG files
How to use it
- Run the script in Illustrator (see below).
- Choose the folder that holds your SVG files.
- Choose the folder where the DXF files should be saved.
- Wait for the "finished" message.
How to run an Illustrator script
- Download the script with the button on this page.
- Open Adobe Illustrator. No document needs to be open.
- Go to File > Scripts > Other Script... (Ctrl+F12 on Windows, Cmd+F12 on Mac).
- Choose the downloaded
.jsxfile.
To keep the script in the menu, copy it into Illustrator's Presets > en_US > Scripts folder inside the Illustrator application folder and restart Illustrator. It then appears under File > Scripts.
Illustrator may warn that scripts can change your files. That is normal for any script. This one's full code is shown at the bottom of the page so you can read what it does.
Tips for cut files
- Use filled shapes. DXF stores outlines of shapes. An icon drawn as a thick line exports as its center line only. For icons from this site, convert the solid version.
- Check the size. DXF has no fixed unit, so cutting software may open the design at a different size. Resize after importing.
- Units. The script exports in inches. To use millimetres, open it in a text editor and change
AutoCADUnit.InchestoAutoCADUnit.Millimeters. - Curves. Open one converted file in your cutting software before selling or cutting a batch, to check the curves are smooth.
There is more on cutting icons in how to upload SVG icons to Cricut Design Space.
Questions
Does Cricut need DXF?
No. Cricut Design Space opens SVG directly, which is the better format for it. DXF is mainly for Silhouette Studio Basic Edition, laser and CNC software, and CAD programs.
Does it convert subfolders?
No, only the SVG files directly inside the folder you choose.
Colors are missing after import. Why?
Many cutting and CAD programs ignore fill colors in DXF and show only outlines. The shapes are still there.
The code
This is the complete script. Nothing else is downloaded or installed.
// illustrator-batch-svg-to-dxf.jsx
// Free script from LinearAndLoom Icons: https://linearandloomicons.netlify.app/scripts/
// Provided as is. Try it on a copy of your files first.
/* SVG to DXF - Adobe Illustrator script
------------------------------------------------------------
Converts every .svg file in a folder to a DXF file for cutting machines, laser cutters and CAD software.
HOW TO RUN
Illustrator: File > Scripts > Other Script... > choose this file.
1. Pick the folder that contains the .svg files.
2. Pick the folder where the .dxf files should be saved.
Units are inches. To use millimetres, change AutoCADUnit.Inches to AutoCADUnit.Millimeters below.
Original SVG files are never modified.
*/
#target illustrator
function main() {
var inputFolder = Folder.selectDialog("Select folder with SVG files");
if (!inputFolder) return;
var outputFolder = Folder.selectDialog("Select folder to save DXF files");
if (!outputFolder) return;
var svgFiles = inputFolder.getFiles(function (file) {
return file instanceof File && file.name.match(/\.svg$/i);
});
if (svgFiles.length === 0) {
alert("No SVG files found.");
return;
}
var previousLevel = app.userInteractionLevel;
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var done = 0, failed = [];
for (var i = 0; i < svgFiles.length; i++) {
var file = svgFiles[i];
var doc = null;
try {
doc = app.open(file);
// Export as DXF
var dxfFile = new File(outputFolder + "/" + file.name.replace(/\.svg$/i, ".dxf"));
var dxfOptions = new ExportOptionsAutoCAD();
dxfOptions.exportFileFormat = AutoCADExportFileFormat.DXF;
dxfOptions.version = AutoCADCompatibility.AutoCADRelease18; // widely compatible; use AutoCADRelease24 for newest
dxfOptions.unit = AutoCADUnit.Inches; // change to Millimeters if that's your unit
dxfOptions.exportOption = AutoCADExportOption.MaximumEditability;
dxfOptions.convertTextToOutlines = false; // no text in these files
dxfOptions.colors = AutoCADColors.TrueColors;
dxfOptions.rasterFormat = AutoCADRasterFormat.PNG;
doc.exportFile(dxfFile, ExportType.AUTOCAD, dxfOptions);
doc.close(SaveOptions.DONOTSAVECHANGES);
done++;
} catch (e) {
// one bad file must not stop the rest
failed.push(decodeURI(file.name) + " (" + e + ")");
try { if (doc) { doc.close(SaveOptions.DONOTSAVECHANGES); } } catch (e2) {}
}
}
app.userInteractionLevel = previousLevel;
var msg = "SVG to DXF - finished\n\nConverted: " + done;
if (failed.length) { msg += "\n\nCould not convert " + failed.length + ":\n" + failed.slice(0, 15).join("\n"); }
alert(msg);
}
main();
Download illustrator-batch-svg-to-dxf.jsxJavaScript (ExtendScript) · 73 lines · 3 KB · free
These scripts are free. If one saved you time, you can say thanks by buying a pack from the LinearAndLoom Etsy shop.


