Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Sharp

Resize and convert images on your server.

Files, images and mediaNPM

GitHubWebsite

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/LICENSE

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

84 / 100
Gid Score, #48 overall
172M
downloads a week, npm
32.9K
GitHub stars
297
agent projects use it
Sharp: downloads per weeknpm, sharp 171,932,863
Sharp: GitHub starslovell/sharp 32,869

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

189 projects, 5.8%
134 projects, 4.4%
106 projects, 4.3%
39 projects, 8.2%
37 projects, 11.1%
26 projects, 5.5%
17 projects, 5.0%
14 projects, 5.0%

Often used with

In 91.9% of its projects
In 67.3% of its projects
In 49.2% of its projects
In 45.5% of its projects
In 52.9% of its projects
In 64.0% of its projects
In 55.9% of its projects
In 48.8% of its projects

Sharp in practice

Strengths

Far ahead on JPEG in the maintainers' benchmark, less so on PNG

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.

Small regions in memory, all cores busy

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.

No child processes, no blocked event loop

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.

File-size optimisation without extra CLI tools

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

Four images in parallel unless you change the env var

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.

One thread per image on default glibc Linux

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.

Benchmark rivals are retired projects

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

See all

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

See all

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

Apache-2.0Gid 84172M/wk

Jimp

Pick Jimp when you cannot install native parts (some hosts and sandboxes); it is written entirely in JavaScript.

Pillow

Pick Pillow when your backend is in Python.

Cloudinary

Pick Cloudinary when you would rather upload images to a hosted service that resizes and serves them for you.

Compare Sharp with another tool

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.”

  1. 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 sharp

    From sharp.pixelplumbing.com/install/

  2. Import it (ES modules or require both work).

    // ESM
    import sharp from 'sharp';
    
    // CJS
    const sharp = require('sharp');
    

    From github.com/lovell/sharp/blob/main/README.md

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## 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

npm install sharp on Node.js 18
Upgrade to Node.js 20.9+ (or pin sharp 0.34 on Node.js 18)

sharp 0.35 dropped Node.js 18.

Running npm install on a Mac and uploading node_modules to a Linux server or AWS Lambda
Install for the target, e.g. npm install --cpu=x64 --os=linux --libc=glibc sharp, or install on the server itself

Package managers pick the ready-built files for the machine that runs the install.

Letting webpack or esbuild bundle sharp into server code
Mark sharp as external (webpack externals, esbuild --external:sharp)

sharp loads native files at run time and must stay in node_modules.

sharp(input).resize(800).toFile('out.jpg') on phone photos
sharp(input).autoOrient().resize(800).toFile('out.jpg')

Output strips EXIF orientation, so photos taken sideways stay sideways.

sharp(input, { failOnError: false })
sharp(input, { failOn: 'none' }), only for trusted input

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.