UUID/GUID Generator Online - v1, v4, v7

Generate UUIDs (Universally Unique Identifiers) or GUIDs (Globally Unique Identifiers) instantly. Supports versions v1, v4 and v7 with multiple format options. Perfect for database IDs, API keys, tokens and much more.

Tip: Use v4 for general random IDs, v1 when you need embedded timestamp, and v7 for chronologically sortable IDs (better for databases).

What is UUID/GUID?

UUID (Universally Unique Identifier) or GUID (Globally Unique Identifier) is a 128-bit identifier used to uniquely identify resources in computer systems. The probability of generating two identical UUIDs is extremely low, making them ideal for globally unique identifiers.

UUID Versions

UUID v1 - Timestamp-Based

Generated from the current timestamp and MAC address (or random value). Allows chronological ordering but may reveal information about when and where it was generated.

6ba7b810-9dad-11d1-80b4-00c04fd430c8

Use when: You need chronologically orderable UUIDs in legacy systems.

UUID v4 - Random (Most Common)

Generated completely randomly. It's the most used and recommended version for most cases. Reveals no information about origin or creation time.

f47ac10b-58cc-4372-a567-0e02b2c3d479

Use when: You need random unique IDs for any general purpose.

UUID v7 - Time-Orderable (New)

Newest version (RFC draft 2024). Combines Unix timestamp with randomness, allowing chronological ordering while maintaining uniqueness. Excellent for databases and distributed systems.

018d2f8a-3c4e-7890-b456-789012345678

Use when: You need orderable IDs for better performance in database indexes.

Common Use Cases

πŸ—„οΈ Database Primary Keys

Unique IDs for tables in distributed databases

πŸ” Tokens and Sessions

Unique identifiers for user sessions and timed tokens

πŸ“ File Names

Ensure unique names for file uploads and storage

πŸ”— REST Resource IDs

Unique identifiers for resources in RESTful APIs

πŸ“Š Event Tracking

Unique IDs for logs, events, and transactions

🌐 Distributed Systems

Ensure uniqueness across multiple servers without coordination

Supported Formats

Standard (lowercase with hyphens):

f47ac10b-58cc-4372-a567-0e02b2c3d479

Uppercase with hyphens:

F47AC10B-58CC-4372-A567-0E02B2C3D479

Lowercase without hyphens:

f47ac10b58cc4372a5670e02b2c3d479

Uppercase without hyphens:

F47AC10B58CC4372A5670E02B2C3D479

UUID Structure

A standard UUID has 36 characters (32 hexadecimal + 4 hyphens) divided into 5 groups:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
β””β”€β”€β”¬β”€β”€β”˜ β””β”¬β”€β”˜ β””β”¬β”€β”˜ β””β”¬β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
   β”‚     β”‚    β”‚    β”‚       β”‚
   β”‚     β”‚    β”‚    β”‚       β””─ Node (48 bits)
   β”‚     β”‚    β”‚    β””──────── Clock Seq (16 bits)
   β”‚     β”‚    β””─────────── Time Hi + Version (16 bits)
   β”‚     β””──────────────── Time Mid (16 bits)
   β””─────────────────── Time Low (32 bits)

The digit M indicates the version (1, 4, or 7). The digit N indicates the variant (always 8, 9, A, or B).

Implementation in Different Languages

JavaScript/Node.js

// Usando o pacote 'uuid'
import { v4 as uuidv4, v1 as uuidv1 } from 'uuid';

const id = uuidv4(); // UUID v4
console.log(id); // f47ac10b-58cc-4372-a567-0e02b2c3d479

const idV1 = uuidv1(); // UUID v1
console.log(idV1); // 6ba7b810-9dad-11d1-80b4-00c04fd430c8

// Nativo no navegador (crypto API)
const uuid = crypto.randomUUID();
console.log(uuid); // Generates UUID v4

Python

import uuid

# UUID v4 (random)
id = uuid.uuid4()
print(id)  # f47ac10b-58cc-4372-a567-0e02b2c3d479

# UUID v1 (timestamp)
id_v1 = uuid.uuid1()
print(id_v1)  # 6ba7b810-9dad-11d1-80b4-00c04fd430c8

# Como string
id_str = str(uuid.uuid4())
print(id_str)

Java

import java.util.UUID;

// UUID v4 (random)
UUID uuid = UUID.randomUUID();
System.out.println(uuid.toString());

