API Key Generator

Generate secure random API keys for development and testing.

8256

About API Key Generator

The API Key Generator is an essential tool for developers creating APIs and web services. It generates random API keys in multiple formats (hex, base64, alphanumeric, UUID-like) with customizable length, prefixes, suffixes, and separators. Perfect for creating authentication keys, access tokens, and API credentials that match your specific requirements.

Use Cases:

  • Generating API authentication keys
  • Creating access tokens and credentials
  • Generating secret keys for applications
  • Creating test API keys for development
  • Generating keys with specific format requirements
  • Creating keys with organizational prefixes

Key Features:

  • Multiple formats (hex, base64, alphanumeric, UUID-like)
  • Customizable length (8-256 characters)
  • Prefix and suffix support
  • Separator insertion at intervals
  • Copy generated keys to clipboard
  • 100% browser-based - no server processing
By Muhammad Abdullah Rauf · Founder, EverydayTools.proUpdated 2026-06-08

What is an API key and how do you generate a secure one?

An API key is a randomly generated string used to authenticate requests to an API. Secure API keys use cryptographically random generation (not Math.random), are typically 32–64 characters, and are formatted in hex, base64, or alphanumeric encoding.

An API key is a shared secret passed by a client in HTTP requests to identify and authorize the caller. Unlike passwords, API keys are designed to be long, random, and machine-generated — not human-memorable.

**What makes an API key secure:**

• **Cryptographic randomness**: Generated using a cryptographically secure pseudo-random number generator (CSPRNG), not Math.random() (which is statistically random but not cryptographically secure)

• **Sufficient entropy**: At least 128 bits of entropy (32 hex characters = 128 bits, 43 base64 characters ≈ 258 bits, 22 UUID characters = 128 bits)

• **No predictable patterns**: No timestamps, sequential IDs, or hash of predictable inputs

**Common API key formats:**

• **Hex**: e.g., `a3f82c1d4e7b0953...` — uses characters 0–9 and a–f

• **Base64**: e.g., `K3fWx9+Abc...` — more compact, uses A–Z, a–z, 0–9, +, /

• **Alphanumeric**: e.g., `Kx3fW9AbcR...` — URL-safe, uses A–Z, a–z, 0–9 only

• **UUID v4**: e.g., `550e8400-e29b-41d4-a716-446655440000` — fixed 36-character hyphenated format

This generator uses the browser's Web Crypto API (crypto.getRandomValues) — the same source used by OS-level secure random number generators.

Quick answers

Concise answers for common searches — definitions, steps, and comparisons.

How are API keys generated securely?

Using crypto.getRandomValues() — the browser's cryptographically secure random number generator — not Math.random().

Is the API key generator private?

Yes — keys are generated in your browser. Nothing is uploaded. Open Network tab to verify.

How to use API Key Generator

  1. Choose key format

    Select Hex (0–9, a–f), Base64, or Alphanumeric (A–Z, a–z, 0–9). Alphanumeric is URL-safe and most broadly compatible. Hex is standard for API authentication tokens. Base64 is compact.

  2. Set key length

    32 characters for hex (128-bit entropy) is the minimum recommended. For higher-security applications, use 64 hex characters (256-bit). Most major APIs use 32–64 character keys.

  3. Click Generate

    The key is generated immediately using crypto.getRandomValues. Each click produces a new, independent key.

  4. Copy and store securely

    Copy the key immediately. Store it in an environment variable, secrets manager (AWS Secrets Manager, HashiCorp Vault, .env file excluded from git), or password manager. Do not store raw API keys in code.

API Key Generator examples

32-char hex API key

Input

Format: Hex · Length: 32 characters

Output

a3f82c1d4e7b09534c0e11f2b8d63a90

128 bits of entropy. Standard for most API authentication use cases.

Stripe-style alphanumeric key

Input

Format: Alphanumeric · Length: 32 characters

Output

sk_live_Kx3fW9AbcRq7mZnP2vLdTj8Y

Stripe, GitHub, Twilio, and similar services use alphanumeric keys with type prefixes (sk_live_, ghp_, etc.) for easy identification.

Who uses API Key Generator?

Common real-world scenarios where this tool saves time.

