developer•2026-10-19•6 min read

How to Generate UUID v4 IDs in Bulk for Test Data and Spreadsheets

Learn the RFC 9562 UUID v4 specification, how to generate thousands of collision-resistant IDs for mock databases, and how to format them for CSV and SQL.

How to Generate UUID v4 IDs in Bulk for Test Data and Spreadsheets
Dedicated Browser Utility

UUID v4 Generator

Generate cryptographically random RFC 4122 Version 4 UUIDs individually or in bulk.

Open Tool Now
Bulk UUID v4 generation for test databases and spreadsheets
Generate RFC 9562-compliant UUID v4 identifiers in bulk for database seeds, mock API responses, and spreadsheet data imports.

When setting up staging environments, testing database migrations, or stress-testing APIs with realistic mock data, software engineers need large volumes of unique primary keys.

Relying on simple sequential integers (1, 2, 3...) in mock datasets creates brittle tests: auto-incrementing integers hide concurrency race conditions, fail when simulating distributed databases, and leak record creation volume if exposed to client applications.

The universal industry standard for distributed identifiers is the Universally Unique Identifier (UUID), specifically UUID Version 4.

In this guide, you will learn the exact bitwise structure defined in RFC 9562 (which supersedes RFC 4122), how collision probabilities work in practice, how to generate batches of formatted identifiers without scripting, and how to use the free in-browser UUID Generator to export bulk test datasets.


Anatomy of a UUID v4: The 128-Bit Layout

A standard UUID is a 128-bit label expressed as 32 hexadecimal digits displayed in five hyphenated groups:

f47ac10b-58cc-4372-a567-0e02b2c3d479
 8 chars - 4 -  4 -  4 -   12 chars

While other UUID variants encode physical machine MAC addresses (v1) or timestamps (v1, v6, v7), Version 4 relies on high-entropy randomness. Out of the 128 total bits:

  • 6 bits are fixed to identify the UUID version and variant.
  • 122 bits are cryptographically random.
Structure and bitwise anatomy of an RFC 9562 UUID v4
The 32-character hexadecimal layout of UUID v4 showing the version nibble ('4') and variant bits ('8', '9', 'a', or 'b').

The Fixed Position Indicators

You can immediately verify whether any UUID is a valid Version 4 by inspecting two specific character positions:

  1. The Version Nibble (13th character): Always the digit 4.

In our example: f47ac10b-58cc-`4`372-a567-0e02b2c3d479.

  1. The Variant Bits (17th character): Must represent RFC variant 1, where the two most significant bits are 10. In hexadecimal, this restricts the character to 8, 9, a, or b (or uppercase 8, 9, A, B).

In our example: f47ac10b-58cc-4372-`a`567-0e02b2c3d479.


Collision Probability: Do You Need to Worry About Duplicates?

Developers frequently ask: "If UUID v4 is random, could two records accidentally receive the exact same ID?"

To calculate the chance of a collision, we apply the mathematics of the Birthday Paradox. With 122 random bits, the total pool of possible UUIDs ($N$) is:

$$N = 2^{122} \approx 5.316 \times 10^{36}$$

The probability $P$ of finding at least one collision after generating $k$ unique identifiers is approximately:

$$P(k) \approx 1 - e^{-\frac{k^2}{2N}}$$

Let us put this number into perspective:

  • If you generate 1,000,000 UUIDs per second, it would take 100 years of continuous generation to reach a one-in-a-billion chance of a single duplicate.
  • If you generate a batch of 100,000 mock users for a test spreadsheet, the collision probability is approximately $9.4 \times 10^{-28}$—effectively zero.

Because the collision risk is mathematically infinitesimal, distributed microservices can generate primary keys locally with zero database roundtrips and zero central coordination locks.


Step-by-Step: Generating Bulk UUIDs for Spreadsheets and Seed Scripts

When generating mock data for tools like Excel, Google Sheets, Postgres COPY, or Prisma seed scripts, formatting requirements differ. Here is the standard workflow using UtilityKit's UUID Generator:

Step 1: Select Your Batch Size

Choose the number of records you need. For mock CSV tables, 50 to 500 identifiers is usually ideal for testing pagination and table filtering.

Step 2: Choose Casing & Hyphens

  • Standard (lowercase with hyphens): The default for PostgreSQL, MySQL UUID columns, and JSON REST APIs:

f47ac10b-58cc-4372-a567-0e02b2c3d479

  • Uppercase: Often required by Microsoft SQL Server or legacy Windows registries:

