UUID guide
UUID v4 vs UUID v7
UUID v4 is random. UUID v7 includes time information, so newly generated IDs sort more naturally by creation time.
Which UUID version to pick
Both versions are useful, but they solve slightly different problems. UUID v4 is familiar and random. UUID v7 is newer and friendlier for ordered records, logs, and database indexes.
Example
Need random test IDs: choose v4
Need time-ordered IDs: choose v7
Use the UUID Generator to create either version in single or batch output.
A practical rule
- Use UUID v4 when you only need random unique-looking IDs for tests, fixtures, and prototypes.
- Use UUID v7 when sort order by creation time helps your logs, tables, or generated records.
- Keep one version within a dataset unless you have a clear reason to mix them.
Database and log behavior
UUID v7 can be easier to inspect in logs because values generated close together tend to stay close together when sorted. That can also be helpful for database indexes that dislike completely random insert order.
UUID v4 is still a good default for simple test data and systems that already expect random UUIDs. Do not migrate only because a newer version exists.
Common mistakes
- Assuming UUID v7 is simply shorter or more secure than v4
- Mixing versions in fixtures without documenting why
- Depending on UUID order when the chosen version is random
- Using generated test IDs as secrets
Related problems
FAQ
Is UUID v7 random?
UUID v7 includes a timestamp portion and random bits. It is designed to be sortable by time while still keeping strong uniqueness properties.
Should I replace every UUID v4 with v7?
Not automatically. Existing systems can keep v4 unless ordered generation solves a real problem.
Can I generate UUID v4 and v7 in batches?
Yes. The UUID Generator can create either version in bulk.