
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGood news! Yes, you can convert SVG images to JPG (or PNG) using Sanity's image CDN, and you don't need GROQ to do it directly—though you can handle it in your queries.
The Sanity image transformation API supports format conversion using the fm parameter. Simply add ?fm=jpg or ?fm=png to your image URL to convert SVG to a rasterized bitmap format:
https://cdn.sanity.io/images/[project-id]/[dataset]/[asset-id]-[dimensions].svg?fm=png
If you want to conditionally convert SVGs in your GROQ queries (which is great for automation), you can check the file extension and append the format parameter. Here's an example from the Sanity community:
*[_type == 'blogPost'] {
images[] {
asset->{
url,
extension == 'svg' => {
'url': url + '?fm=png'
}
}
}
}This pattern checks if the asset extension is svg, and if so, reassigns the url field with the ?fm=png parameter appended. You can use ?fm=jpg instead if you prefer JPEG output.
If you're specifically dealing with Next.js's <Image> component rejecting SVGs, you have two options:
next/imagedangerouslyAllowSVG: true to your next.config.js:module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'cdn.sanity.io',
},
],
dangerouslyAllowSVG: true,
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
}The CDN conversion approach is generally safer and more performant since it lets Sanity's globally-distributed CDN handle the transformation and caching at the edge.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store