# turbo-stream

> A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.

Latest version **3.2.1** (published 2026-08-19) · MIT license · 1.7M weekly downloads

## Install

```sh
npm install turbo-stream
pnpm add turbo-stream
yarn add turbo-stream
bun add turbo-stream
```

## Health

**Score 90/100 (A)** — status: active.

Positive: high downloads; has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

## Facts

| | |
|---|---|
| Version | 3.2.1 |
| Published | 2026-08-19 |
| First published | 2023-10-23 |
| Weekly downloads | 1.7M |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 126.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 322 |
| Author | Jacob Ebey <jacob.ebey@live.com> |
| Maintainers | jacob-ebey |
| Keywords | devalue, turbo, stream, enhanced, json |

## Links

- npm: https://www.npmjs.com/package/turbo-stream
- Repository: https://github.com/jacob-ebey/turbo-stream
- npm.io page: https://npm.io/package/turbo-stream

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [@turf/center-mean](https://npm.io/package/@turf/center-mean.md) — 1.3M weekly downloads

## Recent versions

- 3.2.1 (latest) — 2026-08-19
- 3.2.0 — 2026-02-26
- 3.1.0 — 2025-02-07
- 3.0.1 — 2025-02-05
- 3.0.0 — 2025-02-04
- 2.4.1 — 2024-09-11
- 2.4.0 — 2024-08-17
- 2.3.0 — 2024-08-12
- 2.2.3 — 2024-08-11
- 2.2.2 — 2024-08-10
- 2.2.1 — 2024-08-10
- 2.2.0 — 2024-06-04
- 2.1.0 — 2024-05-30
- 2.0.1 — 2024-04-29
- 2.0.0 — 2024-03-06
- … 17 more at https://npm.io/package/turbo-stream/versions

## README

# Turbo Stream <br> [![turbo-stream's badge](https://deno.bundlejs.com/?q=turbo-stream&badge=detailed)](https://bundlejs.com/?q=turbo-stream)

Streaming data transport format that supports:

- Streaming promises
- `undefined`, `null`, `Boolean`, `String`
- `Bigint`, `Set`, `Map`, `URL`, `RegExp`, `Error`
- `Number`, including `+Infinity`, `-Infinity` and `NaN`, `-0`
- Circular references, repeated references
- `Date`, including invalid dates
- `Symbol` (`Symbol.from()`)
- Objects with `toJSON` methods
- Iterables, AsyncIterable
- `Buffer`, `ArrayBuffer`, `DataView`, TypedArrays
- `File`, `Blob`, `FormData`, `ReadableStream`

Uses `ReadableStream` as the transport interface for encoding and decoding.

Decode runtime size: [![turbo-stream's badge](https://deno.bundlejs.com/badge?q=turbo-stream&badge=detailed&treeshake=%5B%7B+decode+%7D%5D)](https://bundlejs.com/?q=turbo-stream&treeshake=%5B%7B+decode+%7D%5D)

## Installation

```bash
npm install turbo-stream
```

## Usage

```js
import { decode, encode } from "turbo-stream";

const encodedStream = encode(Promise.resolve(42));
const decoded = await decode(encodedStream);
console.log(decoded); // 42
```

## Benchmarks

Run them yourself with `pnpm bench`

```
• realistic payload
------------------------------------------- -------------------------------
JSON                           2.80 µs/iter   2.71 µs █▆                   
                        (2.59 µs … 5.61 µs)   5.55 µs ██                   
                    (  2.91 kb …   2.91 kb)   2.91 kb ██▁▂▁▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▂
turbo encode                  16.71 µs/iter  16.47 µs  █                   
                      (16.04 µs … 19.47 µs)  18.38 µs ███                  
                    (  2.80 kb …   2.81 kb)   2.80 kb ██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█
turbo full                    35.30 µs/iter  36.33 µs  █                   
                     (31.38 µs … 202.79 µs)  52.50 µs  █▃  ▄               
                    (  2.47 kb … 454.32 kb) 104.44 kb ▂██▃▅█▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┬  ╷
                        JSON │──┤
                             ┴  ╵
                                         ┌┬╷
                turbo encode             ││┤
                                         └┴╵
                                                       ╷┌─┬┐              ╷
                  turbo full                           ├┤ │├──────────────┤
                                                       ╵└─┴┘              ╵
                             └                                            ┘
                             2.59 µs           27.55 µs            52.50 µs

summary
  turbo encode
   5.97x slower than JSON
   2.11x faster than turbo full
```

## Legacy

Shout out to Rich Harris and his https://github.com/rich-harris/devalue project. Devalue has heavily influenced this project and portions of the original code was directly lifted from it. I highly recommend checking it out if you need something more cusomizable or without streaming support. This new version has been re-written from the ground up and no longer resembles devalue.

---
_Source: https://npm.io/package/turbo-stream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