Development and testing API tokens

Generate unique API keys for dev/staging environments. Using a different key per environment makes revocation simple — rotate the dev key without affecting production.

Webhook signing secrets

Generate random secrets for validating webhook payloads (HMAC-SHA256 signatures). Services like Stripe, GitHub, and Shopify use shared secrets to sign webhook bodies.

Internal service tokens

Generate auth tokens for microservices communicating over an internal network. Each service gets a unique key, limiting the blast radius of any single compromised token.

Password reset and email verification tokens

Generate cryptographically random tokens for one-time-use links. A 32-byte random hex token is effectively unguessable — far more secure than sequential IDs.

Reference tables

API key format comparison

Choosing the right encoding for your use case.

FormatCharacters used128-bit lengthURL-safeBest for
Hex0–9, a–f32 charsYesDatabase tokens, hashes, general purpose
Base64 (URL-safe)A–Z, a–z, 0–9, -, _22 charsYesCompact tokens, JWTs
AlphanumericA–Z, a–z, 0–922+ charsYesDeveloper-facing API keys (Stripe-style)
UUID v4hex + hyphens36 charsYesResource IDs, database primary keys

Advertisement

Frequently Asked Questions

What is the difference between Math.random() and crypto.getRandomValues()?

Math.random() produces statistically random-looking numbers, but the underlying pseudo-random generator is deterministic and seeded predictably — not suitable for security. crypto.getRandomValues() uses the operating system's entropy source (hardware events, timing jitter) and is cryptographically secure — unpredictable even if an attacker knows the algorithm.

How long should an API key be?

At minimum, 128 bits of entropy — equivalent to 32 hex characters, 22 base64 characters, or a UUID v4. For high-security applications, 256 bits (64 hex characters) is recommended. Longer is safer — the key space grows exponentially with length, making brute-force attacks computationally infeasible.

What format should API keys use — hex, base64, or alphanumeric?

All are secure if generated from a CSPRNG. Choose based on compatibility: Hex (0–9, a–f) is universally safe in URLs and headers. Base64 is compact but requires URL-safe variant (replaces + with - and / with _) for headers and query strings. Alphanumeric (A–Z, a–z, 0–9) is URL-safe and human-readable, making it popular for developer-facing API keys (similar to GitHub, Stripe, Twilio key formats).

How should I store an API key?

Never in source code. Use environment variables (process.env.API_KEY), a .env file excluded from version control (.gitignore), a cloud secrets manager (AWS Secrets Manager, GCP Secret Manager, Azure Key Vault), or a self-hosted vault (HashiCorp Vault). Keys in code — even in private repos — are frequently leaked via history, forks, and log files.

Can someone guess my API key?

Not practically, if generated correctly. A 128-bit key has 2^128 possible values (~340 undecillion). At 1 billion guesses/second, brute-forcing would take 10^22 years — far longer than the age of the universe. The real risk is key leakage (committed to git, logged in plaintext, sent over HTTP), not guessing.

How do I rotate an API key?

Generate a new key, update all services consuming the old key to use the new one, test the new key is working, then revoke the old key. For zero-downtime rotation in production: (1) generate new key, (2) add it alongside old key, (3) update clients, (4) revoke old key once all clients updated.

What is a UUID and is it a secure API key?

UUID v4 is a 128-bit random identifier formatted as `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`. It uses 122 random bits (not 128 — 6 bits encode version/variant). UUID v4 from crypto.getRandomValues is a valid API key format, but note that the format leaks that it is a UUID — some security guidelines recommend opaque random strings with no identifiable structure.

Are the API keys generated here logged or stored?

No — generation uses the Web Crypto API running entirely in your browser. No keys are transmitted to EverydayTools servers. You can verify this by opening your browser's Network tab during generation and confirming no outbound requests are made.

Privacy, accuracy, and trust

Privacy

Generated API keys and tokens are created locally in your browser using Web Crypto—they are not sent to EverydayTools servers.

For production systems, rotate API keys regularly and store in a dedicated secrets manager — not in code or .env files committed to version control.

Part of Developer Tools

More free tools for the same workflow.

Advertisement

Reviewed on 2026-06-08.