How I use ULIDs when sortable IDs help
· 2 min read
A ULID is an identifier that includes a timestamp part, so generated IDs sort roughly by creation time.
The ULID Generator tool helps with the mechanical part, but I still check the result before using it somewhere real.
The simple idea
A ULID is an identifier that includes a timestamp part, so generated IDs sort roughly by creation time.
I use the tool to make the transformation visible: input on one side, output on the other, and a quick sanity check before I copy anything.
Step 1: Generate a single ULID to see the format
Generate a single ULID to see the format.
Step 2: Generate several and notice the sort order
Generate several and notice the sort order.
Step 3: Use ULIDs when chronological sorting is helpful
Use ULIDs when chronological sorting is helpful.
Step 4: Avoid ULIDs when revealing creation time is a problem
Avoid ULIDs when revealing creation time is a problem.
Step 5: Store them consistently as uppercase strings unless your system chooses otherwise
Store them consistently as uppercase strings unless your system chooses otherwise.
Step 6: Do not use ULIDs as secrets
Do not use ULIDs as secrets.
Step 7: Compare with UUIDs before choosing an ID format for a project
Compare with UUIDs before choosing an ID format for a project.
My checklist
Before I trust the result, I check:
- Generate a single ULID to see the format.
- Generate several and notice the sort order.
- Use ULIDs when chronological sorting is helpful.
- Avoid ULIDs when revealing creation time is a problem.
- Store them consistently as uppercase strings unless your system chooses otherwise.
- Do not use ULIDs as secrets.
- Compare with UUIDs before choosing an ID format for a project.
Small utilities are useful because they remove repetitive work. They are safest when the output is still reviewed.
Comments
Comments are welcome — please read the comment policy first. Powered by giscus and GitHub Discussions.