Bundlephobia API
Free Bundlephobia API with no key: minified and gzipped size of any npm package, plus dependency count, tree-shakeability and download time estimates. Tested.
Endpoint tested and returned HTTP 200 on 2026-08-20
What is the Bundlephobia API?
The Bundlephobia API is a free, key-free API that reports the bundle size cost of any npm package — minified size, gzipped size, dependency count, tree-shakeability and estimated download times on slow connections.
Bundlephobia answers the question package.json cannot: what does adding this dependency actually cost your users? It builds the package and measures the real minified and gzipped output including all dependencies.
Because it builds packages on demand, a first request for an uncached package can take many seconds or time out. Once cached it is fast. Any CI integration needs a generous timeout and a retry, or it will fail spuriously.
Quick facts
- Base URL
https://bundlephobia.com/api- Authentication
- No API key required.
- Rate limit
- No published limit, but building uncached packages is slow — be patient rather than retrying aggressively.
- Pricing
- Free and open source.
- CORS
- Enabled — callable directly from browser JavaScript
- Official docs
- Read the docs
How to use the Bundlephobia API
Every request below was executed against the live API on 2026-08-20, and the response shown is the real body it returned — not an illustration.
1. Measure an npm package's bundle size
GET https://bundlephobia.com/api/size?package=react%4018.2.0
curl 'https://bundlephobia.com/api/size?package=react%4018.2.0'const res = await fetch("https://bundlephobia.com/api/size?package=react%4018.2.0");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
res = requests.get("https://bundlephobia.com/api/size?package=react%4018.2.0", timeout=20)
res.raise_for_status()
print(res.json()){
"dependencyCount": 1,
"hasJSNext": false,
"hasJSModule": false,
"isModuleType": false,
"hasSideEffects": true,
"peerDependencies": [],
"assets": [
{
"name": "main",
"type": "js",
"size": 6618,
"gzip": 2608
}
],
"dependencySizes": [],
"size": 6618,
"gzip": 2608,
"scoped": false,
"name": "react",
"version": "18.2.0",
"description": "React is a JavaScript library for building user interfaces.",
"repository": "https://github.com/facebook/react.git"
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
package | string | Required | Package name, optionally with @version. URL-encode the @. react%4018.2.0 |
record | boolean | Optional | Whether to record the lookup in Bundlephobia's stats. true |
Response fields
sizeinteger- Minified size in bytes.
gzipinteger- Gzipped size in bytes — the number that matters for transfer.
dependencyCountinteger- Number of dependencies pulled in.
hasJSModule / hasJSNextboolean|string- Whether an ES module build exists, enabling tree-shaking.
hasSideEffectsboolean- Whether the package declares side effects, which blocks tree-shaking.
assetsarray- Individual bundle assets with their sizes.
What you can build with the Bundlephobia API
- Check the size cost of a dependency before adding it
- Compare competing libraries by bundle impact
- Gate pull requests on bundle size in CI
- Find which dependencies dominate your bundle
Common errors and how to fix them
Timeout on first request
The package is being built on demand.
Fix: Uncached packages can take 10-30 seconds. Use a generous timeout and retry once rather than failing immediately.
BuildError
The package cannot be bundled — often native modules or broken builds.
Fix: Some packages genuinely cannot be measured this way; handle the error rather than treating it as a zero.
Scoped package 404
The @ was not URL-encoded.
Fix: Encode it as %40, e.g. %40scope%2Fname.
Bundlephobia API — frequently asked questions
Is the Bundlephobia API free?
Yes, free and open source with no API key.
Why is my first request so slow?
Bundlephobia builds the package on demand to measure it. An uncached package can take 10-30 seconds; subsequent requests are fast.
Which size figure should I care about?
The gzipped size, since that is what users actually download. Minified size overstates the real transfer cost.
What does hasSideEffects mean?
Whether the package declares that its modules have side effects. When true, bundlers cannot tree-shake unused code, so you pay for the whole package even if you import one function.
Tools that pair with this API
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
Unit Converter
Convert between units of length, weight, temperature, area, volume, speed, time and data storage instantly, with a swap button and common conversion tables.
Bundlephobia is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-20; always check the official documentation before relying on this API in production, as terms and limits can change.