Skip to main content

A list of every web API in Deno

Have you ever wondered how web compatible Deno is? Probably not, but I did today. To answer that question, I am writing this blog post: I’ll list and explain every single web API implemented in Deno. Get yourself something to drink, because this is going to take a while to go through.

Before we get into it though, I just want to set some ground rules:

  1. I am not including any JS language features. Only web platform features.
  2. I will include the few features that are still marked as --unstable, but will mention that they are not yet stable.
  3. I am not including any features that are not a concrete API. For example JSON modules are implemented in Deno, but are more of an abstract concept rather than a concrete API and thus are not included in this list.

Table of Contents

atob and btoa

These two functions are used to encode and decode base64 strings. They’re old - Firefox 1, released on the 9th of November 2004, already had support.

atob("SGVsbG8gV29ybGQ="); // "Hello World"
btoa("Hello World"); // "SGVsbG8gV29ybGQ="

setTimeout and clearTimeout

setTimeout is another super old web feature. It’s used to schedule a function to be called after a certain amount of time has passed. It returns a numeric ID that can be used to cancel the timeout with clearTimeout.

Beware that Deno implements this API just like in the browser: returning a number. Node.js also implements this API, but with a non-standard behavior where it returns an object instead of a number.

setTimeout(() => {
  console.log("This prints after 1 second.");
}, 1000);

const timerId = setTimeout(() => {
  console.log("This doesn't print at all.");
}, 500);

console.log("This prints immediately.");

setInterval and clearInterval

setInterval and clearInterval are very similar to setTimeout and clearTimeout. The difference is that setInterval calls the callback function every X milliseconds, rather than only once after X milliseconds.

Same disclaimer as with setTimeout applies here: Deno implements this API just like the browser, while Node has a non standard object as the return value.


Deno implements the Web Cryptography API completely. This API can be used to do various low and high level cryptographic operations. For example you can:

  • generate a random UUID with crypto.randomUUID()
  • generate a Uint8Array filled with random bytes with crypto.getRandomValues()
  • sign and verify data with crypto.subtle.sign() and crypto.subtle.verify() with RSA, ECDSA, and many other algorithms.
  • generate hashes with crypto.subtle.digest().
  • encrypt and decrypt data with crypto.subtle.encrypt() and crypto.subtle.decrypt().
  • generate RSA, ECDSA, HMAC, or AES keys with crypto.subtle.generateKey()

Deno’s implementation of the Web Cryptography API was completed just a few weeks ago, but the wait was totally worth it. Deno passes more web platform tests than both Chrome and Firefox. Only Safari has us slightly beat:

Engine % of tests passing
Safari 99.8%
Deno 98.1%
Chrome/Edge 94.5%
Firefox 93.4%

You can see the current data for yourself on

const uuid = crypto.randomUUID();
const bytes = await crypto.getRandomValues(new Uint8Array(16));
const digest = await crypto.subtle.digest("SHA-256", bytes);

fetch, Request, Response, and Headers

Deno implements the maybe most popular modern web API: fetch. It’s used to make HTTP requests. Usage is super simple: the first argument is the URL you want to request, and the second argument is an optional object with options, like method, headers, or body.

The fetch API in Deno is implemented natively in the runtime, backed by the blazing fast hyper HTTP implementation in Rust. It supports HTTP/1.1 and HTTP/2 servers, full duplex streaming, native gzip/deflate/brotli decoding, and is highly compatible with the web platform.

Just like all of our other web APIs, our implementation of fetch is tested using the same web platform tests test-suite as all the browsers. This makes sure that Deno’s implementation is compatible with the web platform. To our knowledge, we are the only server side runtime that tests fetch against the canonical web platform tests right now.

Deno also implements all of the objects surrounding fetch: Request, Response, and Headers. These objects represent a HTTP request, a HTTP response, and a list of HTTP headers respectively. Because Deno is a web-first runtime, our HTTP server uses these same objects to represent the request and response. That makes proxying requests super easy.

const resp = await fetch("");
const text = await resp.text();

Blob and File

Blob and File both represent binary data. The big difference between them and Uint8Array is that they can store their data in memory or on disk, thus making them ideal for large binary blobs. Because of the possibility of storing data on disk, the data backed by Blob and File is only available asynchronously.

Data can be retrieved using the .arrayBuffer(), .text(), and .stream() methods, or the FileReader API.

const blob = new Blob(["Hello World"]);
const text = await blob.text();

const file = new File(["Hello World"], "hello.txt");
const bytes = await file.arrayBuffer();
console.log(new Uint8Array(bytes));

TextEncoder and TextDecoder

Sometimes you need to encode or decode strings into or from a binary representation. Deno provides the TextEncoder and TextDecoder APIs for this. They can be used to encode strings into a Uint8Array, and decode Uint8Arrays into strings. All of the text encodings that are available in the browser are also available in Deno.

const encoder = new TextEncoder();
const bytes = encoder.encode("Hello World");

const decoder = new TextDecoder();
const text = decoder.decode(bytes);


