Skip to content

dev.ids

unique IDs (UUIDs, ULIDs, nano IDs) and strong passwords

Makes values meant to be unique or hard to guess. UUIDs, ULIDs and nano IDs name records, and passwords are drawn at random with a length and character set you choose.

Tags: random

  • uuid a new random UUID (version 4)
  • password a random password of letters, digits and symbols
  • passphrase random words joined by dashes, easier to type and remember than a password, each adding about 9.4 bits of strength
  • ulid a new ULID
  • nanoid a random ID made only of characters that are safe in URLs, about as unlikely to repeat as a UUID
  • uuid_info what kind of UUID this is (its version and variant)
uuid() -> str

a new random UUID (version 4)

A 36-character ID random enough that two never match, so it can be made anywhere without checking with anyone

1
uuid()"1ac87333-7c7a-410c-94ff-f610b6b3c9fd"
Example outputCtrl+Enter to run

See also uuid_info, ulid

password(len: int = 20) -> str

a random password of letters, digits and symbols

Each character adds about 6.5 bits of strength. Each bit doubles the guesses an attacker needs, and 80 bits or more is out of reach even for offline guessing

1
password()"AvrxYw4j4cvn@8*h@F4x"
2
password(12)"s^sk6NYkdiDa"
Example outputCtrl+Enter to run

See also passphrase

passphrase(words: int = 6) -> str

random words joined by dashes, easier to type and remember than a password, each adding about 9.4 bits of strength

1
passphrase()"foggy-perch-fossil-canoe-opera-pecan"
2
passphrase(4)"vague-viper-chief-carve"
Example outputCtrl+Enter to run

See also password

ulid() -> str

a new ULID

26 characters holding the time it was made and then 80 random bits, so sorting ULIDs sorts them by age

1
ulid()"01M6KW6QEG7YZ3NQBS54PZE621"
Example outputCtrl+Enter to run

See also uuid, nanoid

nanoid(len: int = 21) -> str

a random ID made only of characters that are safe in URLs, about as unlikely to repeat as a UUID

1
nanoid()"u-m85JB6KuH8cZ35tK_Ds"
2
nanoid(8)"pt2IM7J8"
Example outputCtrl+Enter to run

See also uuid, ulid

uuid_info(s: str) -> map

what kind of UUID this is (its version and variant)

Versions 1 and 7 start with the time they were made, which this reads back

1
uuid_info(uuid()){version: 4, variant: "RFC 9562"}
2
uuid_info("c232ab00-9414-11ec-b3c8-9f6bdeced846"){version: 1, variant: "RFC 9562", timestamp: 2022-02-22 13:22:22 -06:00}
Example outputCtrl+Enter to run

See also uuid

1
# a random ID
2
uuid()"9aa1fe9b-e329-4bad-a25c-17aaec5d3a81"
3
# when was this UUID made?
4
uuid_info("01890a5d-ac96-774b-bcce-b302099a8057").timestamp2023-06-29 22:34:18 -05:00
5
# an ID that sorts by time
6
ulid()"01M6KW6QEK602EXV6VZ6XXQMA9"
7
# a strong password
8
password()"i5UDeh?EnrsM=F%6V9MJ"
9
# one that's easier to type
10
passphrase()"naval-raven-helix-candy-lance-cloud"
Example outputCtrl+Enter to run

Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.