Developer Workflow
Generate UUIDs for realistic test data
Learn when to use random UUIDs for fixtures, mock API payloads, database seed rows, and repeatable local testing.
Problem
Tests and demos often need IDs that look like production identifiers. Reusing short fake values like 123 can hide bugs in parsing, validation, uniqueness checks, and copy-pasted examples.
When to use this
- A fixture or mock API response needs IDs that look like real records.
- A database seed file needs unique identifiers without copying production data.
- A support example should avoid exposing real user, order, or tenant IDs.
Steps
- Step 1
Choose the UUID count
Decide how many unique IDs you need for the fixture, seed file, or manual test case before generating values.
- Step 2
Generate random UUIDs
Use the UUID generator to create version 4 UUIDs when you only need unique-looking IDs for local tests or examples.
- Step 3
Replace production IDs
Swap real IDs in payloads, screenshots, or tickets with generated UUIDs while keeping the same field names and structure.
- Step 4
Keep deterministic IDs when tests require them
If a snapshot test expects exact output, save generated UUIDs in the fixture instead of generating new values on every run.
Example
Mock API response with UUID fields
Input
{"userId":"replace-me","organizationId":"replace-me","requestId":"replace-me"}Output
{"userId":"3f2e2b6a-7f2c-4e3a-9a21-6e98785f4c20","organizationId":"7a6b3d94-44e3-4a70-85c0-31278f7d1b42","requestId":"b91d1c0e-6ef2-49e5-9f59-1f81d4f3be76"}Common mistakes
Generating new UUIDs inside stable tests
Random values can make snapshots and assertions flaky. Generate once, then commit the fixture values when stability matters.
Using UUIDs as proof of security
UUIDs are identifiers, not permissions. Do not rely on an unguessable-looking ID instead of authentication and authorization checks.
FAQ
Which UUID version should I use for test data?
Version 4 UUIDs are usually fine for mock payloads, fixtures, and local seed data because they are random and widely recognized.
Are UUIDs safe to show in examples?
Generated UUIDs are safe for examples when they are not copied from production systems and do not map to real records.
Can duplicate UUIDs happen?
The chance is extremely small for properly generated version 4 UUIDs, but application code should still handle uniqueness constraints correctly.