F47AC10B-58CC-4372-A567-0E02B2C3D479

  • Compact (no hyphens): Useful when saving 32-character hex tokens to MongoDB or URL paths:

f47ac10b58cc4372a5670e02b2c3d479

Step 3: Configure Delimiters for Your Target Tool

  • For CSV / Spreadsheets: Select Newline delimiters. When pasted into column A of Google Sheets or Microsoft Excel, each UUID occupies its own row automatically.
  • For SQL INSERT Statements: Select Commas with single quotes so your clipboard contains ready-to-paste tuples:
  INSERT INTO users (id, name) VALUES
  ('f47ac10b-58cc-4372-a567-0e02b2c3d479', 'Test User 1'),
  ('9b1deb4d-3b7d-4842-8904-4b8118254c5e', 'Test User 2');
  • For JSON Arrays: Select Commas with double quotes for instant drop-in to mockData.json:
  [
    "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "9b1deb4d-3b7d-4842-8904-4b8118254c5e"
  ]

Tested Code Example: Generating Bulk UUIDs in JavaScript & Node.js

Modern runtimes have native support for RFC 9562 UUID v4 via the Web Cryptography API:

// Works in Node.js 16.7+, modern browsers, and Cloudflare Workers
export function generateBulkUuids(count: number): string[] {
  const ids = new Array<string>(count);
  for (let i = 0; i < count; i++) {
    // crypto.randomUUID() uses OS-level CSPRNG entropy
    ids[i] = crypto.randomUUID();
  }
  return ids;
}

// Generate 5 mock IDs for a CSV
const testIds = generateBulkUuids(5);
console.log(testIds.join("\n"));

4 Common Mistakes to Avoid with UUIDs

  1. Using `Math.random()` to Build UUIDs:

Legacy tutorials often show functions concatenating Math.random().toString(16). Math.random() is not cryptographically secure and exhibits birthday collisions millions of times faster than true CSPRNG sources. Always use crypto.randomUUID() or crypto.getRandomValues(). For an in-depth breakdown of cryptographic entropy and randomness pitfalls, see our guide on how password entropy and modulo bias work.

  1. Treating UUID as an Unordered Index in B-Tree Tables:

Because UUID v4 is uniformly random, inserting millions of records into a traditional clustered index (like MySQL InnoDB's primary key) causes index page fragmentation and slow disk I/O. If write throughput on massive tables is critical, use an auto-incrementing integer or UUID v7 for sequential clustering, and use UUID v4 for external public references.

  1. Mismatched String Casing in SQL Queries:

Some database engines compare VARCHAR fields case-sensitively by default. Always standardize on lowercase across both your application code and seed scripts.

  1. Encoding Binary as Text:

When transmitting raw bytes or files alongside test records, remember that identifiers differ from byte wrappers. Check our guide on Base64 encoding vs encryption to understand how binary payloads are handled across APIs.


Generate Bulk Identifiers in Seconds

If you need clean, unquoted or custom-delimited UUID v4 values for your test spreadsheets or database seeds right now, open the free UUID Generator on UtilityKit.

It generates up to 500 compliant identifiers per batch entirely in your browser using native Web Cryptography, with instant controls for hyphens, uppercase formatting, and one-click copy.

Tags:#uuid generator#uuid v4#test data generation#bulk uuid#database seeding#cryptographic identifiers

Frequently Asked Questions

Quick answers to common questions for users and search assistants

What is the difference between UUID v4 and other UUID versions?
Unlike UUID v1 (derived from timestamp and network MAC address) or UUID v5 (derived from SHA-1 namespace hashing), UUID v4 is generated almost entirely from cryptographically strong pseudorandom bits. This makes v4 completely stateless, privacy-preserving, and immune to device tracking.
What is the probability of two UUID v4 values colliding?
A UUID v4 contains 122 random bits, providing approximately 5.3 × 10^36 possible identifiers. Under the birthday problem, you would need to generate over 2.7 quintillion UUIDs to reach a one-in-a-billion chance of a duplicate.
How should I format UUIDs for CSV spreadsheets versus SQL seed scripts?
For CSV imports, output unquoted, newline-delimited lowercase strings. For SQL INSERT statements, format each UUID surrounded by single quotes and delimited with commas (for example: ('f47ac10b-...'), ('9b1deb4d-...')) to avoid database syntax errors.

Related Utilities Mentioned in This Guide

Browse directory

Continue Reading

Advertisement