RSA Key Pair Generator Online — 2048/3072/4096, PEM & JWK
Generate RSA key pairs (2048, 3072, or 4096 bits) online for OAEP encryption, PSS signing, or RS256 JWTs. Exports PKCS#8 private key + SPKI public key as PEM, JWK, or DER (hex/base64). 100% local — the Web Crypto API runs in your browser, private keys never leave the tab.
Last updated:
CommentsPick a key size (2048 / 3072 / 4096 bits) and click Generate. You get a matching RSA public + private key pair in PEM, JWK, and DER formats. Generated locally via the Web Crypto API — the private key never touches a server.
Key generation runs entirely in your browser using the native Web Crypto API. The private key is never transmitted — you can verify with your browser's DevTools Network panel.
What is RSA Key Generator?
An RSA Key Generator produces an asymmetric key pair used for signing (JWT RS256/PS256, SSH keys, TLS certs) or encryption (RSA-OAEP for data at rest, hybrid schemes for envelopes). The private key stays on the machine that signs or decrypts; the public key is safe to publish. Modern production systems use 2048 bits at minimum, 3072 for medium-term (10+ years), 4096 for regulated / long-lived roots.
How to generate an RSA key pair
- 1Choose a key size — 2048 for most APIs, 3072 for stronger long-term signing, 4096 for CA roots and compliance-sensitive workloads.
- 2Click Generate. `crypto.subtle.generateKey` runs in your browser; larger keys take a few seconds.
- 3Copy or download the private key in PEM (PKCS#8, `-----BEGIN PRIVATE KEY-----`), JWK, or DER format.
- 4Copy the public key in SPKI PEM (`-----BEGIN PUBLIC KEY-----`), JWK, or DER — this is the safe half to share.
- 5For JWT signing, feed the private key into your signer and publish the public key at `/.well-known/jwks.json` (use our JWKS Generator to assemble the endpoint).
Use Cases
Sign RS256 / PS256 JWTs
Auth services signing access tokens with RS256 (or the more modern PS256) need a fresh RSA pair on every environment. Use this to bootstrap without installing OpenSSL locally.
Test JWKS rotation
Generate two keys, publish both at your JWKS endpoint, sign new tokens with the new key while the old one still validates in-flight tokens. Rotate without downtime.
Encrypt secrets with RSA-OAEP
Encrypt a symmetric AES key (for hybrid encryption of large payloads) using RSA-OAEP + SHA-256 — the standard envelope pattern for encrypting-at-rest.
Local development / CI fixtures
Generate a throwaway pair for unit tests that need to sign and verify tokens end-to-end, without polluting your team's shared secrets.
Code Examples
Equivalent with OpenSSL
# 2048-bit RSA, PKCS#8 private key + SPKI public key
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private.pem
openssl pkey -in private.pem -pubout -out public.pemGenerate in Node.js
import { generateKeyPair } from "node:crypto";
import { promisify } from "node:util";
const { publicKey, privateKey } = await promisify(generateKeyPair)("rsa", {
modulusLength: 2048,
publicKeyEncoding: { type: "spki", format: "pem" },
privateKeyEncoding: { type: "pkcs8", format: "pem" },
});Generate in Python (cryptography)
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization
key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
pem = key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption(),
)Generate in Go
import (
"crypto/rand"
"crypto/rsa"
)
key, err := rsa.GenerateKey(rand.Reader, 2048)Key Concepts
- PKCS#8 vs. PKCS#1
- PKCS#8 (`-----BEGIN PRIVATE KEY-----`) is the modern envelope for any private key type. PKCS#1 (`-----BEGIN RSA PRIVATE KEY-----`) is the older RSA-only format. Web Crypto and most modern libraries produce PKCS#8; convert with `openssl pkcs8 -topk8 -in pkcs1.pem -out pkcs8.pem -nocrypt`.
- SPKI
- SubjectPublicKeyInfo — the standard container for public keys (`-----BEGIN PUBLIC KEY-----`). Contains the key type identifier plus the raw key bits, so a single format works for RSA, EC, Ed25519, etc.
- Key size trade-offs
- 2048 bits is the current baseline (roughly 112 bits of security, safe through ~2030). 3072 gives 128-bit security, matching AES-128. 4096 is ~144-bit, useful for CA roots that must remain safe for decades. Doubling key size ~8x's signing cost.
- Public exponent
- Almost always 65537 (0x010001). It's a Fermat prime, making key generation fast and eliminating known low-exponent attacks. If a library asks, keep the default.
Tips & Best Practices
- ▸For JWT signing, prefer RS256 (widely supported) or PS256 (RSA-PSS, side-channel-safer signatures). Both use the same key pair.
- ▸Never commit private keys to git. Even 'test' keys — attackers scan public repos for `BEGIN PRIVATE KEY` in seconds.
- ▸If you need faster / smaller keys, switch to ECDSA (ES256 / P-256). 256-bit EC ≈ 3072-bit RSA in strength, but signatures are ~8x smaller.
- ▸PEM files must have exactly `-----BEGIN X-----`, a newline, base64 wrapped at 64 chars, a newline, and `-----END X-----`. Reformatting can silently break parsers.
Frequently Asked Questions
Is my private key uploaded anywhere?
No. Key generation runs entirely in your browser via the Web Crypto API's crypto.subtle.generateKey(). You can verify with your browser's DevTools Network panel — no request is made when you click Generate. The private key exists only in this tab's memory and is destroyed when you close it.
Which key size should I use?
2048 bits is the modern minimum and is still fine for most use cases. 3072 bits is what NIST recommends for anything expected to be secure past 2030. 4096 bits provides an extra safety margin but is roughly 5× slower for private-key operations. If you're targeting a device with limited CPU (embedded, mobile), stick with 2048; for long-lived server keys, 3072 is a sensible default.
What's the difference between RSA-OAEP, RSA-PSS, and RSASSA-PKCS1-v1_5?
RSA-OAEP is used for encryption (encrypting a symmetric key, for example). RSA-PSS is the modern padding for signatures with proper security proofs. RSASSA-PKCS1-v1_5 is the older signature padding still required for RS256 JWTs, TLS 1.2 signing, and many legacy protocols. Pick based on what your target system expects.
What is PKCS#8 and why does the private key start with 'BEGIN PRIVATE KEY'?
PKCS#8 is the IETF standard container format for asymmetric private keys, defined in RFC 5208 / 5958. OpenSSL's older '-----BEGIN RSA PRIVATE KEY-----' header is PKCS#1 (RSA-specific). Node, Go's crypto/x509, Java's KeyFactory, and modern Python cryptography all prefer PKCS#8 because it's algorithm-agnostic. If a legacy tool needs PKCS#1, run `openssl rsa -in key.pem -traditional` to convert.
Can I use this key for a JWT?
Yes. For RS256 JWTs, pick RSASSA-PKCS1-v1_5 with SHA-256. For PS256 JWTs, pick RSA-PSS with SHA-256. Copy the private key PEM into your JWT library (jsonwebtoken, PyJWT, jose, etc.) and it'll sign against it directly. The public key JWK from this tool can be published as a JWKS endpoint for verifiers.
Should I generate keys in the browser for production use?
For personal / development use, yes — this tool is convenient and safe. For production keys that protect real assets, generate them inside a Hardware Security Module (HSM) or Cloud KMS (AWS KMS, GCP KMS, Azure Key Vault) so the private key never exists on any general-purpose computer.
Try Next
AES Encrypt / Decrypt
Encrypt and decrypt text with AES (128 / 192 / 256, GCM authenticated or CBC legacy) using a password. PBKDF2 key derivation with 200,000 iterations. 100% local — the Web Crypto API runs entirely in your browser.
Related Tools
HMAC Generator
Compute HMAC signatures with SHA-1, SHA-256, SHA-384, or SHA-512 online. Verify API requests, sign webhooks, and authenticate messages. Free, no signup — signing runs locally via the Web Crypto API, secrets never leave your browser.
JWT Decoder
Decode JSON Web Tokens (JWT) to inspect the header, payload, and signature. Runs entirely in your browser — tokens are never sent to any server.
Hash Generator
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes of any text online. Free, no signup — all hashing runs entirely in your browser via the Web Crypto API, so nothing is uploaded.
JWT Generator
Create signed JSON Web Tokens with HS256/384/512 (HMAC), RS256/384/512 (RSA), PS256/384/512 (RSA-PSS), or ES256/384/512 (ECDSA). Paste a raw secret, a PEM private key, or a JWK — signing runs entirely in your browser via the Web Crypto API.
HMAC-SHA256
Compute HMAC-SHA256 signatures with any secret key. Outputs hex, base64, and base64url encodings. Verify a signature against an expected value in one click. Used by AWS SigV4, JWT HS256, Stripe / GitHub / Slack webhooks. 100% local via Web Crypto API.
Bcrypt Generator
Generate and verify bcrypt password hashes online. Configurable cost factor (4–15), shows computation time so you can pick a cost matching your server hardware. Parses and displays hash version and cost from any pasted hash. 100% local — passwords never leave your browser.