Skip to content

The Deno standard library: using @std packages from JSR

The Deno standard library is a set of TypeScript packages maintained by the Deno team. It isn’t built into the runtime: you install the packages you need like any other dependency. It covers things the runtime APIs leave out, such as recursive directory walking, file serving, date formatting, CSV and YAML parsing, and test assertions.

Each module is its own package under the @std scope on JSR, for example @std/fs, @std/path or @std/assert, and each is versioned independently. Most packages are stable (1.x) and follow semantic versioning. Some, such as @std/datetime, are still marked unstable, which means their API can change in a minor release. The packages have no third-party dependencies; they only depend on each other.

Add packages to a project with deno add, which records them in deno.json so you can import them by bare name:

Terminal window
deno add jsr:@std/fs jsr:@std/http
import { walk } from "@std/fs";

For a single script you can skip deno.json and import with a jsr: specifier, as the examples below do.

Reading and writing files is a runtime API (Deno.readTextFile, Deno.writeTextFile), not part of the standard library. @std/fs adds the higher-level operations: walk, expandGlob, ensureDir, copy, move, emptyDir and exists.

This lists every TypeScript file under the current directory:

import { walk } from "jsr:@std/fs@^1/walk";
for await (const entry of walk(".", { exts: [".ts"], includeDirs: false })) {
console.log(entry.path);
}

Run it with deno run --allow-read list.ts.

The HTTP server itself is built into the runtime as Deno.serve. @std/http provides helpers on top of it: static file serving, cookies, status code constants, content negotiation and user-agent parsing.

This server answers /static/... from the public directory and everything else with a plain response:

import { serveDir } from "jsr:@std/http@^1/file-server";
Deno.serve({ port: 8000 }, (req) => {
const { pathname } = new URL(req.url);
if (pathname.startsWith("/static")) {
return serveDir(req, { fsRoot: "public", urlRoot: "static" });
}
return new Response("Hello, world!\n");
});

Run it with deno run --allow-net --allow-read server.ts. A request to /static/logo.png is served from ./public/logo.png.

@std/datetime: parsing and formatting dates

Section titled “@std/datetime: parsing and formatting dates”

parse and format take format strings built from tokens like yyyy, MM, dd, HH and mm. This package is still unstable (0.x), so pin the version you tested with:

import { format, parse } from "jsr:@std/datetime@^0.225";
const date = parse("2023-05-07", "yyyy-MM-dd");
console.log(format(date, "dd/MM/yyyy")); // 07/05/2023

parse interprets the string in the local time zone. format accepts { timeZone: "UTC" } as a third argument if you want UTC output.

@std/uuid: generating and validating UUIDs

Section titled “@std/uuid: generating and validating UUIDs”

For random (v4) UUIDs you don’t need the standard library at all: crypto.randomUUID() is built in. @std/uuid adds validation and the other versions, such as name-based v5 UUIDs, which always produce the same ID for the same namespace and name:

import { NAMESPACE_URL, v4, v5 } from "jsr:@std/uuid@^1";
const random = crypto.randomUUID();
console.log(v4.validate(random)); // true
const data = new TextEncoder().encode("https://example.com/users/42");
const stable = await v5.generate(NAMESPACE_URL, data);
console.log(stable); // same value every run
  • Old code with unversioned https://deno.land/std/... imports is fragile. If you can’t migrate yet, pin a version (https://deno.land/std@0.224.0/...), then move to the matching jsr:@std/* packages.
  • Check the package page for a stability label before depending on a 0.x package such as @std/datetime in production code.
  • Some packages also run outside Deno. JSR shows runtime compatibility on each package page: @std/uuid, for example, is listed for Node.js, Bun and browsers, while @std/fs is Deno-only.

© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)