How to generate UUID v4 identifiers for records and test data

Create one UUID or a batch in TinyToolbox, recognise the version and variant, and keep identifiers stable when you use them.

Open the tool

When you create a record before it has been saved to a database, you may need an identifier that can travel with it. The same problem comes up when preparing test fixtures or joining related records in different files. A UUID is a common way to assign an identifier without waiting for a database sequence to give you the next number.

TinyToolbox UUID v4 Generator uses the browser’s cryptographic random UUID function. It can produce one identifier or a list of up to 1,000, one per line. Start by checking that the receiving system expects version 4. Then decide whether the IDs are temporary examples or stable references that must keep working across files.

Recognise the version and variant in the string

A UUID appears as five groups of hexadecimal digits separated by hyphens. The groups contain 8, 4, 4, 4, and 12 digits. This is a sample layout:

12345678-1234-4abc-8def-123456789abc

The first character in the third group is 4, identifying version 4. The first character in the fourth group is 8, 9, a, or b for the variant used by the generator. The hyphens make the groups easier to recognise. An application may require the canonical hyphenated form even if another representation contains the same underlying bytes.

Version 4 uses random bits rather than encoding a timestamp or sequence number. One generated value does not tell you whether it was created before another. If you need to sort records by when they were created, store a creation time separately. If a system explicitly expects another UUID version, follow its documented requirement instead of assuming it accepts any correctly shaped UUID.

An identifier can be useful as a stable reference without carrying information about the record’s content. Do not try to infer a person, location, or item category from a random UUID. Keep those details in separate fields so they can be updated as needed without changing the reference.

Generate one identifier or a batch in TinyToolbox

  1. Open UUID v4 Generator.
  2. Enter a whole number from 1 to 1,000 under Number of UUIDs.
  3. Select Run tool.
  4. Inspect the lines under Result.
  5. Select Copy result and paste into the application or source file where you need the IDs.

The input starts at one. For a single test record, leave it at one and copy that line. For a batch, count the records that need IDs before running the tool. The result is plain text, with each UUID on its own line. It does not add JSON quotes, a CSV header, or any relationship to the records you are preparing.

If you rerun the generator, it creates a new set. Copy the current set before running again if you need to keep it. A generated list can only become part of your fixture after you assign each value to a particular record. Keep the association in the data file instead of relying on the order of a separately copied list.

Imagine a local test has one workshop and three registration records. The workshop needs its own ID. Each registration needs another ID of its own, plus a reference to the workshop. Generate four IDs. Assign the first to the workshop, then assign one of the remaining three to each registration. Use the same workshop ID in each registration’s workshop reference field.

A new ID is appropriate for a new record. Replacing an existing workshop’s ID without updating its references would break the relationship. Before sharing the fixture, look for the workshop ID in both the parent record and every child record. Confirm that the registration IDs are distinct. This verifies both kinds of identity involved in the example.

For a JSON fixture, write the UUID as a quoted string. The sample above contains hyphens and letters and is not a JSON number. After inserting the values, use JSON Formatter & Viewer to check the structure and see where the references appear. A successful parse confirms JSON syntax. The application or its tests still need to verify that those IDs resolve to the intended records.

Check uniqueness where it matters

A random UUID v4 is designed to make accidental collisions very unlikely, but the generator does not check your database or any earlier list you saved. A storage system can enforce uniqueness when the identifier serves as a unique key. If the system reports a duplicate during insertion, check whether you copied a line twice, reran an import, or reused a fixture that already existed.

For a batch import, compare the number of ID lines with the number of records. Blank lines inserted while copying can shift later assignments. Use a test import or check the resulting mapping before relying on the file. If one row already has an ID and should keep it, exclude that row from the count of records receiving new identifiers.

Some workflows use an ID to recognise an earlier operation or to retry safely. In that case, the same operation may need the same ID on each retry. Generate a new identifier for each distinct operation and retain it where the receiving protocol tells you to. Calling the generator again for an existing reference creates a different value rather than recovering the old one.

Keep identifiers and secrets separate

A UUID identifies a record. Its presence in a URL or an exported file does not establish whether someone should have permission to open that record. The receiving application still needs to enforce access rules. Avoid using the fact that an ID is hard to guess as the only protection for data that should be private.

