The Filesystem APIs

Learn to apply different file operations using the filesystem APIs in Deno.

We'll cover the following

APIs for reading the filesystem

Accessing the filesystem is one of the basic needs we have when writing programs. As we have probably already seen in the documentation, Deno provides APIs to do these common tasks.

With a decision to standardize communication with the Rust core, all of these APIs return Uint8Array, and the decoding and encoding should be made by their consumers. This is a substantial difference from Node.js, where some functions return converted formats, and others return blobs, buffers, etc.

Let’s explore these filesystem APIs and read the contents of a file. We’re going to read the example file sentence.txt using the TextDecoder and Deno.readFile APIs, as the following script demonstrates:

Get hands-on with 1200+ tech skills courses.