SVG to SwiftUI Converter
Paste an SVG and get a SwiftUI Shape you can drop into your project.
Try a sample:
Responsive Aspect Scaling
Canvas Preview24 × 24
SwiftUI Code Output
import SwiftUI
/// Custom SwiftUI vector shape generated by AnimKit (animkit.dev)
struct HeartIconShape: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
let width = rect.size.width
let height = rect.size.height
let sx = width / 24.00
let sy = height / 24.00
path.move(to: CGPoint(x: (12.00 * sx), y: (21.35 * sy)))
path.addLine(to: CGPoint(x: (10.55 * sx), y: (20.03 * sy)))
path.addCurve(to: CGPoint(x: (2.00 * sx), y: (8.50 * sy)), control1: CGPoint(x: (5.40 * sx), y: (15.36 * sy)), control2: CGPoint(x: (2.00 * sx), y: (12.28 * sy)))
path.addCurve(to: CGPoint(x: (7.50 * sx), y: (3.00 * sy)), control1: CGPoint(x: (2.00 * sx), y: (5.42 * sy)), control2: CGPoint(x: (4.42 * sx), y: (3.00 * sy)))
path.addCurve(to: CGPoint(x: (12.00 * sx), y: (5.09 * sy)), control1: CGPoint(x: (9.24 * sx), y: (3.00 * sy)), control2: CGPoint(x: (10.91 * sx), y: (3.81 * sy)))
path.addCurve(to: CGPoint(x: (16.50 * sx), y: (3.00 * sy)), control1: CGPoint(x: (13.09 * sx), y: (3.81 * sy)), control2: CGPoint(x: (14.76 * sx), y: (3.00 * sy)))
path.addCurve(to: CGPoint(x: (22.00 * sx), y: (8.50 * sy)), control1: CGPoint(x: (19.58 * sx), y: (3.00 * sy)), control2: CGPoint(x: (22.00 * sx), y: (5.42 * sy)))
path.addCurve(to: CGPoint(x: (13.45 * sx), y: (20.04 * sy)), control1: CGPoint(x: (22.00 * sx), y: (12.28 * sy)), control2: CGPoint(x: (18.60 * sx), y: (15.36 * sy)))
path.addLine(to: CGPoint(x: (12.00 * sx), y: (21.35 * sy)))
path.closeSubpath()
return path
}
}
// Usage Example:
// HeartIconShape()
// .fill(Color.accentColor)
// .frame(width: 24, height: 24)How to use it
- 1Paste SVG markup or upload an .svg file.
- 2Name the generated Shape struct.
- 3Copy the Swift code and use it like any Shape: .fill(), .stroke() or .frame().
FAQ
Does it support arcs and curves?
Yes. Cubic and quadratic curves map to addCurve and addQuadCurve; arcs are converted to cubic curves.
Will the shape scale with its frame?
Yes. Coordinates are scaled to the rect passed into path(in:), so the shape resizes with its frame.
What about colours and gradients?
Only geometry is converted. Apply colour in SwiftUI with .fill() or .foregroundStyle().