Run, test, transpile, and bundle JavaScript & TypeScript projects — all in Bun. Bun is a new JavaScript runtime built for speed, with a native bundler, transpiler, test runner, and npm-compatible package manager baked-in.

Server-side rendering React

HTTP requests per second (Linux x64)

  • bun: 71,387 requests per second

  • node: 21,567 requests per second

  • deno: 18,277 requests per second

View benchmark

WebSocket chat server

Messages sent per second (Linux x64, 16 clients)

  • bun: 1,058,979 messages sent per second

  • node: 186,830 messages sent per second

  • deno: 82,097 messages sent per second

View benchmark

Load a huge table

Average queries per second

  • bun: 80.65 queries per second

  • deno: 35.6 queries per second

  • better-sqlite3: 32.16 queries per second

View benchmark

What is Bun?

Bun is a new JavaScript runtime built from scratch to serve the modern JavaScript ecosystem, with three major design goals:

  • Fast startup. This is more important than ever as edge computing environments make cold start times more important than ever.
  • Fast running performance. Bun extends JavaScriptCore, the performance-minded JS engine built for Safari.
  • Cohesive DX. Bun is a complete toolkit for building JavaScript apps, including a bundler, transpiler, and package manager.

Bun is designed as a drop-in replacement for Node.js. Use it to run your current JavaScript & TypeScript apps or scripts — on your local computer, server or on the edge. Bun natively implements hundreds of Node.js and Web APIs, including ~90% of Node-API functions (native modules), fs, path, Buffer and more.

The goal of Bun is to run most of the world’s JavaScript outside of browsers, bringing performance and complexity enhancements to your future infrastructure, as well as developer productivity through better, simpler tooling.

Batteries included

  • Implements Web APIs like fetch WebSocket and ReadableStream
  • Implements Node’s node_modules resolution algorithm, so you can use npm packages in Bun. Both ESM and CommonJS are supported; internally Bun uses ESM.
  • Transpiles every file, so TypeScript and JSX just work.
  • Supports "paths", "jsxImportSource" and more from tsconfig.json files.
  • Exposes Bun.Transpiler—Bun’s JSX & TypeScript transpiler—as an API.
  • Uses the fastest system calls available with Bun.write to write, copy, pipe, send, and clone files.
  • Loads environment variables from .env files automatically—no more require("dotenv").config().
  • Ships with a fast SQLite3 client built-in bun:sqlite.
  • Implements most of Node-API so many native Node.js modules just work.
  • Provides a low-overhead foreign function interface bun:ffi for calling native code from JavaScript.
  • Supports a growing list of Node.js core modules like node:fs and node:path, along with globals like Buffer and process.

How does Bun work?

Bun uses the

JavaScriptCore

engine, which tends

to start

and perform a little faster than more traditional choices like V8. Bun is written in

Zig

, a low-level programming language with manual memory management.

Most of Bun is written from scratch including the JSX/TypeScript transpiler, npm client, bundler, SQLite client, HTTP client, WebSocket client and more.

Why is Bun fast?

An enormous amount of time spent profiling, benchmarking and optimizing things. The answer is different for every part of Bun, but one general theme: Zig‘s low-level control over memory and lack of hidden control flow makes it much simpler to write fast software. Sponsor the Zig Software Foundation.

Getting started

To install Bun, run this install script in your terminal. It downloads Bun from GitHub.

curl -fsSL https://bun.sh/install | bash

Bun’s HTTP server is built on web standards like Request and Response

// http.js
export default {
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
};

Run it with Bun:

Bun CLI

bun run

The same command for running JavaScript & TypeScript files with Bun’s JavaScript runtime also runs package.json "scripts". Bun runs package.json scripts 30x faster than npm run.

Replace npm run with bun run and save 160ms on every run.

bun install

bun install is an npm-compatible package manager. You probably will be surprised by how much faster copying files can get. Bun uses the fastest system calls available to copy files.

Replace yarn with bun install and get 20x faster package installs.

bunx

Auto-install and run an executable from a local or remote npm package.

Replace npx with bunx and get 100x faster startup times for local packages.

What is the license?

MIT License, excluding dependencies which have various licenses.

How do I see the source code?

Bun is on GitHub.

Read More