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.

UUID v4 Generator
Generate cryptographically random RFC 4122 Version 4 UUIDs individually or in bulk.
- 01.Anatomy of a UUID v4: The 128-Bit Layout
- 02.Collision Probability: Do You Need to Worry About Duplicates?
- 03.Step-by-Step: Generating Bulk UUIDs for Spreadsheets and Seed Scripts
- 04.Tested Code Example: Generating Bulk UUIDs in JavaScript & Node.js
- 05.4 Common Mistakes to Avoid with UUIDs
- 06.Generate Bulk Identifiers in Seconds

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 charsWhile 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.

The Fixed Position Indicators
You can immediately verify whether any UUID is a valid Version 4 by inspecting two specific character positions:
- The Version Nibble (13th character): Always the digit
4.
In our example: f47ac10b-58cc-`4`372-a567-0e02b2c3d479.
- The Variant Bits (17th character): Must represent RFC variant 1, where the two most significant bits are
10. In hexadecimal, this restricts the character to8,9,a, orb(or uppercase8,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
UUIDcolumns, 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
- 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.
- 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.
- 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.
- 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.
Frequently Asked Questions
Quick answers to common questions for users and search assistants
What is the difference between UUID v4 and other UUID versions?
What is the probability of two UUID v4 values colliding?
How should I format UUIDs for CSV spreadsheets versus SQL seed scripts?
Related Utilities Mentioned in This Guide
Browse directoryUUID v4 Generator
Generate cryptographically random RFC 4122 Version 4 UUIDs individually or in bulk.
Password Generator
Generate strong, unbiased random passwords with customizable length and character sets.
Base64 Encoder & Decoder
Encode and decode Unicode text, UTF-8 strings, and files to and from Base64 format.
Continue Reading
Base64 Encoding vs Encryption: Why Obfuscation Is Not Security
Understand the mathematical difference between Base64 data representation and cryptographic encryption, how 6-bit grouping works, and how to encode safely.
How Password Entropy and Modulo Bias Affect Password Security
Learn the mathematics of password entropy, why passphrase length beats complex symbols, and how modulo bias undermines random generators.