There are APIs that are built into the Deno CLI that are beyond those that are built-ins for JavaScript, including APIs that are unstable or experimental. In order to use APIs marked as unstable, you will need to use --unstable on the command line to make them available. All the APIs are a combination of web platform APIs Deno has implemented and Deno specific APIs.

We try to keep non-standard, Deno specific, APIs in the Deno namespace. We have grouped the APIs into the following functional categories.

Compression Streams API

An API for compressing a stream of data.

An API for decompressing a stream of data.

Console and Debugging

A symbol which can be used as a key for a custom method which will be called when Deno.inspect() is called, or when the object is logged to the console.

Converts the input into a string that has the same format as printed by console.log().

DOM APIs

The MessageChannel interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.

The MessagePort interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.

This type has been renamed to StructuredSerializeOptions. Use that type for new code.

Creates a deep copy of a given value using the structured clone algorithm.

DOM Events

An event which takes place in the DOM.

EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.

Events measuring progress of an underlying process, like an HTTP request (for an XMLHttpRequest, or the loading of the underlying resource of an , , , or ).

Registers an event listener in the global scope, which will be called synchronously whenever the event type is dispatched.

Dispatches an event in the global scope, synchronously invoking any registered event listeners for this event in the appropriate order. Returns false if event is cancelable and at least one of the event handlers which handled this event called Event.preventDefault(). Otherwise it returns true.

Remove a previously registered event listener from the global scope

Encoding API

Decodes a string of data which has been encoded using base-64 encoding.

Creates a base-64 ASCII encoded string from the input string.

ES Modules

Deno provides extra properties on import.meta. These are included here to ensure that these are still available when using the Deno namespace in conjunction with other type libs, like dom.

Fetch API

A custom HttpClient for use with fetch.

This Fetch API interface represents a resource request.

This Fetch API interface represents the response to a request.

The options used when creating a [HttpClient].

I
Deno.Proxy
unstable

Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".

Create a custom HttpClient for to use with fetch.

f
fetch
unstable

FFI

An unsafe function pointer for passing JavaScript functions as C function pointers to ffi calls.

An unsafe pointer to a function, for calling functions that are not present as symbols.

An unsafe pointer to a memory location for passing and returning pointers to and from the FFI.

An unsafe pointer view to a memory location as specified by the pointer value. The UnsafePointerView API mimics the standard built in interface DataView for accessing the underlying types at an memory location (numbers, strings and raw bytes).

A dynamic library resource

A foreign function as defined by its parameter and result types.

A foreign library interface descriptor.

Type conversion for foreign symbol return types.

Type conversion for foreign symbol return types and unsafe callback parameters.

All BigInt number types for interfacing with foreign functions.

All plain number types for interfacing with foreign functions.

All possible types for interfacing with foreign functions.

Pointer type depends on the architecture and actual pointer value.

Infers a foreign library interface.

Infers a foreign symbol.

Type conversion for unsafe callback return types.

Type conversion for foreign symbol parameters and unsafe callback return types.

f
Deno.dlopen
unstable

Opens a dynamic library and registers symbols

File System

c
Deno.File
deprecated

The Deno abstraction for reading and writing files.

The Deno abstraction for reading and writing files.

A FileInfo describes a file and is returned by stat, lstat, statSync, lstatSync.

FsWatcher is returned by Deno.watchFs function when you start watching the file system. You can iterate over this interface to get the file system events, and also you can stop watching the file system by calling .close() method.

Options for writing to a file.

Additional information for FsEvent objects with the "other" kind.

Changes the permission of a specific file/directory of specified path. Ignores the process's umask.

Synchronously changes the permission of a specific file/directory of specified path. Ignores the process's umask.

Change owner of a regular file or directory. This functionality is not available on Windows.

Synchronously change owner of a regular file or directory. This functionality is not available on Windows.

Copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. Fails if target path is a directory or is unwritable.

Synchronously copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. Fails if target path is a directory or is unwritable.

Creates a file if none exists or truncates an existing file and resolves to an instance of Deno.FsFile.

