lacspace-svg
Optimize, convert & bundle SVGs — zero-dependency.
npx lacspace-svg logo.svg -o logo.min.svgEverything, in one command
lacspace-svg bundles the SVG chores every frontend hits — optimization, framework conversion, inlining and spriting — into one small package with no dependency tree and no upload-your-art web service. A tolerant, hand-written XML/SVG parser underpins a pipeline of lossless optimizations (strip cruft, prune unused ids, round precision, normalize colours), a JSX/React converter with TypeScript and ref forwarding, URL/base64 data-URI encoding, and a sprite builder — all runnable from the CLI, in CI, or as a fully-typed dual ESM/CJS library.
What's inside
Lossless optimizer
Strip comments/metadata/editor cruft, prune unused ids, round precision, normalize colours; reports bytes saved.
SVG → React/JSX
camelCase attrs, style-object, self-closing voids, TypeScript + forwardRef.
Data-URI encoder
URL-encoded (smaller) or base64, optional CSS background-image wrap.
Sprite builder
Combine many SVGs into one <symbol> sheet with a <use> usage snippet.
Safety inspector
Flags <script>, on* handlers and external hrefs without executing them.
Hand-written parser
Tolerant XML/SVG parse + serialize, round-trips real-world files.
Zero deps, offline
File/glob/stdin in, stdout/file out, CI-friendly non-zero exits.
Copy, paste, done
Real commands and snippets — from a one-liner to the typed library.
npx lacspace-svg logo.svg -o logo.min.svgReports before/after bytes and % saved.
npx lacspace-svg optimize "icons/*.svg" --out-dir dist --precision 2Globs + per-file output.
npx lacspace-svg jsx logo.svg --name Logo --ts --refTyped, ref-forwarding React component.
npx lacspace-svg data-uri icon.svg --cssbackground-image:url("…") ready to paste.
npx lacspace-svg sprite "icons/*.svg" -o sprite.svgOne symbol per file + usage snippet.
npx lacspace-svg info suspicious.svgCounts, dimensions, script/handler warnings.
What people build with it
✓ Shrink icon/asset SVGs in a build or CI step
✓ Generate React icon components from designer exports
✓ Inline SVGs into CSS/HTML as data-URIs
✓ Bundle an icon set into one sprite sheet
Run lacspace-svg today
Free, open-source, no API keys. It's a CLI and a typed library.
npx lacspace-svg logo.svg -o logo.min.svg