Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

dev

JWTs, URLs, semver, file permissions; networks, IDs, colors and codes below

Example results generated on 2026-10-08. Ones using now, today or randomness will differ when you run them: press Run on any example to run it in your browser, after editing it if you like.

Submodules

moduleabout
netIP addresses, CIDR blocks, subnets, well-known ports
idsUUIDs, ULIDs and nano IDs; secure passwords and passphrases
colorscolors as “#rrggbb”: RGB/HSL, mixing, lightening, WCAG contrast
codescheck digits for cards, ISBNs and IBANs; HTTP status and MIME type lookups

Functions

functiondescription
jwt(s: str)decode a JWT into {header, payload, signature} without verifying it; exp, iat and nbf become dates
url_parse(s: str)split a URL into {scheme, host, port, path, query, fragment}; the query becomes a map, and repeated keys a list
url_build(m: map)the URL for a map like the one url_parse makes; missing parts are left out
semver(s: str)parse a semantic version into {major, minor, patch, pre, build}; compares by version precedence, also against strings
bump(v: str|map, part: str)next “major”, “minor” or “patch” version; a pre-release bumps to its own release
perm(mode: int|str)Unix permissions between octal and rwx: 755 or 0o755 gives “rwxr-xr-x”, and back

jwt

jwt(s: str): decode a JWT into {header, payload, signature} without verifying it; exp, iat and nbf become dates

jwt("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZGEiLCJleHAiOjE5MjQ5OTIwMDB9.c2ln").payload.exp
# → 2030-12-31 18:00:00 -06:00

See also: decode, hmac

url_parse

url_parse(s: str): split a URL into {scheme, host, port, path, query, fragment}; the query becomes a map, and repeated keys a list

url_parse("https://example.com:8080/a/b?x=1&y=two%20words#top")
# → {scheme: "https", host: "example.com", port: 8080, path: "/a/b", query: {x: "1", y: "two words"}, fragment: "top"}

See also: url_build, encode

url_build

url_build(m: map): the URL for a map like the one url_parse makes; missing parts are left out

url_build({scheme: "https", host: "example.com", path: "/search", query: {q: "a b"}})
# → "https://example.com/search?q=a%20b"

See also: url_parse

semver

semver(s: str): parse a semantic version into {major, minor, patch, pre, build}; compares by version precedence, also against strings

semver("1.2.3") < semver("1.10.0")
# → true
semver("1.0.0-beta") < "1.0.0"
# → true
semver("v2.1.0-rc.1+build5")
# → {major: 2, minor: 1, patch: 0, pre: "rc.1", build: "build5"}

See also: bump

bump

bump(v: str|map, part: str): next “major”, “minor” or “patch” version; a pre-release bumps to its own release

bump("1.2.3", "minor")
# → "1.3.0"
bump("2.0.0-rc.1", "major")
# → "2.0.0"

See also: semver

perm

perm(mode: int|str): Unix permissions between octal and rwx: 755 or 0o755 gives “rwxr-xr-x”, and back

perm(755)
# → "rwxr-xr-x"
perm("rw-r--r--")
# → 0o644
perm(0o4755)
# → "rwsr-xr-x"

More examples

dev

# what's in this token?
jwt("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZGEiLCJpYXQiOjE1MTYyMzkwMjJ9.c2ln").payload
# → {sub: "ada", iat: 2018-01-17 19:30:22 -06:00}
# query string of a URL
url_parse("https://example.com/search?q=zil&page=2").query
# → {q: "zil", page: "2"}
# is 1.10 newer than 1.9?
semver("1.10.0") > "1.9.3"
# → true
# chmod 640 means
perm(640)
# → "rw-r-----"