Creates a file if none exists or truncates an existing file and returns an instance of Deno.FsFile.

f
Deno.flock
unstable

Acquire an advisory file-system lock for the provided file. exclusive defaults to false.

Acquire an advisory file-system lock for the provided file. exclusive defaults to false.

Returns a Deno.FileInfo for the given file stream.

Synchronously returns a Deno.FileInfo for the given file stream.

Truncates or extends the specified file stream, to reach the specified len.

Synchronously truncates or extends the specified file stream, to reach the specified len.

f
Deno.funlock
unstable

Release an advisory file-system lock for the provided file.

Release an advisory file-system lock for the provided file.

f
Deno.futime
unstable

Changes the access (atime) and modification (mtime) times of a file stream resource referenced by rid. Given times are either in seconds (UNIX epoch time) or as Date objects.

Synchronously changes the access (atime) and modification (mtime) times of a file stream resource referenced by rid. Given times are either in seconds (UNIX epoch time) or as Date objects.

Creates newpath as a hard link to oldpath.

Synchronously creates newpath as a hard link to oldpath.

Resolves to a Deno.FileInfo for the specified path. If path is a symlink, information for the symlink will be returned instead of what it points to.

Synchronously returns a Deno.FileInfo for the specified path. If path is a symlink, information for the symlink will be returned instead of what it points to..

Creates a new temporary directory in the default directory for temporary files, unless dir is specified. Other optional options include prefixing and suffixing the directory name with prefix and suffix respectively.

Synchronously creates a new temporary directory in the default directory for temporary files, unless dir is specified. Other optional options include prefixing and suffixing the directory name with prefix and suffix respectively.

Creates a new temporary file in the default directory for temporary files, unless dir is specified. Other optional options include prefixing and suffixing the directory name with prefix and suffix respectively.

Synchronously creates a new temporary file in the default directory for temporary files, unless dir is specified. Other optional options include prefixing and suffixing the directory name with prefix and suffix respectively.

Creates a new directory with the specified path.

Synchronously creates a new directory with the specified path.

Open a file and resolve to an instance of Deno.FsFile. The file does not need to previously exist if using the create or createNew open options. It is the callers responsibility to close the file when finished with it.

Synchronously open a file and return an instance of Deno.FsFile. The file does not need to previously exist if using the create or createNew open options. It is the callers responsibility to close the file when finished with it.

Reads the directory given by path and returns an async iterable of Deno.DirEntry.

Synchronously reads the directory given by path and returns an iterable of Deno.DirEntry.

Reads and resolves to the entire contents of a file as an array of bytes. TextDecoder can be used to transform the bytes to string if required. Reading a directory returns an empty data array.

Synchronously reads and returns the entire contents of a file as an array of bytes. TextDecoder can be used to transform the bytes to string if required. Reading a directory returns an empty data array.

Resolves to the full path destination of the named symbolic link.

Returns the full path destination of the named symbolic link.

Asynchronously reads and returns the entire contents of a file as utf8 encoded string. Reading a directory throws an error.

Synchronously reads and returns the entire contents of a file as utf8 encoded string. Reading a directory throws an error.

Resolves to the absolute normalized path, with symbolic links resolved.

Returns absolute normalized path, with symbolic links resolved.

Removes the named file or directory.

Synchronously removes the named file or directory.

Renames (moves) oldpath to newpath. Paths may be files or directories. If newpath already exists and is not a directory, rename() replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.

Synchronously renames (moves) oldpath to newpath. Paths may be files or directories. If newpath already exists and is not a directory, renameSync() replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.

Resolves to a Deno.FileInfo for the specified path. Will always follow symlinks.

Synchronously returns a Deno.FileInfo for the specified path. Will always follow symlinks.

Creates newpath as a symbolic link to oldpath.

Creates newpath as a symbolic link to oldpath.

Truncates or extends the specified file, to reach the specified len. If len is not specified then the entire file contents are truncated.

Synchronously truncates or extends the specified file, to reach the specified len. If len is not specified then the entire file contents are truncated.

f
Deno.umask
unstable

