---
title: "@std/ulid"
description: "Generation of Universally Unique Lexicographically Sortable Identifiers (ULIDs)"
jsr: jsr:@std/ulid
pkg: ulid
version: 1.0.0
generated: true
stability: stable
---
<!-- Autogenerated from JSR docs. Do not edit directly. -->

## Overview

<p>Utilities for generating and working with
<a href="https://github.com/ulid/spec" rel="nofollow">Universally Unique Lexicographically Sortable Identifiers (ULIDs)</a>.</p>
<p>To generate a ULID use the <a href="https://jsr.io/@std/ulid@1.0.0/doc/~/ulid" rel="nofollow"><code>ulid</code></a> function. This will generate a
ULID based on the current time.</p>

```js
import { ulid } from "@std/ulid";

ulid(); // 01HYFKMDF3HVJ4J3JZW8KXPVTY
```

<p><a href="https://jsr.io/@std/ulid@1.0.0/doc/~/ulid" rel="nofollow"><code>ulid</code></a> does not guarantee that the ULIDs will be strictly
increasing for the same current time. If you need to guarantee that the ULIDs
will be strictly increasing, even for the same current time, use the
<a href="https://jsr.io/@std/ulid@1.0.0/doc/~/monotonicUlid" rel="nofollow"><code>monotonicUlid</code></a> function.</p>

```js
import { monotonicUlid } from "@std/ulid";

monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAS
monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAT
```

<p>Because each ULID encodes the time it was generated, you can extract the
timestamp from a ULID using the <a href="https://jsr.io/@std/ulid@1.0.0/doc/~/decodeTime" rel="nofollow"><code>decodeTime</code></a> function.</p>

```js
import { decodeTime, ulid } from "@std/ulid";
import { assertEquals } from "@std/assert";

const timestamp = 150_000;
const ulidString = ulid(timestamp);

assertEquals(decodeTime(ulidString), timestamp);
```

### Add to your project

```sh
deno add jsr:@std/ulid
```

<a href="https://jsr.io/@std/ulid/doc" class="docs-cta jsr-cta">See all symbols in @std/ulid on
<svg class="inline ml-1" viewBox="0 0 13 7" aria-hidden="true" height="20"><path d="M0,2h2v-2h7v1h4v4h-2v2h-7v-1h-4" fill="#083344"></path><g fill="#f7df1e"><path d="M1,3h1v1h1v-3h1v4h-3"></path><path d="M5,1h3v1h-2v1h2v3h-3v-1h2v-1h-2"></path><path d="M9,2h3v2h-1v-1h-1v3h-1"></path></g></svg></a>

<!-- custom:start -->
<!-- Add persistent custom content below. This section is preserved across generations. -->

<!-- custom:end -->
