Practical guide
Generate random version 4 UUIDs for application records, fixtures or temporary identifiers. Their familiar shape makes them easy to carry between tools, but they do not encode a creation time or sequence.
Steps that matter
- Choose the number of identifiers needed for your task.
- Generate the batch and copy the values in the format your application expects.
- Use a database uniqueness constraint when identifiers must be unique within stored records.
Worked example
In the pattern xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, the 4 identifies version 4 and y is one of 8, 9, a or b. The other positions vary between generated UUIDs.
Check before using the result
- UUIDs are identifiers, not an authorization system. Knowing an identifier must not grant access to another user’s private record.
- Random UUID order does not represent creation order. Store a separate timestamp when chronology matters.