Open an SVG file
Create or open an SVG file
Open any
.svg file in your workspace. If you don’t have one, create a new file called icon.svg and paste this code:View the preview panel
The SVG Preview panel automatically appears in the Explorer sidebar when you open an SVG file. You’ll see your icon rendered in real-time.
Explore preview controls
Try these interactive controls in the preview panel:
- Click on the preview to zoom in
- Alt+Click to zoom out
- Alt+Scroll to pan through the graphic
- Toggle background to see your SVG on light, dark, or grid backgrounds
- Change currentColor using the color picker to test different theme colors
Optimize your SVG
Reduce file size with built-in SVGO optimization:Click the optimization button
Look for the ⚡ icon in the editor toolbar (top-right corner) and click it.
Optimization is non-destructive. You can always undo changes with
Cmd+Z / Ctrl+Z.Work with inline SVG
Better SVG works seamlessly with SVG code inside framework components:See gutter previews
Notice the small SVG icon that appears in the gutter (next to the line numbers) where the
<svg> tag starts.Configure settings
Customize Better SVG behavior in VS Code settings:- Open Settings (
Cmd+,/Ctrl+,) - Search for “Better SVG”
- Adjust these common settings:
| Setting | Description | Default |
|---|---|---|
betterSvg.autoReveal | Auto-show preview panel when opening SVG files | true |
betterSvg.enableHover | Enable hover preview for inline SVG | true |
betterSvg.showGutterPreview | Show icons in the gutter | true |
betterSvg.defaultColor | Default color for currentColor | #ffffff |
You’re all set
You now know how to:- ✓ Preview SVG files with interactive controls
- ✓ Optimize SVGs with one click
- ✓ Work with inline SVG in React, Vue, and other frameworks
- ✓ Customize Better SVG settings
Learn about optimization
Deep dive into SVGO optimization features
Framework support
See all supported languages and frameworks