// UUID a partir de string
UUID parsed = UUID.fromString("f47ac10b-58cc-4372-a567-0e02b2c3d479");
System.out.println(parsed);

C# / .NET

using System;

// UUID v4 (random)
Guid id = Guid.NewGuid();
Console.WriteLine(id.ToString());

// Different formats
Console.WriteLine(id.ToString("N")); // without hyphens
Console.WriteLine(id.ToString("D")); // with hyphens (default)
Console.WriteLine(id.ToString("B")); // with braces {}

PHP

<?php
// Using native function (PHP 8.3+)
$uuid = uuid_create(UUID_TYPE_RANDOM);
echo $uuid;

// Or using ramsey/uuid
use Ramsey\Uuid\Uuid;

$uuid = Uuid::uuid4();
echo $uuid->toString(); // f47ac10b-58cc-4372-a567-0e02b2c3d479
?>

Go

package main

import (
    "fmt"
    "github.com/google/uuid"
)

func main() {
    // UUID v4
    id := uuid.New()
    fmt.Println(id.String())
    
    // UUID v1
    idV1, _ := uuid.NewUUID()
    fmt.Println(idV1.String())
}

SQL (PostgreSQL)

-- Enable extension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

-- Generate UUID v4
SELECT uuid_generate_v4();

-- Generate UUID v1
SELECT uuid_generate_v1();

-- Use as primary key
CREATE TABLE users (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    name VARCHAR(100)
);

Ruby

require 'securerandom'

# UUID v4 (random)
uuid = SecureRandom.uuid
puts uuid # f47ac10b-58cc-4372-a567-0e02b2c3d479

# Without hyphens
uuid_no_dash = SecureRandom.uuid.gsub('-', '')
puts uuid_no_dash

UUID vs Auto-Increment IDs

Feature UUID Auto-Increment
Global Uniqueness βœ… Yes ❌ No (per table)
Client Generation βœ… Yes ❌ Server only
Insert Performance ⚠️ Lower βœ… Higher
Storage Space 128 bits 32-64 bits
Predictability βœ… Unpredictable ❌ Sequential
Data Merging βœ… Easy ❌ Conflicts
Ideal For Distributed systems Centralized applications

Best Practices

Security and Privacy

⚠️ UUID is Not a Security Token

UUIDs are unique identifiers, but should not be used as security tokens or secrets. For authentication, use specific libraries that generate cryptographically secure tokens (JWT, OAuth tokens, etc.).

πŸ” UUID v4 Randomness

UUID v4 uses cryptographically secure pseudo-random numbers. The chance of collision is approximately 1 in 2^122, making it safe for unique IDs. For context, you would need to generate 1 billion UUIDs per second for 85 years to have a 50% chance of a single collision.

Frequently Asked Questions

Are UUID and GUID the same thing?

Yes, they are essentially the same thing. UUID is the RFC 4122 standard term, while GUID is the term used by Microsoft. Both are 128-bit identifiers with the same format.

What is the probability of collision?

For UUID v4, the probability is extremely low: approximately 1 in 2^122 (5.3 Γ— 10^36). In practice, the chance of collision is negligible, even in large-scale systems.

Is UUID case-sensitive?

No. UUIDs are hexadecimal and are not case-sensitive. "f47ac10b..." and "F47AC10B..." represent the same UUID. However, the convention is to use lowercase.

Can I use UUID as a URL?

Yes! UUIDs are safe for URLs. They don't contain special characters that need encoding. Example: https://api.example.com/users/f47ac10b-58cc-4372-a567-0e02b2c3d479

Is UUID slower than auto-increment?

In terms of database insertion, yes, UUIDs can be slightly slower due to size (128 bits vs 32-64 bits) and random nature (index fragmentation). However, UUID v7 solves much of this problem with sortable IDs.

Can I generate UUID offline?

Yes! UUIDs can be generated completely offline without internet or server connection. UUID v4 uses only local random numbers, ensuring global uniqueness without coordination.

How do I validate a UUID?

Use regex: /^[0-9a-f]8-[0-9a-f]4-[1-7][0-9a-f]3-[89ab][0-9a-f]3-[0-9a-f]12$/i
Or use native libraries that have built-in validation.

πŸš€ Pro Tip

For modern applications with PostgreSQL or MySQL 8.0+, consider using UUID v7. It combines the advantages of UUIDs (global uniqueness, client generation) with the performance of IDs sequential (chronological ordering, efficient indexes). It's the best of both worlds!