CalculatorsConvertersDeveloperTextAll toolsDirectory
Submit your tool Sign in
Theme
Home/Answers/Security
How-to

How do I generate a time-ordered UUID v7 for database keys?

Short answer

Use a browser-based UUID v7 generator to create sortable, time-ordered version-7 UUIDs that work well as database primary keys. They are generated on your device and never sent to a server.

Why v7 is better for database keys than v4

A version-7 UUID puts a timestamp in its leading bits, so rows created in order also sort in order. That keeps a database index compact and insertions efficient, which is exactly where fully random v4 UUIDs cause fragmentation. If you want the uniqueness of a UUID without hurting index locality, v7 is the version to reach for.

Create them in bulk, privately

A client-side generator builds v7 UUIDs in your browser, so you can create one or a batch without sending anything to a server. That is handy for seeding test data or generating keys during development. It is free and needs no account.

Step by step

  1. Open the generator. Open the UUID v7 generator in your browser.
  2. Generate keys. Generate a single v7 UUID or a bulk set for your table.
  3. Copy and use. Copy the time-ordered UUIDs and use them as primary keys.

Frequently asked questions

Why is v7 sortable?

A v7 UUID encodes a timestamp in its leading bits, so newer values sort after older ones.

Is v7 better than v4 for indexes?

For insertion-ordered keys, yes, because time ordering keeps the index compact.

Are the UUIDs generated online?

No. They are created in your browser and never uploaded.

Related answers