Skip to Content

UUID Generator

UUID Generator is an online tool that automatically generates UUID (Universally Unique Identifier) v4. You can customize uppercase/lowercase settings and hyphen inclusion options.

⚙️ Generation Options

✨ Generated UUID

Generates UUID (Universally Unique Identifier) v4. Each UUID is statistically unique and used for database keys, session IDs, etc.

💡 Examples

Default (lowercase, hyphens):
550e8400-e29b-41d4-a716-446655440000
Uppercase:
550E8400-E29B-41D4-A716-446655440000
No hyphens:
550e8400e29b41d4a716446655440000

Features​

  • UUID v4 Generation: Uses cryptographic randomness to generate statistically unique IDs
  • Multiple Generation: Generate multiple UUIDs at once (1-10)
  • Uppercase/Lowercase: Choose between uppercase and lowercase formats
  • Hyphen Options: Generate with or without hyphens
  • One-Click Copy: Click to copy UUID to clipboard

What is UUID?​

UUID (Universally Unique Identifier) is a 128-bit unique identifier used in software systems. UUID v4 uses random numbers to generate identifiers, ensuring statistical uniqueness.

UUID Format​

Standard UUID format is represented as 32 hexadecimal characters separated by hyphens in 8-4-4-4-12 format:

550e8400-e29b-41d4-a716-446655440000

Each section consists of:

  • 1st section (8 characters): Time-based low
  • 2nd section (4 characters): Time-based mid
  • 3rd section (4 characters): Version and time-based high
  • 4th section (4 characters): Clock sequence
  • 5th section (12 characters): Node (typically MAC address)

For UUID v4, most fields are randomly generated, with the version field fixed at '4'.

Use Cases​

1. Database Primary Keys​

CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
username VARCHAR(50),
email VARCHAR(100)
);

2. Session IDs​

const sessionId = crypto.randomUUID();
localStorage.setItem('sessionId', sessionId);

3. File Names​

const uploadFile = (file) => {
const uuid = crypto.randomUUID();
const extension = file.name.split('.').pop();
const fileName = `${uuid}.${extension}`;
// Upload file...
};

4. Distributed System IDs​

import uuid

def create_transaction():
transaction_id = str(uuid.uuid4())
return {
'id': transaction_id,
'timestamp': datetime.now(),
'status': 'pending'
}

Programming Examples​

JavaScript​

// Browser environment - Web Crypto API
const uuid = crypto.randomUUID();
console.log(uuid); // 550e8400-e29b-41d4-a716-446655440000

// Without hyphens
const uuidNoHyphens = crypto.randomUUID().replace(/-/g, '');
console.log(uuidNoHyphens); // 550e8400e29b41d4a716446655440000

// Uppercase
const uuidUpper = crypto.randomUUID().toUpperCase();
console.log(uuidUpper); // 550E8400-E29B-41D4-A716-446655440000

Python​

import uuid

# Generate UUID v4
generated_uuid = uuid.uuid4()
print(generated_uuid) # 550e8400-e29b-41d4-a716-446655440000

# Convert to string
uuid_str = str(generated_uuid)

# Without hyphens
uuid_no_hyphens = uuid_str.replace('-', '')
print(uuid_no_hyphens) # 550e8400e29b41d4a716446655440000

# Uppercase
uuid_upper = uuid_str.upper()
print(uuid_upper) # 550E8400-E29B-41D4-A716-446655440000

PHP​

// Using ramsey/uuid library
use Ramsey\Uuid\Uuid;

$uuid = Uuid::uuid4();
echo $uuid->toString(); // 550e8400-e29b-41d4-a716-446655440000

// Without hyphens
echo str_replace('-', '', $uuid->toString());

// Uppercase
echo strtoupper($uuid->toString());

Java​

import java.util.UUID;

public class UuidExample {
public static void main(String[] args) {
// Generate UUID
UUID uuid = UUID.randomUUID();
System.out.println(uuid.toString());

// Without hyphens
String uuidNoHyphens = uuid.toString().replace("-", "");
System.out.println(uuidNoHyphens);

// Uppercase
String uuidUpper = uuid.toString().toUpperCase();
System.out.println(uuidUpper);
}
}

C#​

using System;

class Program
{
static void Main()
{
// Generate UUID
Guid uuid = Guid.NewGuid();
Console.WriteLine(uuid.ToString());

// Without hyphens
string uuidNoHyphens = uuid.ToString("N");
Console.WriteLine(uuidNoHyphens);

// Uppercase
string uuidUpper = uuid.ToString().ToUpper();
Console.WriteLine(uuidUpper);
}
}

Security and Best Practices​

Do's​

  1. Database Primary Keys: UUIDs are excellent for distributed databases that need independent key generation
  2. Public IDs: Safe to expose externally as they're not sequential
  3. API Keys: Useful as part of API key generation
  4. Temporary File Names: Ideal for preventing file name collisions

Don'ts​

  1. NOT for Cryptographic Keys: UUIDs are not secure enough for encryption keys
  2. NOT for Password Storage: Never use UUIDs to replace proper password hashing
  3. Sequential Requirements: UUIDs are random, so don't use when sorting order is required
  4. Space-Constrained Scenarios: 128-bit UUIDs may be inefficient compared to shorter IDs

Collision Probability​

UUID v4 uses 122 bits of randomness (128 bits total, with 6 bits used for version and variant).

  • Number of possible UUIDs: 2^122 ≈ 5.3 × 10^36
  • Probability of collision: Practically zero
    • Generating 1 billion UUIDs per second for 85 years: less than 50% collision probability

Browser Compatibility​

The crypto.randomUUID() API used by this tool is supported in:

  • Chrome 92+
  • Firefox 95+
  • Safari 15.4+
  • Edge 92+

For older browsers, polyfills or libraries like uuid are recommended.

FAQ​

Q1. What's the difference between UUID versions?​

A: There are multiple UUID versions:

  • Version 1: Time-based (includes MAC address)
  • Version 3: MD5 hash-based
  • Version 4: Random (most commonly used)
  • Version 5: SHA-1 hash-based

Version 4 is most commonly used due to its simplicity and randomness.

Q2. Are UUIDs truly unique?​

A: Statistically speaking, yes. With 122 bits of randomness, the probability of collision is negligible. However, mathematical absolute uniqueness is not guaranteed.

Q3. Can I use UUIDs as database primary keys?​

A: Yes, but consider:

  • Pros: Globally unique, can be generated client-side, safe for distributed systems
  • Cons: Larger storage space (16 bytes vs 4-8 bytes for integers), no sequential ordering, slightly slower indexing

Q4. Are UUIDs secure?​

A: UUIDs are not cryptographically secure keys. While they are unpredictable, they should not replace proper encryption keys or authentication tokens.

Q5. What's the difference between hyphens and no hyphens?​

A: It's purely a formatting difference:

  • With hyphens: 550e8400-e29b-41d4-a716-446655440000 (36 characters, standard format)
  • Without hyphens: 550e8400e29b41d4a716446655440000 (32 characters, compact format)

Choose based on your system requirements.

Q6. Why use UUIDs instead of auto-increment IDs?​

A: Benefits of UUIDs:

  • Distributed generation: Multiple servers can generate IDs independently without conflicts
  • Security: Non-sequential, harder to guess next ID
  • Offline generation: Can be generated without database connection
  • Merging data: Easy to merge data from multiple sources without ID conflicts

Auto-increment IDs are better for:

  • Performance: Faster indexing and smaller storage
  • Simplicity: Easier to debug and read
  • Ordering: Natural chronological ordering