Optimize Next.js Images — Give next/image a Lean Source
next/image optimizes on request, and only for images it serves. Compress the originals in public/ so the first request is fast, and plain <img> files are small too.
Quick answer
next/image resizes and converts images through Next's Image Optimization API, caching the result. It always starts from your original file, and with output: 'export' there is no server to do that work at all. Compress public/ with TinyPixels so both paths start from a lean source.
How to compress images before deploying a Next.js app
Download and open TinyPixels
Free to install on Mac or Windows — no account needed to start.
Resize oversized originals
A 6000 px export makes the first optimized request slower and bloats the cache.
Compress public/
Drop it into TinyPixels. Convert big banners to WebP or AVIF if you serve them directly.
Commit and deploy
Both the optimizer and the raw files now start from smaller sources.
What next/image does, and what it leaves alone
next/image resizes and converts images on demand through the Image Optimization API: the first request for a given size transforms the original, serves WebP by default (AVIF if you enable it in images.formats), and caches the result for later visitors. Static imports also give it width and height automatically, and a blur placeholder if you ask for one.
That makes the original's size matter in two ways. A very large source makes the first request for each variant slower and takes more memory on the server. And everything that bypasses the optimizer, plain <img> tags, CSS backgrounds, Open Graph images and files served from public/ directly, ships the original at full size.
Static exports change the picture further: with output: 'export' there is no server, so the default optimizer is unavailable. Unless you configure a custom loader or mark images as unoptimized, your images ship as committed, and compressing them beforehand is the optimization. Check the current Next.js docs for your version's details, and your hosting provider's terms on image optimization usage.
Faster first request
A lean source shortens the on-demand transform for each new size.
Covers unoptimized paths
Plain <img>, CSS and OG images get smaller too.
Key for static export
With output: export, pre-compression is the main optimization you have.
Format conversion
Convert directly-served banners to WebP or AVIF and update references.
What Next.js does with an image
| Setup | What happens | Your move |
|---|---|---|
| <Image /> with the default server | Resizes on request, WebP by default, AVIF opt-in, caches the output. | Give it a lean, right-sized source |
| Static import (import hero from ...) | Infers width and height, supports a blur placeholder. Still starts from the original. | Compress the imported file |
| output: 'export' | No server for the default optimizer. Images ship as committed unless you set a loader or unoptimized. | Compress before build; this is your optimization |
| Plain <img> or CSS url() | Not optimized. The original is served. | Compress the file |
| Open Graph / metadata images | Served as-is. | Compress the file |
Defaults depend on your Next.js version and hosting setup; confirm against the current docs before relying on any one behaviour.
Common mistakes with Next.js images
Assuming next/image makes compression unnecessary
It still reads your original on the first request. A 6 MB source means a slow first hit and a bigger cache, even though visitors later get small variants.
Using output: 'export' without a loader
The default optimizer needs a server. Without a custom loader or unoptimized, you will get a build error or unoptimized full-size images.
Using a plain <img> for the hero
It bypasses the optimizer entirely, so the original file is what the visitor gets.
Forgetting CSS and OG images
Backgrounds and social-card images are served directly, and nothing optimizes them unless you do.
Frequently asked questions
Does next/image compress my images?
It resizes and converts them on request and caches the result, but it reads your original each time it creates a new variant. A smaller original makes that work faster.
Do I still need to compress images if I use next/image?
Yes, for three reasons: faster first requests, images that bypass the optimizer, and static exports where no server optimizer exists.
How do images work with output: 'export'?
There's no server to run the Image Optimization API, so you need a custom loader or unoptimized images. Compressing the sources before build is the practical optimization.
Does next/image support AVIF?
Yes, you can enable AVIF through the images.formats setting; WebP is the default. Check the docs for your version.
Can I batch compress my whole public/ folder at once?
Yes. Drop public/ into TinyPixels and every image compresses in one local pass.
Ship a leaner Next.js deploy
Free to start. No credit card, no account, no cloud. See Pro pricing →
Related tools
Optimize React Images
Compress images for your React app before build.
Compress Flutter Assets
Shrink your Flutter app bundle with local compression.
WebP Converter
Convert any format to WebP locally.
Optimize Astro Images
The same approach for Astro's public/ folder.
Image Compressor Hub
Every format, platform, and framework in one place.
Optimize Vue Images
Compress images for your Vue app before build.
Optimize Svelte Images
Compress images for your Svelte app before build.
Optimize Angular Images
Compress images for your Angular app before build.
Read more: Fix your Lighthouse score where it actually matters → · Best image format for websites in 2026 →