Download StackBlitz projects programmatically
While StackBlitz provides an API to fetch project data, there's no built-in way to download projects as zip files programmatically. This tool makes it easy to download reproductions for issues quickly.
Important
This project is not affiliated with or endorsed by StackBlitz in any way. Users are responsible for ensuring their use of this tool complies with StackBlitz's Terms of Service. Please review their terms before using this tool.
The easiest way to download a StackBlitz project is at stackblitz.zip
Simply replace stackblitz.com with stackblitz.zip in any StackBlitz edit URL:
Original: https://stackblitz.com/edit/nuxt-starter-k7spa3r4
Download: https://stackblitz.zip/edit/nuxt-starter-k7spa3r4
π see source
# download a project as a zip file
npx stackblitz-zip https://stackblitz.com/edit/nuxt-starter-k7spa3r4
# specify output path for zip
npx stackblitz-zip https://stackblitz.com/edit/nuxt-starter-k7spa3r4 my-project.zip
# clone project to a directory
npx stackblitz-clone https://stackblitz.com/edit/nuxt-starter-k7spa3r4
# clone to a specific directory
npx stackblitz-clone https://stackblitz.com/edit/nuxt-starter-k7spa3r4 ./my-projectInstall the package:
npm install stackblitz-zipimport { cloneProject, downloadToFile, parseUrl } from 'stackblitz-zip'
// download from a URL as a zip file
const projectId = parseUrl('https://stackblitz.com/edit/nuxt-starter-k7spa3r4')
await downloadToFile({ projectId, outputPath: './output.zip' })
// download by project ID
await downloadToFile({
projectId: 'nuxt-starter-k7spa3r4',
outputPath: './my-project.zip',
})
// clone project to a directory
await cloneProject({
projectId: 'nuxt-starter-k7spa3r4',
outputPath: './my-project',
})import { downloadToBlob, downloadToResponse, parseUrl } from 'stackblitz-zip'
// download as Web Response (edge runtimes, servers)
const projectId = parseUrl('https://stackblitz.com/edit/nuxt-starter-k7spa3r4')
const response = await downloadToResponse({ projectId })
// response can be returned directly from edge functions
// or download as Blob (browser-friendly)
const blob = await downloadToBlob({ projectId })
// trigger browser download
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `${projectId}.zip`
a.click()
URL.revokeObjectURL(url)Note
Direct browser usage may be blocked by CORS when fetching from stackblitz.com.
- Universal - works in Node.js, browsers, and edge runtimes
- Built with tsdown and client-zip
- Nitro web service at stackblitz.zip
- Fetches project data directly from StackBlitz API
- Zip slip protection and security validations
- Configurable size limits and timeouts
- Web API streaming (Response/ArrayBuffer/Blob)
Note
The APIs use Web standards (fetch, ArrayBuffer, Blob) but direct fetching from stackblitz.com may be blocked by CORS.
- β Zip slip protection - file paths are sanitized to prevent directory traversal
- β Size limits - configurable limits on file size (10MB) and total size (100MB)
- β Request timeout - prevents hanging requests (30s default)
- β Project ID validation - only alphanumeric, hyphens, and underscores
- β Memory efficient - streaming support with no temporary files
Self-host the web service using the included Nitro app:
cd app
pnpm install
pnpm build
pnpm previewDeploy to any platform using Nitro's deployment presets - supports Vercel, Netlify, Cloudflare Pages, AWS, Azure, Node.js, and many more.
Downloads a StackBlitz project and returns the path to the created zip file.
Options:
projectId(string, required): The StackBlitz project IDoutputPath(string, optional): Path where the zip file should be saved. Defaults to<project-id>.ziptimeout(number, optional): Timeout in milliseconds for loading the project. Defaults to30000(30 seconds)maxFileSize(number, optional): Maximum size per file in bytes. Defaults to10485760(10MB)maxTotalSize(number, optional): Maximum total project size in bytes. Defaults to104857600(100MB)verbose(boolean, optional): Enable console logging. Defaults tofalse
Clones a StackBlitz project by creating all files in a target directory.
Options:
projectId(string, required): The StackBlitz project IDoutputPath(string, optional): Path where the project directory should be created. Defaults to<project-id>/timeout(number, optional): Timeout in milliseconds for loading the project. Defaults to30000(30 seconds)maxFileSize(number, optional): Maximum size per file in bytes. Defaults to10485760(10MB)maxTotalSize(number, optional): Maximum total project size in bytes. Defaults to104857600(100MB)verbose(boolean, optional): Enable console logging. Defaults tofalse
Returns: Path to the created directory
Downloads a StackBlitz project and returns it as a Web Response (universal).
Options: Same as downloadToFile except outputPath
Returns: A Response object containing the zip file stream
Downloads a StackBlitz project and returns it as an ArrayBuffer (universal).
Options: Same as downloadToFile except outputPath
Downloads a StackBlitz project and returns it as a Blob (browser-friendly).
Options: Same as downloadToFile except outputPath
Parse a StackBlitz URL and extract the project ID.
Parameters:
url(string, required): Full StackBlitz project URL (e.g.,https://stackblitz.com/edit/project-id)
Returns: The project ID
# clone this repository
git clone https://github.com/stackblitz-labs/stackblitz.zip
# install dependencies
corepack enable
pnpm install
# run interactive tests
pnpm dev
# build for production
pnpm buildMade with β€οΈ
Published under MIT License.