Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

jetify-com/typeid

Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

jetify-com/typeid.json
{
"createdAt": "2023-06-07T21:29:58Z",
"defaultBranch": "main",
"description": "Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs",
"fullName": "jetify-com/typeid",
"homepage": "",
"language": "Go",
"name": "typeid",
"pushedAt": "2025-11-07T19:07:25Z",
"stargazersCount": 3431,
"topics": [
"guid",
"typeid",
"uuid",
"uuidv7"
],
"updatedAt": "2025-11-25T10:52:53Z",
"url": "https://github.com/jetify-com/typeid"
}

A type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

Section titled “A type-safe, K-sortable, globally unique identifier inspired by Stripe IDs”

License: Apache 2.0 Join Discord Built with Devbox

TypeIDs are a modern, type-safe extension of UUIDv7. Inspired by a similar use of prefixes in Stripe’s APIs.

TypeIDs are canonically encoded as lowercase strings consisting of three parts:

  1. A type prefix (at most 63 characters in all lowercase snake_case ASCII [a-z_]).
  2. An underscore ’_’ separator
  3. A 128-bit UUIDv7 encoded as a 26-character string using a modified base32 encoding.

Here’s an example of a TypeID of type user:

user_2x4y6z8a0b1c2d3e4f5g6h7j8k
└──┘ └────────────────────────┘
type uuid suffix (base32)

A [formal specification]!(./spec) defines the encoding in more detail.

You can try converting UUID to TypeID and back using Jetify’s TypeID Converter. Paste your TypeID string to convert to UUID or put your prefix and UUID in this format: prefix:UUID to convert to TypeID.

  • Type-safe: you can’t accidentally use a user ID where a post ID is expected. When debugging, you can immediately understand what type of entity a TypeID refers to thanks to the type prefix.
  • Compatible with UUIDs: TypeIDs are a superset of UUIDs. They are based on the upcoming UUIDv7 standard. If you decode the TypeID and remove the type information, you get a valid UUIDv7.
  • K-Sortable: TypeIDs are K-sortable and can be used as the primary key in a database while ensuring good locality. Compare to entirely random global ids, like UUIDv4, that generally suffer from poor database locality.
  • Thoughtful encoding: the base32 encoding is URL safe, case-insensitive, avoids ambiguous characters, can be selected for copy-pasting by double-clicking, and is a more compact encoding than the traditional hex encoding used by UUIDs (26 characters vs 36 characters).

Implementations should adhere to the formal [specification]!(./spec).

Latest spec version: v0.3.0

LanguageStatusSpec Version
Go✓ Implementedv0.3
SQL✓ Implementedv0.2
TypeScript✓ Implementedv0.3
LanguageAuthorSpec Version
C# (.Net)@TenCoKaciStromyv0.2 on 2023-06-30
C# (.Net Standard 2.1)@cbuctokv0.2 on 2023-07-03
C# (.NET)@firenerov0.3 on 2024-04-15
Dart@mistermoe @tbd54566975v0.3 on 2024-07-02
Elixir@sloanelybutsurelyv0.3 on 2024-04-22
Elixir@xinzv0.1 on 2024-06-03
Erlang@eproxusv0.3 on 2024-09-25
Gleam@okkdevv0.3 on 2025-07-09
Haskell@MMZK1526v0.3 on 2024-04-19
Java@fxlaev0.3 on 2024-04-14
Java@softpropsv0.2 on 2023-07-04
Kotlin@alerisv0.3 on 2024-05-18
Lua@pushcxv0.3 on 2025-05-21
OCaml@titouancreachv0.3 on 2024-04-22
PHP@BaseCodeOyv0.3 on 2024-12-06
Postgres@blitssv0.3 on 2024-06-24
Python@akhundMuradv0.3 on 2024-04-19
Ruby@broothiev0.3 on 2024-04-13
Rust@conradludgatev0.3 on 2024-04-12
Rust@johnnynotsoluckyv0.3 on 2024-05-17
Rust@Govcraftv0.3 on 2024-07-15
Scala@ant8ev0.3 on 2024-04-19
Scala@guizmaiiNot validated yet
Swift@Frizlabv0.3 on 2024-04-19
T-SQL@uniteeiov0.2 on 2023-08-25
TypeScript@ongteckwuv0.2 on 2023-06-30
Zig@nikoksrv0.3 on 2024-12-29

We are looking for community contributions to implement TypeIDs in other languages.

This repo includes a command-line tool for generating TypeIDs. To install it, run:

Terminal window
curl -fsSL https://get.jetify.com/typeid | bash

To generate a new TypeID, run:

Terminal window
$ typeid new prefix
prefix_01h2xcejqtf2nbrexx3vqjhp41

To decode an existing TypeID into a UUID run:

Terminal window
$ typeid decode prefix_01h2xcejqtf2nbrexx3vqjhp41
type: prefix
uuid: 0188bac7-4afa-78aa-bc3b-bd1eef28d881

And to encode an existing UUID into a TypeID run:

Terminal window
$ typeid encode prefix 0188bac7-4afa-78aa-bc3b-bd1eef28d881
prefix_01h2xcejqtf2nbrexx3vqjhp41
  • UUIDv7 - The upcoming UUID standard that TypeIDs are based on.

Alternatives to UUIDv7 that are also worth considering (but not type-safe like TypeIDs):