Bun — A fast all-in-one JavaScript runtime

Bun for Windows is here! Check out what's new in Bun 1.1 →

Bun
Bun v1.1.11 is here! →

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:

  • Speed. Bun starts fast and runs fast. It extends JavaScriptCore, the performance-minded JS engine built for Safari. Fast start times mean fast apps and fast APIs.
  • Elegant APIs. Bun provides a minimal set of highly-optimimized APIs for performing common tasks, like starting an HTTP server and writing files.
  • Cohesive DX. Bun is a complete toolkit for building JavaScript apps, including a package manager, test runner, and bundler.

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.

Cross-platform shell scripts

The Bun.$ API implements a cross-platform bash-like interpreter, shell, and coreutils. This makes it easy to run shell scripts from JavaScript for devops tasks.

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

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

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.