Download StackBlitz projects programmatically
See the codeDownload 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
# 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-project
Install the package:
npm install stackblitz-zip
import { 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.
[!NOTE] The APIs use Web standards (fetch, ArrayBuffer, Blob) but direct fetching from stackblitz.com may be blocked by CORS.
Self-host the web service using the included Nitro app:
cd app
pnpm install
pnpm build
pnpm preview
Deploy to any platform using Nitro's deployment presets - supports Vercel, Netlify, Cloudflare Pages, AWS, Azure, Node.js, and many more.
downloadToFile(options: DownloadOptions): Promise<string>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 to 30000 (30 seconds)maxFileSize (number, optional): Maximum size per file in bytes. Defaults to 10485760 (10MB)maxTotalSize (number, optional): Maximum total project size in bytes. Defaults to 104857600 (100MB)verbose (boolean, optional): Enable console logging. Defaults to falsecloneProject(options: CloneOptions): Promise<string>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 to 30000 (30 seconds)maxFileSize (number, optional): Maximum size per file in bytes. Defaults to 10485760 (10MB)maxTotalSize (number, optional): Maximum total project size in bytes. Defaults to 104857600 (100MB)verbose (boolean, optional): Enable console logging. Defaults to falseReturns: Path to the created directory
downloadToResponse(options): Promise<Response>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
downloadToBuffer(options): Promise<ArrayBuffer>Downloads a StackBlitz project and returns it as an ArrayBuffer (universal).
Options: Same as downloadToFile except outputPath
downloadToBlob(options): Promise<Blob>Downloads a StackBlitz project and returns it as a Blob (browser-friendly).
Options: Same as downloadToFile except outputPath
parseUrl(url: string): stringParse 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 build
Made with ❤️
Published under MIT License.
TypeScript
48.7%
HTML
27.4%
CSS
19.2%
JavaScript
4.7%
Download StackBlitz projects programmatically
See the codeDownload 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
# 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-project
Install the package:
npm install stackblitz-zip
import { 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.
[!NOTE] The APIs use Web standards (fetch, ArrayBuffer, Blob) but direct fetching from stackblitz.com may be blocked by CORS.
Self-host the web service using the included Nitro app:
cd app
pnpm install
pnpm build
pnpm preview
Deploy to any platform using Nitro's deployment presets - supports Vercel, Netlify, Cloudflare Pages, AWS, Azure, Node.js, and many more.
downloadToFile(options: DownloadOptions): Promise<string>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 to 30000 (30 seconds)maxFileSize (number, optional): Maximum size per file in bytes. Defaults to 10485760 (10MB)maxTotalSize (number, optional): Maximum total project size in bytes. Defaults to 104857600 (100MB)verbose (boolean, optional): Enable console logging. Defaults to falsecloneProject(options: CloneOptions): Promise<string>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 to 30000 (30 seconds)maxFileSize (number, optional): Maximum size per file in bytes. Defaults to 10485760 (10MB)maxTotalSize (number, optional): Maximum total project size in bytes. Defaults to 104857600 (100MB)verbose (boolean, optional): Enable console logging. Defaults to falseReturns: Path to the created directory
downloadToResponse(options): Promise<Response>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
downloadToBuffer(options): Promise<ArrayBuffer>Downloads a StackBlitz project and returns it as an ArrayBuffer (universal).
Options: Same as downloadToFile except outputPath
downloadToBlob(options): Promise<Blob>Downloads a StackBlitz project and returns it as a Blob (browser-friendly).
Options: Same as downloadToFile except outputPath
parseUrl(url: string): stringParse 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 build
Made with ❤️
Published under MIT License.
TypeScript
48.7%
HTML
27.4%
CSS
19.2%
JavaScript
4.7%