Bun 1.0 is here! Read the announcement →

Bun
Bun v1.0.33 is now available →

Bun is a fast JavaScript
all-in-one toolkit|

Develop, test, run, and bundle JavaScript & TypeScript projects—all with Bun. Bun is an all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager.

$ bun run

Bun is a JavaScript runtime.

Bun is a new JavaScript runtime built from scratch to serve the modern JavaScript ecosystem. It has three major design goals:

Bun is designed as a drop-in replacement for Node.js. It natively implements hundreds of Node.js and Web APIs, including fs, path, Buffer and more.

The goal of Bun is to run most of the world's server-side JavaScript and provide tools to improve performance, reduce complexity, and multiply developer productivity.

Drop-in Node.js compatibility

Bun aims to be a drop-in replacement for Node.js. It implements Node's module resolution algorithm, globals like Buffer and process, and built-in modules like fs and path. Click to track Bun's progress towards full compatibility.

Fast running performance

Bun extends the JavaScriptCore engine—the performance-minded JS engine built for Safari—with native-speed functionality implemented in Zig.

Works with node_modules

With Bun, you still use package.json to manage your dependencies. Use Bun's native npm client to see just how fast installing dependencies can be.

No more module madness

Forget the complicated rules around CommonJS, ESM, file extensions, resolution priority, and package.json configurations. With Bun, it just works.

TypeScript

TypeScript is a first-class citizen in Bun. Directly execute .ts and .tsx files. Bun respects your settings configured in tsconfig.json, including "paths", "jsx", and more.

Web-standard APIs

Bun implements the Web-standard APIs you know and love, including fetch, ReadableStream, Request, Response, WebSocket, and FormData.

JSX

JSX just works. Bun internally transpiles JSX syntax to vanilla JavaScript. Like TypeScript itself, Bun assumes React by default but respects custom JSX transforms defined in tsconfig.json.

Watch mode

The bun run CLI provides a smart --watch flag that automatically restarts the process when any imported file changes.

The APIs you need. Baked in.

Start an HTTP server

Start a WebSocket server

Read and write files

Hash a password

Bundle for the browser

Write a test

File system routing

Read a stream

Run a shell script

Call a C function

index.tsx
const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on localhost:${server.port}`);

$ bun install

Bun is an npm-compatible package manager.

Bun

pnpm

17x

npm

29x

Yarn

33x

Installing dependencies from cache for a Remix app.
View benchmark

Node.js compatible

Bun still installs your dependencies into node_modules like npm and other package managers—it just does it faster. You don't need to use the Bun runtime to use Bun as a package manager.

Crazy fast

Bun uses the fastest system calls available on each operating system to make installs faster than you'd think possible.

Workspaces

Workspaces are supported out of the box. Bun reads the workspaces key from your package.json and installs dependencies for your whole monorepo.

Global install cache

Download once, install anywhere. Bun only downloads a particular version of a package from npm once; future installations will copy it from the cache.

Binary lockfile

After installation, Bun creates a binary bun.lockb lockfile with the resolved versions of each dependency. The binary format makes reading and parsing much faster than JSON- or Yaml-based lockfiles.

Familiar API

Bun's CLI uses commands and flags that will feel familiar to any users of npm, pnpm, or yarn.

Replace yarn with bun install to get 30x faster package installs.

$ bun test

Bun is a test runner that makes the rest look like test walkers.

Bun

Vitest

5x slower

Jest+SWC

8x slower

Jest+tsjest

18x slower

Jest+Babel

20x slower

Running the test suite for Zod
View benchmark

Jest-compatible syntax

Bun provides a Jest-style expect() API. Switch to bun test with no code changes.

Crazy fast

Bun's fast startup times shine in the test runner. You won't believe how much faster your tests will run.

Lifecycle hooks

Run setup and teardown code per-test with beforeEach/afterEach or per-file with beforeAll/afterAll.

Snapshot testing

Full support for on-disk snapshot testing with .toMatchSnapshot(). Overwrite snapshots with the --update-snapshots flag.

DOM APIs

Simulate DOM and browser APIs in your tests using happy-dom.

Watch mode

Use the --watch flag to re-run tests when files change using Bun's instantaneous watch mode.

Function mocks

Mock functions with mock() or spy on methods with spyOn().

Replace jest with bun test to run your tests 10-30x faster.

1

Install Bun

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

2

Write your code

index.tsx
const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on localhost:${server.port}`);

3

Run the file

bun index.tsx

Learn by example.

Our guides break down how to perform common tasks with Bun.