Retrieve the process umask. If mask is provided, sets the process umask. This call always returns what the umask was before the call.

f
Deno.utime
unstable

Changes the access (atime) and modification (mtime) times of a file system object referenced by path. Given times are either in seconds (UNIX epoch time) or as Date objects.

Synchronously changes the access (atime) and modification (mtime) times of a file system object referenced by path. Given times are either in seconds (UNIX epoch time) or as Date objects.

Watch for file system events against one or more paths, which can be files or directories. These paths must exist already. One user action (e.g. touch test.file) can generate multiple file system events. Likewise, one user action can result in multiple file paths in one event (e.g. mv old_name.txt new_name.txt). Recursive option is true by default and, for directories, will watch the specified directory and all sub directories. Note that the exact ordering of the events can vary between operating systems.

Write data to the given path, by default creating a new file if needed, else overwriting.

Synchronously write data to the given path, by default creating a new file if needed, else overwriting.

Asynchronously write string data to the given path, by default creating a new file if needed, else overwriting.

Synchronously write string data to the given path, by default creating a new file if needed, else overwriting.

HTTP Server

A handler for HTTP requests. Consumes a request and returns a response.

f
Deno.serve
unstable

Services HTTP requests given a TCP or TLS socket.

Allows "hijacking" the connection that the request is associated with. This can be used to implement protocols that build on top of HTTP (eg. WebSockets).

Allows "hijacking" the connection that the request is associated with. This can be used to implement protocols that build on top of HTTP (eg. WebSockets).

I/O

c
Deno.Buffer
deprecated

A variable-sized buffer of bytes with read() and write() methods.

A handle for stderr.

A handle for stdin.

A handle for stdout.

Close the given resource ID (rid) which has been previously opened, such as via opening or creating a file. Closing a file when you are finished with it is important to avoid leaking resources.

Gets the size of the console as columns/rows.

f
Deno.copy
deprecated

Copies from src to dst until either EOF (null) is read from src or an error occurs. It resolves to the number of bytes copied or rejects with the first error encountered while copying.

Flushes any pending data operations of the given file stream to disk.

Synchronously flushes any pending data operations of the given file stream to disk.

Flushes any pending data and metadata operations of the given file stream to disk.

Synchronously flushes any pending data and metadata operations of the given file stream to disk.

Check if a given resource id (rid) is a TTY.

f
Deno.iter
deprecated

Turns a Reader, r, into an async iterator.

f
Deno.iterSync
deprecated

Turns a ReaderSync, r, into an iterator.

Read from a resource ID (rid) into an array buffer (buffer).

f
Deno.readAll
deprecated

