Most developers first encounter UUIDs when setting up database primary keys. But UUIDs solve problems far beyond the database — and once you start using them, you'll wonder why you ever reached for auto-increment.

The Problem with Sequential IDs

Auto-increment IDs are fast and small, but they leak information. Every /users/42 tells an attacker there are at least 42 users. Every /orders/1087 reveals your order volume. In a REST API, sequential IDs are an enumeration attack waiting to happen.

UUIDs fix this by being unguessable. /users/550e8400-e29b-41d4-a716-446655440000 tells an attacker nothing.

Beyond the Database: Where UUIDs Shine