How to batch rtl svg icon generation with api and automation scripts
- Step 1Create a mirror manifest — Create a JSON file listing each icon file name and its mirror property (true/false). You can derive this from your icon metadata or use the tool's auto-detect feature which analyses icon shapes to suggest whether mirroring is appropriate.
- Step 2Write the batch script — Read the manifest, filter for mirror: true icons, POST each SVG to the RTL Mirror API endpoint, and write the response to your rtl/ output folder. Use p-limit to cap concurrent requests at 10.
- Step 3Add to your build pipeline — Run the script as a prebuild step: npm run generate-rtl. In CI, cache the rtl/ output folder keyed by a hash of the source icons to avoid regenerating on every push.
Frequently asked questions
How does the auto-detect feature determine if an icon should be mirrored?+
The API analyses path geometry for horizontal asymmetry and checks for directional indicators like arrowheads, triangular path terminations, and slanted strokes. It returns a confidence score (0–1) along with a recommendation. Threshold of 0.7+ is a reliable auto-mirror signal.
Can the script handle SVG sprite sheets as well as individual files?+
Not directly — sprite sheets need to be split first. Use the Sprite Builder tool's extract API to decompose the sheet into individual icons, mirror the directional ones, then rebuild the sprite. This is a two-step pipeline.
What format does the batch API accept for mirror manifests?+
The batch endpoint accepts a multipart form with an icons field (array of SVG strings) and a flags field (array of booleans, one per icon). Icons with flag: true are mirrored; flag: false icons are returned unchanged.
How do I handle icons that need cultural redesign rather than just a mirror?+
Mark those icons as redesign: true in your manifest. The script skips API calls for those and outputs a report listing them as requiring manual design work. This prevents half-baked automated output from shipping.
Privacy first
Every JAD SVG tool runs entirely in your browser using the DOM API and Canvas. Your SVG files never leave your device — verified by zero outbound network requests during processing.