Every test suite and seed script eventually needs rows, and every row needs an identifier. The lazy options are all traps: sequential numbers that behave nothing like production keys, placeholder strings like "test-id-1" that a real UUID column will reject, or the same famous example UUID pasted into forty fixtures. Then the tests pass against data that production would never produce, and the first real bug arrives as a surprise.
The fix is to fill fixtures with genuine identifiers, generated the same way production generates them. This guide shows how to do that with the UUID Generator on Ovatly, which creates version 4 UUIDs in batches of up to 100, and how to keep the resulting files readable instead of turning them into walls of hex.
Contents
- Quick answer
- Why test data needs real UUIDs
- How to generate a batch, step by step
- Worked example: seeding a small test table
- Why fresh values beat one copied UUID
- Keeping fixtures readable
- Limitations
- Common mistakes
- FAQs
- Conclusion
Quick answer
Open the UUID Generator, choose how many UUIDs your seed script or fixture file needs (from 1 to 100), press Generate UUIDs, then use Copy all to take the whole list, one per line. Paste the values straight into your fixture: each one is a version 4 UUID with 122 random bits, in the canonical lowercase hyphenated form most databases and APIs expect. Need more than 100? Generate again; every press produces a fresh batch, and values are never repeated or stored.
Why test data needs real UUIDs
A fixture has one job: stand in for production data faithfully enough that tests mean something. Identifiers are where that faithfulness usually breaks. If your production table uses UUID primary keys but your fixtures use integers or readable slugs, you never test the real column type, the real index behaviour or the real API validation. Code that serialises, compares or parses identifiers goes untested on the exact values it will meet in production.
Real UUIDs also protect you from a subtler failure: tests that only pass because the fake IDs are convenient. Sequential fixture IDs sort neatly, fit in small integers and never collide. Random UUIDs do none of those things, which is precisely why they expose ordering assumptions and uniqueness bugs while the code is still on your machine.
How to generate a batch, step by step
- Open the UUID Generator and decide how many records your fixture needs. Count the rows first; generating the right number once beats patching the file later.
- Choose that number, from 1 to 100, and press Generate UUIDs. Batches of 100 are instant, because generation happens locally in your browser using its cryptographic random source.
- Use Copy all to take the whole list, one per line, or copy single values for one-off records.
- Paste the list into your seed script or fixture file, one UUID per record, and fill in the remaining fields around them.
- If the fixture grows, generate a second batch and append it. Fresh values never repeat an earlier batch, so there is nothing to check for duplicates.
Worked example: seeding a small test table
Suppose a test needs 25 user records. Set the count to 25, generate, and Copy all. You now have 25 lines, each a value in the pattern xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, with the third group starting with 4 and the fourth group starting with 8, 9, a or b. Paste them into the fixture as the id column, one per record, and write the names, emails and other fields around them.
Two details are worth a glance before you run the suite. First, every value is distinct, which is guaranteed in practice by the 122 random bits: you would need to generate billions per second for years to expect one accidental collision. Second, every value is in canonical lowercase form with hyphens, so a UUID column or an API schema accepts them without reformatting. The fixture now exercises the same identifier type, format and uniqueness behaviour as production.
Why fresh values beat one copied UUID
It is tempting to keep one known UUID in your clipboard and paste it wherever a fixture needs an ID. Resist it. A single reused value creates three problems. It hides missing uniqueness constraints, because the database never gets the chance to reject a duplicate it should reject, or rejects fixtures for a reason unrelated to the code. It creates false relationships, where records that should be unrelated appear joined because they share an identifier. And it makes failures misleading: a test breaks because two fixtures collided, not because the application misbehaved.
Fresh random values cost nothing extra. A batch takes seconds, each record gets its own identifier, and uniqueness problems in your schema surface immediately, in the test run where they belong. The one exception is a fixture that deliberately tests duplicate handling; there, reuse the value on purpose and name the test so the intent is obvious.
Keeping fixtures readable
A fixture full of UUIDs can turn unreadable fast, and unreadable fixtures stop being maintained. A few habits keep them manageable:
- Keep one record per line or block. When each record sits on its own line with its UUID first, scanning and diffing stay easy, and a changed ID shows up as a single-line change in version control.
- Order fields consistently. Put the identifier in the same position in every record so the eye learns where to look.
- Comment sparingly at the top. A short header noting what the fixture represents ages better than a comment per record.
- Regenerate rather than hand-edit. If a value needs replacing, paste in a fresh generated UUID instead of typing hex by hand; a hand-typed digit can quietly break the version or variant markers.
- Keep the batch with the work. Because the tool stores nothing, the fixture file itself is the record of which values you used. Commit it, and the values are preserved with the tests.
Limitations
The generator makes version 4 (random) UUIDs only. If your production system uses time-ordered identifiers, look at UUID v7 in a dedicated library instead, and generate fixture values the same way so ordering behaviour matches. The batch limit is 100 per press; larger seed sets simply take a few presses, pasting each list in turn.
A UUID is also an identifier, not a credential. Fixture values are safe to commit because they encode nothing and guard nothing, but never let a generated UUID stand in for an API key or password in a config fixture; for credentials, prefer a longer password from this site's Password Generator, which gives you more entropy and control over the character set. And remember the storage rule: values exist only in the page until you close it, so copy the batch before navigating away.
Common mistakes
- Pasting one example UUID into every fixture. Shared identifiers hide uniqueness bugs and create false relationships between records.
- Using placeholder strings a UUID column rejects. Values like "user-1" fail the moment the fixture meets a real UUID type or a validating API.
- Hand-typing or editing hex digits. One changed character can break the version digit or variant marker and produce a value no generator would emit.
- Generating one at a time for a bulk seed. The tool makes up to 100 per batch with Copy all; repeated single generations waste the time the batch feature exists to save.
- Closing the tab before copying. Nothing is stored and there is no history, so an uncopied batch is gone.
FAQs
How many UUIDs can I generate for a fixture file at once? Choose any number from 1 to 100 per batch. Use Copy all to take the whole list, one per line, and run the generator again if a seed script needs more.
Why not reuse one UUID across all my test records? Because production identifiers are unique. A shared UUID can mask missing uniqueness constraints, create false collisions between fixtures, and make a test fail for reasons that have nothing to do with the code under test.
Are generated UUIDs safe to commit in test fixtures? They are random identifiers with no data encoded in them, so a committed fixture value reveals nothing about your systems. Just never treat a UUID as a credential; it is an identifier, not a secret.
Do you store the UUIDs I generate? No. They exist only in the page until you close it, so copy the batch before you navigate away.
What format do the generated UUIDs come in?
The canonical form: lowercase hexadecimal digits with hyphens, in the pattern xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, which is what most databases and APIs expect.
Conclusion
Good fixtures use the same identifiers as production: real version 4 UUIDs, unique per record, in canonical form. The UUID Generator makes them in batches of up to 100 with Copy all for the whole list, locally in your browser, storing nothing. Generate fresh values instead of recycling one copied UUID, keep one record per line, and your test data will behave like the real thing. If you want to understand the values themselves before you seed a database with them, the companion guide explains the 8-4-4-4-12 pattern group by group.
Related guide: UUID Format Explained: The 8-4-4-4-12 Pattern.
More tools for this kind of work live in the Developer Tools archive.