For an account password, use a credential workflow such as Password Generator and follow the receiving system’s rules. Use UUIDs where the application expects a UUID string. Keeping the purpose of each value clear makes it easier to handle disclosure and storage correctly.

Verify the final data

Check that each UUID has the five expected groups and the version character in the right position. Confirm that your receiving field expects hyphenated text, then check the resulting records after import. If a tool rejects a value, look for a leading or trailing space, a missing character, or extra quotes copied from a surrounding example. Confirm the application accepts version 4 rather than changing the identifier until it happens to pass.

For a fixture you will run again, save the generated IDs with their records and document which fields reference them. If the data is intended to be new on every run, have that workflow create and assign the values at the appropriate step. The key check is that the IDs remain distinct where required and that every reference uses the exact value of the record it refers to.

Import a small catalog without changing existing IDs

Imagine that you maintain a catalog of equipment at three sites. The current records already have IDs, and a new spreadsheet contains eight items that need to be added. First, identify which incoming rows are genuinely new. If a row is a corrected entry for an existing item, keep the existing ID and update its descriptive fields. Assign new UUIDs only to the rows that represent new records. A name change or typo correction should leave other records that point to that item working.

Open the UUID v4 Generator and generate eight identifiers for the eight new items. Create an empty ID column in the spreadsheet, then paste one identifier into each new row. Review the first and last assignment, and check that there are eight nonblank IDs. Keep an unmodified copy of the incoming list until the import is finished. If you sort before the IDs are assigned, sort complete rows so each description stays with its serial number or other reference.

Next, export the catalog in the format your import accepts. Reopen the exported file and inspect the identifier column. Entries should remain text strings, with all their hexadecimal digits and hyphens intact. If a formula or cleanup step replaced blanks or transformed strings, check that it touched the intended column. A file with the correct count of IDs can still associate an ID with the wrong item if the column was sorted independently.

Try a small import in a staging or test copy when available. Confirm that items are created and updated as intended, and inspect one record whose name changed. If the old version and the corrected version appear as two records, check how the import matches rows. A generated identifier represents the assignment you make. The importing system decides whether that identifier creates a new record or matches one already stored.

Make a retry safe for a partially imported batch

Suppose the catalog import reports that five rows succeeded and three failed validation. Keep the ID assignments from the initial file. Fix the rejected descriptions or missing fields while preserving the IDs. If the system supports an update-or-insert operation keyed by UUID, a rerun can use those same values to match the five known rows and insert the remaining three. Review the importer’s actual rules first. If it only supports inserts, send just the failed rows after checking which entries were saved.

You can test the pattern with one sample row before using it for eight or eighty. Import the row with its UUID, correct the name in the source file, and run the same process again. Then search the test destination using the ID. Confirm that the name changed on the existing record and that the record count stayed the same. If the import returns a duplicate error instead, save the response and use the update workflow the destination provides.

A fresh UUID on every retry would identify a different record. It can conceal which attempt created the original and leave parallel records with different references. Save the mapping from old source keys or import row references to your assigned IDs with the job. Then a retry can refer back to that mapping instead of guessing based on names or row numbers that may have changed.

Decide how to display and search identifiers

A full UUID is convenient for copy and paste even when it is too long for a narrow table cell. If your interface shows only the first few characters, keep a way to copy the complete identifier. Treat a shortened label as a visual aid. Two full UUIDs can share the same prefix, so a prefix alone may match several records.

When someone reports an issue using an ID, paste it into an exact-match search if that feature is available. Check that a leading or trailing space did not come along from a spreadsheet or message. Use the stored representation your system expects. A system may compare IDs in a structured UUID field, or it may treat the entire value as text. When working with exported files, preserve the full value throughout so that either destination can read it.

UUID v4 values also do not reveal which record came first. If you need to order the results by creation or import date, store a separate timestamp and sort on that field. If a batch has a deliberate order, keep a separate sequence field for presentation. This lets the identifier remain stable when a display changes from alphabetical order to location or date order.

Before handing the dataset to a colleague, share the column name and the meaning of each reference. If a related table contains an equipment ID and a maintenance-event ID, clarify which column points to the equipment record and which identifies the event. A useful check is to take one known maintenance entry and follow its equipment ID back to the correct location and item. That verifies the relationship as well as the format of the identifier.