1. License
“Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license”
sharp's own code is Apache-2.0 and free for paid products; using it on your server ships nothing to users.
github.com/lovell/sharp/blob/main/LICENSE3. Used by agents' projects
Dependency in 297 public GitHub projects set up for AI coding agents that we scanned (4.7%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error
What Sharp does
sharp is a free JavaScript package that makes photos smaller and faster to load. Your server or build step resizes uploads, crops avatars and turns big JPEG or PNG files into WebP or AVIF. It runs in Node.js, Deno or Bun, not in the web page itself.
What people build with it
Thumbnails for uploaded photos
A user uploads a 6 MB phone photo; your server saves a small, upright copy for lists and previews.
Serve WebP or AVIF instead of JPEG
Your site's images load faster because the build or server saves them in newer, smaller formats.
Square profile pictures
Any photo a user picks becomes a 200 by 200 avatar, cropped around the busiest part of the picture.
Never upscale small images
Fit pictures into a 200 pixel box for a gallery, but leave small ones at their own size so they do not blur.
Accept only JPEG uploads
Your upload service refuses every other image format before decoding, which shrinks the risk from crafted files.
Share images from a template Idea
Turn a drawing made from a template, such as a post title card, into a PNG picture for social media previews.
Sharp popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Sharp is used
- Sharp is a dependency in 297 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (6.1% of the 4,867 JavaScript/TypeScript ones), #1 of 281 in files, images and media.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 889; those are left out of every share on this page.
- Projects that use it most often also use TypeScript (91.9%), Tailwind CSS (67.3%), Playwright (JavaScript) (49.2%).
- It is more common in projects set up for OpenClaw (11.1%) than for Cursor (4.3%).
By coding agent
Often used with
Sharp in practice
Strengths
The performance page tested sharp v0.35.0 on a 4-core AWS AMD64 machine. On a JPEG decode, resize and encode, sharp (buffer) did 89.63 ops/sec. jimp did 3.44, imagemagick 16.23 and gm 20.92. The PNG gap is smaller: sharp did 47.74 ops/sec against 10.37 for imagemagick, which works out to 4.6x. The docs note that libvips caching was disabled for sharp in this test, and that caching is on by default.
The site says libvips keeps only small regions of uncompressed image data in memory and processes them a piece at a time. It says this makes full use of multiple CPU cores and the L1/L2/L3 cache.
The site says the work stays non-blocking through libuv, and no child processes are spawned. Promises and <code>async</code>/<code>await</code> are supported.
According to the site, mozjpeg and pngquant features can be used on JPEG and PNG output without invoking separate imagemin processes. It also says JPEG Huffman tables are optimised without jpegoptim or jpegtran, and animated GIF output is optimised without tools such as gifsicle.
Watch out for
How many images sharp processes in parallel is set by libuv's <code>UV_THREADPOOL_SIZE</code>, which defaults to 4. For more than 4 physical CPU cores, the docs say to set it before the Node.js process starts.
On glibc-based Linux without jemalloc or without <code>MALLOC_ARENA_MAX</code>, libvips defaults to 1 thread per image "to help reduce memory fragmentation". On other systems, the default thread count matches the number of CPU cores.
The benchmark's own contender list describes the imagemagick package as one that "has been unmaintained for a long time". It says gm "has been sunset".
Auto-orient, resize and encode JPEG with mozjpeg
// ESM
import sharp from 'sharp';
const output = await sharp('input.jpg')
.autoOrient()
.resize({ width: 200 })
.jpeg({ mozjpeg: true })
.toBuffer();More about Sharp
Funding
- GitHub Sponsors: https://github.com/lovell
- GitHub Sponsors: https://github.com/libvips
- Open Collective: https://opencollective.com/libvips
- thanks.dev: https://thanks.dev/u/gh/lovell
- 2 GitHub sponsors
Agent Skills for it
- sharp-edges: Identifies error-prone APIs, dangerous configurations, and footgun designs that enable security mistakes. Use when reviewing API designs, co
Packages around it
- typescript: Typed JavaScript
- @playwright/test: Browser end-to-end tests
- tailwindcss: Utility-first CSS
- vitest: Unit test runner
- tsx: Run TypeScript in Node
- react: UI library
More in Files, images and media
Alternatives
Sharp This page
Pick Jimp when you cannot install native parts (some hosts and sandboxes); it is written entirely in JavaScript.
Pick Pillow when your backend is in Python.
Pick Cloudinary when you would rather upload images to a hosted service that resizes and serves them for you.
Get started
Tell your AI assistant
“Use sharp 0.35.5 (Node.js 20.9+) on the server to auto-orient each uploaded image, resize it to fit 1200 px without enlarging, save WebP plus a 200 px square cover-cropped thumbnail, and set limitInputPixels; keep sharp out of the client bundle.”
Add sharp to your project. The right ready-built files for your system come with it, so your package manager must install optional packages.
npm install sharpImport it (ES modules or require both work).
// ESM import sharp from 'sharp'; // CJS const sharp = require('sharp');
Rules for your agent
## Sharp
- Install with `npm install sharp`. Import with `import sharp from 'sharp'` (ESM) or `const sharp = require('sharp')` (CJS).
- Target a runtime with Node-API v9 support: Node.js >= 20.9.0, Deno or Bun.
- Chain operations on `sharp(input)` and finish with `.toBuffer()` or `.toFile()`. Input can be a file path, a Buffer or a Stream.
- For smaller JPEG output, use `.jpeg({ mozjpeg: true })` as the README shows. Do not add a separate imagemin step for this.
- When using more than 4 physical CPU cores, set `UV_THREADPOOL_SIZE` before the Node.js process starts.
- With the default glibc allocator on Linux, set `MALLOC_ARENA_MAX` to 2 or 4 before the process starts. Use `sharp.concurrency()` to manage threads per image.
Mistakes to avoid
sharp 0.35 dropped Node.js 18.
Package managers pick the ready-built files for the machine that runs the install.
sharp loads native files at run time and must stay in node_modules.
Output strips EXIF orientation, so photos taken sideways stay sideways.
The failOnError option was removed in 0.35; failOn controls how strict decoding is.
Questions
Can I use sharp in the browser or in a React component?
No. Run it on your server, in a serverless function or in your build; the docs say browser use is unsupported.
Which image formats can it read and write?
It reads JPEG, PNG, WebP, GIF, AVIF, TIFF and SVG, and writes JPEG, PNG, WebP, GIF, AVIF and TIFF.
Why do my phone photos come out sideways?
Output drops the camera orientation data. Call autoOrient() before resizing.
Does it work on AWS Lambda?
Yes, if your deployment package holds the Linux build for the function's chip type.
Is it safe for images uploaded by strangers?
It treats all input as untrusted, rejects files with decode warnings and limits the pixel count by default.