When interacting with HTTP APIs, sometimes you need to send data as multipart/form-data. This can be done using the FormData API. It is a JavaScript structure that lets you easily append key-value pairs or files to a form to be sent as multipart data.

Because Deno also uses the same Request and Response objects from fetch for the native HTTP server, FormData can be used to easily decode multipart form data from incoming requests by calling await request.formData(). Neat huh?

const formData = new FormData();
formData.append("name", "Deno");
formData.append("age", "3");
formData.append("file", new File(["Hello World"], "hello.txt"));

const resp = await fetch("", {
  method: "POST",
  body: formData,


The performance allows for accurate time measurement, for example using It can also be used to directly measure the time spent on some operation using performance.mark() and performance.measure().

const start =;
await fetch("");
const end =;
console.log("Took", end - start, "milliseconds");


The structuredClone API is used to deep clone objects. It is a very new API, but is already shipping in all major browsers.

Compared to shallow cloning, deep cloning doesn’t just copy the shape of the outermost object, but also the shape of all nested objects and arrays. It can also clone objects with circular references.

const obj = {
  foo: "bar",
  baz: {
    qux: "quux",
const clone = structuredClone(obj);
console.log(obj === clone); // false
console.log(obj.baz === clone.baz); // false

obj.baz.qux = "quuz";
console.log(obj.baz.qux); // quuz
console.log(clone.baz.qux); // quux

URL and URLSearchParams

URLs are integral to anything having to do with the web. Deno implements the URL and URLSearchParams APIs as they are specified by the WHATWG. This means that our URL and query string parsing is exactly the same as the browser. This can prevent security issues around one system parsing a URL slightly differently to another system.

const url = new URL("");
console.log(url.href); //
console.log(url.hostname); //
console.log(url.searchParams.get("name")); // undefined
url.searchParams.append("name", "bar");
console.log(url.href); //


console may be the most useful web API out there. Printf debugging anyone? You probably know about console.log() already, so here are some other cool features of console that Deno implements that you may not know about:

%c marker can be used to add color to logging output using CSS. Deno understands this natively - no need to remember ANSI escape codes anymore to do colored logging:

console.log("%cHello, world!", "color: red");
console.log("%cHello, %cworld!", "font-weight: bold", "font-style: italic");

Another cool console feature we implement is the console.time API. It makes it super simple to figure out how long some operation took:

await new Promise((resolve) => setTimeout(resolve, 1000));


JavaScript execution is always single threaded - the language has no built in concurrency primitives. To support workloads that require multiple threads, the web has the concept of Worker. Workers are additional JavaScript execution contexts that run on a separate thread, completely isolated from the main thread.

Deno implements workers natively, just like in the browser. Because the APIs are identical you can use libraries that are written for the browser in Deno without any changes. An example of such a library is comlink - it makes using workers super simple by abstracting away the details of cross worker communication.

// main.js
import * as Comlink from "";

const url = new URL("./worker.js", import.meta.url);
const worker = new Worker(url, { type: "module" });

const obj = Comlink.wrap(worker);

console.log(`Counter: ${await obj.counter}`);
console.log(`Counter: ${await obj.counter}`);

// worker.js
import * as Comlink from "";

const obj = {
  counter: 0,
  inc() {


Event and EventTarget

In the browser events and event targets are the basis of all interactive experiences. They allow you to register a callback to be called when some event occurs. FileReader is an EventTarget for example: it emit events when a chunks of the file are read, or when the file is completely read, or when an error occurs.

Modern APIs often don’t use events and callbacks anymore, instead using Promises. These have much better usability and readability because of async/await. Nonetheless Event and EventTarget are still used by many APIs, so Deno implements them just like browsers.

const target = new EventTarget();
target.addEventListener("foo", (event) => {
target.dispatchEvent(new Event("foo"));


Just like how Deno implements fetch do to HTTP requests just like in the browser, Deno also implements the WebSocket API. WebSockets are great way to do bi-directional communication between a client and server.

Because the WebSocket protocol works the same on both ends of the connection (client and server), Deno also uses this same API for server-side (incoming) WebSocket connections on the native HTTP server.

const ws = new WebSocket("ws://localhost:4500");
ws.onopen = () => {
  ws.send("Hello, world!");
ws.onmessage = (event) => {

ReadableStream and WritableStream

Streaming is a critical part of modern web applications. It is a necessity when working with data that is larger than can fit into available memory at once. It is also a great way to reduce the TTFB when working with large files.

Deno supports the same streams API as browsers. This is very powerful, because it allows Deno users to make use of stream transformers written for the browser. It also lets web developers use stream transforms written for Deno on their website. For example, the std/streams module from Deno’s standard library can be used from both Deno and the browser to do things like split streams of text at newlines.

Readable streams are the most common type of stream, and are used when you want to read data from a source. For example, you might want to stream the response body of a HTTP request, or the contents of a file on disk.

Writable streams are the inverse - they are used when you want to write data to a destination in chunks. One such case is the sending side of a WebSocketStream (more on this below).

const body = new ReadableStream({
  start(controller) {
    controller.enqueue(new Uint8Array([1, 2, 3]));
    controller.enqueue(new Uint8Array([4, 5, 6]));

const resp = await fetch("", { body });
for await (const chunk of resp.body) {


Next to the low level stream primitives ReadableStream and WritableStream, the web also has a general purpose API to transform streaming data called TransformStream. They have a readable and a writable end, and a “transformer” function. For each chunk that is written to the writable end, the transformer function is called. It can then enqueue transformed chunks to the readable end for the consumer to read.

const input = new ReadableStream({
  start(controller) {
    controller.enqueue("Hello, ");

const transformer = new TransformStream({
  transform(chunk, controller) {

const output = input.pipeThrough(transformer);

for await (const chunk of output) {


As mentioned earlier, Deno implements the WebSocket API that is built on top of EventTarget. This can sometimes be pretty painful to use. As an alternative you can use the WebSocketStream API which is based on streams and promises. It is a lot easier to use when you are using async/await.

const wss = new WebSocketStream("wss://");
const { writable, readable } = await wss.connection;

const writer = writable.getWriter();
await writer.write("Hello server!");

for await (const message of readable) {
  console.log("new message:", message);

NOTE: this API is still experimental and may change in the future. You need to use the –unstable flag to use it.

TextEncoderStream and TextDecoderStream

The TextEncoderStream and TextDecoderStream are transform streams that can encode and decode strings to and from bytes in chunks. Unlike TextEncoder and TextDecoder are usually used for fully synchronous operations, TextEncoderStream and TextDecoderStream are fully streaming.

This API makes it super easy to convert the response stream from a fetch call to string chunks:

const response = await fetch("");
const body = response.body.pipeThrough(new TextDecoderStream());
for await (const chunk of body) {

CompressionStream and DecompressionStream

Another operation that often needs to performed on streaming data is compression and decompression. You can use CompressionStream to gzip compress some data before uploading to a storage bucket for example. When downloading that data again you can decompress it with DecompressionStream.

Just like Chrome, Deno supports gzip and deflate compression. Support for brotli compression is coming soon.

const response = await fetch("");
const body = response.body.pipeThrough(new CompressionStream("gzip"));
const file = await Deno.create("./file.gz");
for await (const chunk of body) {
  await file.write(chunk);

CompressionStream is available in the latest Deno canary build, but is not yet available in the 1.18 stable build. The first stable build it will be available in is Deno 1.19.


URLPattern is a new web API to match URLs against a path-to-regexp style pattern. It is super useful for creating routing systems for HTTP servers for example. The API is available in Chrome and Deno, and Firefox is interested in implementing it.

const pattern = new URLPattern({ pathname: "/hello/:name" });
const match = pattern.exec("");

alert, confirm and prompt

CLI applications often need to interact with the user to some extent. Deno implements the simple dialog APIs alert, confirm and prompt from the web platform for this purpose. You can alert a user with a message and wait for acknowledgement, ask the user to confirm a yes/no question, or prompt the user for a string response.

let name;
do {
  name = prompt("What is your name?");
} while (!confirm(`Is your name ${name}?`));
alert(`Hello, ${name}!`);

localStorage and sessionStorage

When writing CLI applications it is also often useful to persist a little bit of state across runs (for example an API access token). This can be done trivially with the localStorage API. It is a persistent key-value store for each Deno application.

const count = parseInt(localStorage.getItem("count") || "0");
console.log(`You have started the application ${count} times previously.`);
localStorage.setItem("count", count + 1);

The window.navigator object contains some useful information about the current system, like the number of available CPU cores / threads for example. navigator.hardwareConcurrency contains the number of logical CPU cores.

console.log("This system has", navigator.hardwareConcurrency, "CPU cores.");


All of the previous APIs have either been related to the CPU, or some I/O primitive. Deno also supports accessing the GPU through the WebGPU API. This low-level API can be thought of as “vulkan for the web”. It allows for efficient low level access to the GPU to perform rendering and compute tasks.

Deno bases it’s WebGPU implementation of the same Rust library that Firefox uses: wgpu.

const adapter = await navigator.gpu.requestAdapter();
console.log("GPU adapter:",;

// this blog post is already long enough, I won't go into
// low level GPU programming here :-)

NOTE: this API is still experimental and may change in the future. You need to use the –unstable flag to use it.


One lesser known web API is MessageChannel. It is a pair of streams that can be used to communicate between two workers. Each channel has two “ports”, each of which can be either kept in the current worker or transferred to another worker.

This allows for really complex communication channels between workers, without requiring a single centralized worker to act as a “message proxy”.

const channel = new MessageChannel();
const { port1, port2 } = channel;
port1.onmessage = (event) => {
port2.postMessage("Hello, world!");


BroadcastChannel is similar to MessageChannel in that it is a channel to communicate between workers. However, unlike MessageChannel, it is a 1 to many channel rather than a 1 to 1 channel.

const channel = new BroadcastChannel("my-channel");
channel.onmessage = (event) => {
channel.postMessage("Hello, world!");

NOTE: this API is still experimental and may change in the future. You need to use the –unstable flag to use it.