Exporting Icons
The icon:export command extracts icons from a downloaded JSON collection and writes them as standalone SVG files. This is useful for designers who work in tools like Figma or Illustrator, for projects that need static SVG assets, or for cherry-picking a small subset of icons to commit to your repository.
Quick start
Section titled “Quick start”# Export specific iconsphp vendor/bin/swarm-icons icon:export tabler home star arrow-left
# Export an entire setphp vendor/bin/swarm-icons icon:export mdi --all
# Export to a custom directoryphp vendor/bin/swarm-icons icon:export tabler home user --dest=./assets/iconsArguments
Section titled “Arguments”| Argument | Required | Description |
|---|---|---|
prefix | Yes | Icon set prefix (e.g., tabler, mdi) |
icons | No | One or more icon names to export |
You must provide either specific icon names or the --all flag.
Options
Section titled “Options”| Option | Short | Description | Default |
|---|---|---|---|
--all | Export every icon (and alias) in the set | false | |
--dest | -d | Output directory for SVG files | ./export/{prefix}/ |
--overwrite | Overwrite existing SVG files | false | |
--json | Path to a JSON collection file | auto-detected from resources/json/ |
How it works
Section titled “How it works”- The command loads the JSON collection file for the given prefix (auto-detected from
resources/json/{prefix}.jsonor specified with--json). - It resolves each requested icon, including aliases. An alias like
housethat points tohomeproduces its ownhouse.svgfile with the resolved SVG content. - Each icon is rendered as a complete SVG element with
xmlns="http://www.w3.org/2000/svg"so the file works in any context (design tools, image viewers, browsers, etc.). - Files are written to the output directory with a progress bar for large sets.
Examples
Section titled “Examples”Export a handful of icons for a project
Section titled “Export a handful of icons for a project”php vendor/bin/swarm-icons icon:export heroicons home user cog bell --dest=./resources/iconsThis creates four SVG files in ./resources/icons/:
resources/icons/ home.svg user.svg cog.svg bell.svgExport an entire set for a design team
Section titled “Export an entire set for a design team”php vendor/bin/swarm-icons icon:export tabler --all --dest=./design/tabler-iconsExport from a custom JSON file
Section titled “Export from a custom JSON file”If the JSON file is not in the default resources/json/ location:
php vendor/bin/swarm-icons icon:export custom --all --json=/path/to/my-icons.json --dest=./outputRe-export with overwrite
Section titled “Re-export with overwrite”By default, existing files are skipped. Use --overwrite to replace them:
php vendor/bin/swarm-icons icon:export tabler home star --dest=./icons --overwriteThe summary output shows how many icons were exported, skipped, or failed:
[OK] 2 exported in ./iconsSkipping and overwrite behavior
Section titled “Skipping and overwrite behavior”Without --overwrite, the command skips any icon whose .svg file already exists in the output directory. The summary tells you how many were skipped:
[OK] 5 exported, 3 skipped (existing) in ./export/tablerThis makes it safe to re-run the command after adding new icon names to your list without losing any manual edits to previously exported files.