https://github.com/jetpack-io/typeid Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. {{ message }} jetpack-io / typeid Public * Notifications * Fork 1 * Star 472 Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs License Apache-2.0 license 472 stars 1 fork Star Notifications * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights jetpack-io/typeid This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 1 tag Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/j] Use Git or checkout with SVN using the web URL. [gh repo clone jetpac] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @loreto loreto Add 'new' to example in README (#44) ... dbc7a5b Jun 28, 2023 Add 'new' to example in README (#44) This fixes the example in the readme. It's supposed to be `typeid new` dbc7a5b Git stats * 11 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows Improve github action workflows (#36) June 27, 2023 11:02 cli Implement typeid cli, and add FromX constructors (#25) June 14, 2023 16:26 .gitignore Jl/typeid add devbox (#43) June 28, 2023 10:53 .goreleaser.yaml Use .Tag instead of .Version in goreleaser (#40) June 27, 2023 15:28 CODE_OF_CONDUCT.md Clean up opensource typeid code so we can publish it (#18) June 7, 2023 10:49 LICENSE Clean up opensource typeid code so we can publish it (#18) June 7, 2023 10:49 README.md Add 'new' to example in README (#44) June 28, 2023 14:09 devbox.json Jl/typeid add devbox (#43) June 28, 2023 10:53 devbox.lock Jl/typeid add devbox (#43) June 28, 2023 10:53 go.mod Test and build go modules in opensource monorepo (#32) June 26, 2023 14:24 go.sum Test and build go modules in opensource monorepo (#32) June 26, 2023 14:24 main.go Implement typeid cli, and add FromX constructors (#25) June 14, 2023 16:26 View code TypeID A type-safe, K-sortable, globally unique identifier inspired by Stripe IDs What is it? Benefits Implementations Command-line Tool Related Work README.md TypeID A type-safe, K-sortable, globally unique identifier inspired by Stripe IDs License: Apache 2.0 Join Discord Built with Devbox What is it? TypeIDs are a modern, type-safe extension of UUIDv7. TypeIDs are canonically encoded as lowercase strings consisting of three parts: 1. A type prefix 2. An underscore '_' separator 3. A 128-bit UUIDv7 encoded as a 26-character string in base32 (using Crockford's alphabet in lowercase). Here's an example of a TypeID of type user: user_2x4y6z8a0b1c2d3e4f5g6h7j8k +--+ +------------------------+ type uuid suffix (base32) Benefits * 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 Language Status Go Implemented Python ... Coming Soon Rust ... Coming Soon SQL Implemented TypeScript ... Coming Soon We are looking for community contributions to implement TypeIDs in other languages. Command-line Tool This repo includes a command-line tool for generating TypeIDs. To install it, run: curl -fsSL https://get.jetpack.io/typeid | bash To generate a new TypeID, run: $ typeid new prefix prefix_01h2xcejqtf2nbrexx3vqjhp41 To decode an existing TypeID into a UUID run: $ typeid decode prefix_01h2xcejqtf2nbrexx3vqjhp41 type: prefix uuid: 0188bac7-4afa-78aa-bc3b-bd1eef28d881 And to encode an existing UUID into a TypeID run: $ typeid encode prefix 0188bac7-4afa-78aa-bc3b-bd1eef28d881 prefix_01h2xcejqtf2nbrexx3vqjhp41 Related Work * UUIDv7 - The upcoming UUID standard that TypeIDs are based on. Alternatives to UUIDv7 that are also worth considering (but not type-safe like TypeIDs): * xid * ulid * ksuid About Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs Topics uuid guid uuidv7 typeid Resources Readme License Apache-2.0 license Code of conduct Code of conduct Stars 472 stars Watchers 12 watching Forks 1 fork Report repository Releases 1 v0.1.0 Latest Jun 27, 2023 Packages 0 No packages published Contributors 2 * @loreto loreto Daniel Loreto * @Lagoja Lagoja John Lago Languages * Go 100.0% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.