Read Reader r until EOF (null) and resolve to the content as Uint8Array`.

f
Deno.readAllSync
deprecated

Synchronously reads Reader r until EOF (null) and returns the content as Uint8Array.

Synchronously read from a resource ID (rid) into an array buffer (buffer).

Seek a resource ID (rid) to the given offset under mode given by whence. The call resolves to the new position within the resource (bytes from the start).

Synchronously seek a resource ID (rid) to the given offset under mode given by whence. The new position within the resource (bytes from the start) is returned.

f
Deno.setRaw
unstable

Set TTY to be under raw mode or not. In raw mode, characters are read and returned as is, without being processed. All special processing of characters by the terminal is disabled, including echoing input characters. Reading from a TTY device in raw mode is faster than reading from a TTY device in canonical mode.

Write to the resource ID (rid) the contents of the array buffer (data).

f
Deno.writeAll
deprecated

Write all the content of the array buffer (arr) to the writer (w).

Synchronously write all the content of the array buffer (arr) to the writer (w).

Synchronously write to the resource ID (rid) the contents of the array buffer (data).

Network

If resolveDns is called with "CAA" record type specified, it will return an array of this interface.

A generic transport listener for message-oriented protocols.

I
Deno.Listener
unstable

If resolveDns is called with "MX" record type specified, it will return an array of this interface.

If resolveDns is called with "NAPTR" record type specified, it will return an array of this interface.

The information of the network interface.

If resolveDns is called with "SOA" record type specified, it will return an array of this interface.

If resolveDns is called with "SRV" record type specified, it will return an array of this interface.

I
Deno.TlsConn
unstable

Specialized listener that accepts TLS connections.

The type of the resource record. Only the listed types are supported currently.

f
Deno.connect
unstable

Create a TLS connection with an attached client certificate.

f
Deno.listen
unstable

Listen announces on the local transport address.

Listen announces on the local transport address.

Listen announces on the local transport address over TLS (transport layer security).

Returns an array of the network interface information.

Shutdown socket send operations.

Start TLS handshake from an existing connection using an optional list of CA certificates, and hostname (default is "127.0.0.1"). Specifying CA certs is optional. By default the configured root certificates are used. Using this function requires that the other end of the connection is prepared for a TLS handshake.

Observability

f
Deno.loadavg
unstable

Returns an array containing the 1, 5, and 15 minute load averages. The load average is a measure of CPU and IO utilization of the last one, five, and 15 minute periods expressed as a fractional number. Zero means there is no load. On Windows, the three values are always the same and represent the current load, not the 1, 5 and 15 minute load averages.

Receive metrics from the privileged side of Deno. This is primarily used in the development of Deno. 'Ops', also called 'bindings', are the go-between between Deno JavaScript and Deno Rust.

Returns a map of open resource ids (rid) along with their string representations. This is an internal API and as such resource representation has any type; that means it can change any time.

Performance API

Encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the .mark() method) at an explicit point in an application.

PerformanceMark is an abstract interface for PerformanceEntry objects with an entryType of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the performance timeline.

PerformanceMeasure is an abstract interface for PerformanceEntry objects with an entryType of "measure". Entries of this type are created by calling performance.measure() to add a named DOMHighResTimeStamp (the measure) between two marks to the performance timeline.

Runtime Environment

Returns the script arguments to the program. If for example we run a program:

Build related information.

The URL of the entrypoint module entered from the command-line.

Reflects the NO_COLOR environment variable at program start.

The current process id of the runtime.

The pid of the current process's parent.

Version related information.

Registers the given function as a listener of the given signal event.

Change the current working directory to the specified path.

Return a string representing the current working directory.

Returns the path to the current deno executable.

Exit the Deno process with optional exit code. If no exit code is supplied then Deno will exit with return code of 0.

f
Deno.getGid
unstable

Returns the group id of the process on POSIX platforms. Returns null on windows.

f
Deno.getUid
unstable

Returns the user id of the process on POSIX platforms. Returns null on Windows.

f
Deno.hostname
unstable

Get the hostname of the machine the Deno process is running on.

Returns an object describing the memory usage of the Deno process measured in bytes.

Returns the release version of the Operating System.

Removes the given signal listener that has been registered with Deno.addSignalListener.

Displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel.

Scheduling

A microtask is a short function which is executed after the function or module which created it exits and only if the JavaScript execution stack is empty, but before returning control to the event loop being used to drive the script's execution environment. This event loop may be either the main event loop or the event loop driving a web worker.

Streams API

This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.

This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.

This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.

This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate.

This Streams API interface is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink.

Sub Process

c
Deno.Child
unstable

Send a signal to process under given pid.

f
Deno.run
unstable
f
Deno.spawn
unstable

Executes a subprocess, waiting for it to finish and collecting all of its output. Will throw an error if stdin: "piped" is passed.

Spawns a child process.

Synchronously executes a subprocess, waiting for it to finish and collecting all of its output. Will throw an error if stdin: "piped" is passed.

Testing

f
Deno.bench
unstable

Register a bench which will be run when deno bench is used on the command line and the containing module looks like a bench module. fn can be async if required. Declared function must have a name.

Register a test which will be run when deno test is used on the command line and the containing module looks like a test module. fn can be async if required.

Timers

Cancels a timed, repeating action which was previously started by a call to setInterval()

Cancels a scheduled action initiated by setTimeout()

f
Deno.refTimer
unstable

Make the timer of the given id blocking the event loop from finishing.

Make the timer of the given id not blocking the event loop from finishing.

Repeatedly calls a function , with a fixed time delay between each call.

Sets a timer which executes a function once after the timer expires. Returns an id which may be used to cancel the timeout.

Web APIs

A controller object that allows you to abort one or more DOM requests as and when desired.

The location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Accessible via globalThis.location.

The URL interface represents an object providing static methods used for creating object URLs.

The URLPattern API provides a web platform primitive for matching URLs based on a convenient pattern syntax.

A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object.

URLPatternResult is the object returned from URLPattern.exec.

Shows the given message and waits for the enter key pressed.

Shows the given message and waits for the answer. Returns the user's answer as boolean.

Shows the given message and waits for the user's input. Returns the user's input as string.

Dispatch an uncaught exception. Similar to a synchronous version of:

Web Crypto API

The CryptoKey dictionary of the Web Crypto API represents a cryptographic key.

The CryptoKeyPair dictionary of the Web Crypto API represents a key pair for an asymmetric cryptography algorithm, also known as a public-key algorithm.

This Web Crypto API interface provides a number of low-level cryptographic functions. It is accessed via the Crypto.subtle properties available in a window context (via Window.crypto).

Web File API

A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.

Provides information about files and allows JavaScript in a web page to access their content.

Lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read.

Web Sockets

Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.

Used to upgrade an incoming HTTP request to a WebSocket.

Web Storage API

This Web Storage API interface provides access to a particular domain's session or local storage. It allows, for example, the addition, modification, or deletion of stored data items.

WebAssembly

The WebAssembly.CompileError object indicates an error during WebAssembly decoding or validation.

A WebAssembly.Global object represents a global variable instance, accessible from both JavaScript and importable/exportable across one or more WebAssembly.Module instances. This allows dynamic linking of multiple modules.

A WebAssembly.Instance object is a stateful, executable instance of a WebAssembly.Module. Instance objects contain all the Exported WebAssembly functions that allow calling into WebAssembly code from JavaScript.

The WebAssembly.LinkError object indicates an error during module instantiation (besides traps from the start function).

The WebAssembly.Memory object is a resizable ArrayBuffer or SharedArrayBuffer that holds the raw bytes of memory accessed by a WebAssembly Instance.

A WebAssembly.Module object contains stateless WebAssembly code that has already been compiled by the browser — this can be efficiently shared with Workers, and instantiated multiple times.

The WebAssembly.RuntimeError object is the error type that is thrown whenever WebAssembly specifies a trap.

The WebAssembly.Table() object is a JavaScript wrapper object — an array-like structure representing a WebAssembly Table, which stores function references. A table created by JavaScript or in WebAssembly code will be accessible and mutable from both JavaScript and WebAssembly.

The GlobalDescriptor describes the options you can pass to new WebAssembly.Global().

The MemoryDescriptor describes the options you can pass to new WebAssembly.Memory().

A ModuleExportDescriptor is the description of a declared export in a WebAssembly.Module.

A ModuleImportDescriptor is the description of a declared import in a WebAssembly.Module.

The TableDescriptor describes the options you can pass to new WebAssembly.Table().

The value returned from WebAssembly.instantiate.

The WebAssembly.compile() function compiles WebAssembly binary code into a WebAssembly.Module object. This function is useful if it is necessary to compile a module before it can be instantiated (otherwise, the WebAssembly.instantiate() function should be used).

The WebAssembly.compileStreaming() function compiles a WebAssembly.Module directly from a streamed underlying source. This function is useful if it is necessary to a compile a module before it can be instantiated (otherwise, the WebAssembly.instantiateStreaming() function should be used).

The WebAssembly.instantiate() function allows you to compile and instantiate WebAssembly code.

The WebAssembly.instantiateStreaming() function compiles and instantiates a WebAssembly module directly from a streamed underlying source. This is the most efficient, optimized way to load wasm code.

The WebAssembly.validate() function validates a given typed array of WebAssembly binary code, returning whether the bytes form a valid wasm module (true) or not (false).

WebGPU