A command-line tool to convert scalable vector graphics (SVG) files into stereo-lithography (STL) files for 3D printing. Originally created to enable the 3D printing of plates for a printing press from 2D vector graphics.
git clone git@github.com:dfosco/svg-to-stl-cli.git
cd svg-to-stl-cli
npm installTo use svg-stl from anywhere on your machine, install it globally:
cd svg-to-stl-cli
npm install -g .This registers the svg-stl command in your PATH. You can then run it from any directory:
svg-stl <input.svg> [options]To uninstall the global command later:
npm uninstall -g svg-to-stl-clisvg-stl <input.svg> [options]Or, without global install, from the project directory:
npm run svg-stl -- <input.svg> [options]| Option | Description | Default |
|---|---|---|
-o, --output <path> |
Output STL file path | Input filename with .stl extension |
--type-size <mm> |
Image size in mm | 60 |
--type-depth <mm> |
Depth of type in mm | 3 |
--invert-type |
Invert type | false |
--flare-type |
Flare type (bevel) | false |
--reverse-winding-order |
Reverse winding order | false |
--base-plate |
Enable rectangular base plate | (no base plate) |
--base-plate-circle |
Enable circular base plate | (no base plate) |
--base-depth <mm> |
Depth of base in mm | 5 |
--buffer <mm> |
Buffer around the image in mm | 5 |
--color <hex> |
Color for rendering (hex format) | #5d9dea |
Basic conversion:
svg-stl example-svg/Entypo/star.svgWith custom output and size:
svg-stl example-svg/Entypo/star.svg -o star_large.stl --type-size 100With rectangular base plate:
svg-stl example-svg/Entypo/star.svg --base-plateWith circular base plate:
svg-stl example-svg/Entypo/star.svg --base-plate-circleThere are example SVG files in example-svg/Entypo.
- Specifying type height
- Including indented/recessed type
- Rendering with and without a base plate
- Round and Rectangular base plates supported
- Specifying base plate height
- Optionally inverting type for printing press use
- Optionally flaring the base of type for added strength
- Reversing the winding order (CW/CCW) of SVG paths for incorrectly-built SVG files
- The base plate and type are output as separate meshes rather than using CSG (Constructive Solid Geometry) operations to merge them. For most 3D printing purposes, this is functionally equivalent, but slicers will process them separately.
- A hole in an SVG path should be defined by points in counter-clockwise order, where the shape outline is defined by points in a clockwise order, or vice versa. Some SVG creation tools don't do this correctly, and shapes render in 3D space as "inside out".
- You can try the
--reverse-winding-orderoption to fix this, but it's possible to have both combinations of winding in the same file, ensuring that some part is always inside out.
- You can try the
- A hole that is not a hole, but an additional shape filled with background color will not render as a hole.
- SVG text elements are not supported. To render text, you need to convert the text to "outlines" or "paths" before saving the SVG file.
For now tested on MacOS, but if you try on Linux or Windows WSL and something breaks, open an issue!
- three.js - For 3D geometry creation and rendering
- jsdom - For SVG parsing in Node.js environment
- commander - For CLI argument parsing
Props to @rcalme who open sourced https://github.com/rcalme/svg-to-stl eleven years ago and made creating this CLI a breeze 🙇♂️