Browser-Local · SVG ↔ JSX, HTML & CSS
Free SVG to Code & Code to SVG Converter
Drop an .svg file or paste vector XML to generate typed React TSX, plain JSX, sanitized inline HTML, and compact CSS Data URIs—or switch to Code → SVG to extract a clean .svg file from React components and CSS snippets. Zero credits, zero uploads.
SVG to Code — React JSX/TSX, clean HTML & CSS
Paste raw <svg> markup or drop a .svg file up to 2 MB to generate four clean outputs side by side: typed React TSX, plain React JSX, sanitized inline HTML, and a compact CSS Data URI. Every conversion runs optimizeSvg first with 2-decimal coordinate rounding to strip comments, editor bloat, scripts, and unsafe event handlers before formatting your code.
SVG → typed React TSX / JSX component
Generate a ready-to-paste React component in TypeScript (SVGProps<SVGSVGElement>) or plain JavaScript. The converter turns kebab-case attributes like stroke-width, fill-rule, and clip-path into camelCase props, converts inline style strings into JSX style objects, adds {...props} forwarding on the root <svg>, and lets you set the component name or swap fills and strokes to currentColor.
SVG → clean inline HTML
Export normalized <svg> XML ready to paste directly into HTML templates or Figma. Before output, the pipeline removes XML prologs, DOCTYPE declarations, metadata, comments, <script> and <foreignObject> tags, and inline on* event handlers while ensuring xmlns, viewBox, and numeric width and height attributes stay intact on the root element.
SVG → CSS Data URI
Turn any clean <svg> into a .icon-vector CSS rule using background-image: url("data:image/svg+xml,..."). Instead of Base64 bloat, the encoder applies minimal UTF-8 percent-encoding—escaping only %, #, <, >, and braces and replacing double quotes with single quotes—so CSS stylesheets stay readable, smaller, and easier to compress.
Code to SVG — paste JSX or CSS, get a .svg file
Switch to Code → SVG to recover a standalone .svg file from an existing React JSX or TSX component, a CSS data:image/svg+xml Data URI (including base64-encoded rules), or an HTML snippet containing <svg>. The parser removes JSX comments and {...props} spreads, restores kebab-case SVG attributes, runs XSS sanitization, and lets you preview or download the .svg.
How to convert SVG to code in 3 steps
First, pick SVG → Code or Code → SVG and paste markup, drop a .svg, .tsx, .jsx, .html, or .css file, or load a sample preset. Second, set a React component name, toggle currentColor, and switch among the React TSX, React JSX, Clean HTML, and CSS Data URI tabs. Third, inspect the isolated <img> preview, copy the output, or download the file.
100% browser-local: 0 credits, no sign-in
Both conversion directions and the live <img> preview run purely in browser memory via Blob URLs—never via dangerouslySetInnerHTML or innerHTML—and no files are uploaded to a server. You spend 0 credits and need no account. Credits are only used if you scroll below to run the optional AI SVG generator.
Create your SVG vector
1Vector prompt
Keep prompts concise: name the subject, geometry style, and 2–4 flat colors. 1 generation = 1 credit.
2Vector style preset
3Output quality & aspect
3 free credits on sign-up · 1 credit/SVG · Auto-refund on failed renders · packs from $5.99
Direct .svg download
Direct .svg download
Direct .svg download
Prompt preset: “24x24 monoline cloud deploy rocket UI icon with uniform stroke weight”
Example SVG files you can inspect and edit. Simple marks are 0.6–1.2 KB; the detailed corgi sticker is 9.5 KB. Output sizes vary by design.
Why use Free SVG to Code & Code to SVG Converter
Typed React TSX, JSX & currentColor ready
Automatically converts kebab-case SVG attributes (stroke-width, fill-rule, clip-path) and inline styles into React camelCase props, adds {...props}, and optionally swaps fills/strokes to currentColor.
Reverse Code → SVG extraction
Paste a React .tsx/.jsx icon component or CSS background-image: url("data:image/svg+xml,...") rule and recover a clean, Figma-ready .svg file in one click.
Compact UTF-8 CSS Data URIs & XSS safety
Outputs minimal percent-encoded data:image/svg+xml URIs (25%–30% smaller than Base64) while stripping <script>, <foreignObject>, and inline on* handlers locally.
SVG to JSX & React Component
Pasting raw <svg> XML straight into React triggers two classic errors: kebab-case attributes like stroke-width and fill-rule produce console warnings or silent drops, and an inline style="stroke-width:2" string crashes React at runtime because JSX expects an object. Our converter rewrites every SVG attribute to camelCase, converts style strings into JSX objects, removes XML prologs, and forwards {...props} cleanly.
Breaks in React JSX (raw XML)
<svg class="icon" stroke-width="2" style="color:#0f172a"><path fill-rule="evenodd" d="M4 12h16"/></svg>Valid React TSX output
<svg className="icon" strokeWidth="2" style={{ color: '#0f172a' }} {...props}><path fillRule="evenodd" d="M4 12h16" /></svg>SVG to CSS Data URI
The most common CSS Data URI bug is leaving a raw # hex color inside url("data:image/svg+xml,..."). Browsers treat the first # as a URL fragment identifier and silently truncate the rest of your SVG, leaving an empty box. Escaping # to %23 (plus <, >, and braces) and swapping double quotes to single quotes keeps your icon working across browsers while staying 25%–30% smaller than Base64.
Silently truncated (# starts a URL fragment)
background-image: url("data:image/svg+xml,<svg viewBox='0 0 24 24'><circle cx='12' cy='12' r='8' fill='#0F172A'/></svg>");Working UTF-8 Data URI (%23 + escaped brackets)
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8' fill='%230F172A'/%3E%3C/svg%3E");Explore More Vector Tools
Specialized workflows in GPTSVG Studio
Text to SVG
Text to SVG Generator — Clean SVG Code from a Prompt
Turn a prompt into editable SVG paths. Recolor your vector, copy React JSX, or open it in Figma. Try 3 free AI credits on verified sign-up.
Logo SVG
SVG Logo Generator — Editable AI Vector Logos
Free SVG logo generator that outputs real editable <svg> paths for Figma in seconds. 3 free credits on sign-up, no card required, no subscription.
Icon SVG
AI SVG Icon Generator — 24×24 Monoline Icon Sets
Generate a single AI icon SVG or cohesive 24×24 monoline sets with uniform 2px strokes. Copy raw <svg> or React JSX — 1 credit each, 3 free on sign-up.
Image to SVG
Free Image to SVG Converter (PNG, JPG & WebP)
Convert any image to SVG free in your browser — PNG, JPG to SVG & WebP to SVG tracing, 0 credits, no sign-in, stays local. Or AI redraw in 1 credit.
Sticker SVG
AI Sticker Maker — Transparent SVG Stickers for Merch & Chat
Design die-cut mascot stickers as true transparent SVG paths with an AI sticker maker. Export SVG or 4096px PNG. 1 credit each, 3 free to start.
Laser SVG
Laser Cut SVG & SVG for Laser Cutting — Closed Paths, No Bitmaps
Generate laser cut SVG files with closed paths and no embedded bitmaps — plus a full SVG for laser cutting guide for Glowforge, xTool, LightBurn and CNC.
SVG Optimizer
Free SVG Optimizer & Minifier
Minify and clean SVG files free in your browser. Strip Inkscape metadata, round path decimals, remove XSS tags, and preview before/after <svg> savings.
SVG Path Editor
SVG Path Editor – Edit Path Data in Your Browser
Edit SVG path data in your browser: drag control points, switch M/L/C/Q/Z commands, copy the d attribute. 0 credits, no login, fully local.
Transparent Pricing
Pay once, credits never expire
1 credit = 1 native AI SVG or vector redraw — $0.20/SVG on Starter ($5.99/30), $0.15/SVG on Creator ($14.99/100), or $0.12/SVG on Studio ($34.99/300). One-time packs, never expire.
Starter
30 native SVGs or AI vector redraws (~$0.20/SVG)
$5.99
30 credits
30 native SVG vectors (1 credit each)
- Pack credits never expire
- Native <svg> XML + 1K–4K PNG export
- All 8 logo, icon & sticker presets
- Automatic credit refund on failed jobs
Creator
100 native SVGs or AI vector redraws (~$0.15/SVG)
$14.99
100 credits
100 native SVG vectors (1 credit each)
- Pack credits never expire
- Native <svg> XML + 1K–4K PNG export
- All 8 logo, icon & sticker presets
- Automatic credit refund on failed jobs
Studio
300 native SVGs or AI vector redraws (~$0.12/SVG)
$34.99
300 credits
300 native SVG vectors (1 credit each)
- Pack credits never expire
- Native <svg> XML + 1K–4K PNG export
- All 8 logo, icon & sticker presets
- Automatic credit refund on failed jobs
Verified new accounts receive 3 free credits (no card required, one-time per email/IP). Unused pack credits stay in your balance indefinitely, and failed AI runs refund automatically. Prices in USD.
Free SVG to Code & Code to SVG Converter FAQ
Is this SVG to code and code to SVG converter completely free?
Yes. Both SVG → Code and Code → SVG conversions run 100% locally in your browser for 0 credits, with no sign-in required and zero server uploads.
What changes when converting SVG XML to React JSX or TSX?
React requires camelCase attribute names (such as strokeWidth, strokeLinecap, fillRule, and className instead of class), object syntax for inline style attributes, and no XML prologs or DOCTYPE declarations. Our converter handles all of these automatically and wraps the markup in a reusable component.
How does the Code to SVG mode extract an .svg file from JSX or CSS?
Switch to Code → SVG and paste a React icon component, an HTML snippet, or a CSS data:image/svg+xml rule (URL-encoded or Base64). The parser strips JSX spreads ({...props}), restores kebab-case XML attributes, adds xmlns/viewBox metadata, sanitizes unsafe tags, and lets you download the .svg file.
Why use a UTF-8 percent-encoded CSS Data URI instead of Base64?
Base64 encoding inflates SVG text size by roughly 33% and makes stylesheets unreadable. Minimal UTF-8 percent-encoding (escaping only <, >, #, %, and braces) keeps CSS background-image snippets smaller and compresses better under Brotli/Gzip.