Key Pair Generator

Fresh RSA, ECDSA and Ed25519 key pairs as PEM or JWK, made locally.

Runs in your browser Instant No sign-up
Key pair
Done
Processed locally · nothing is uploadedProcessed locally

How to use it

Pick a Key type and click Generate. Every click makes a new key pair. The output has two PEM blocks:

  • Public key: -----BEGIN PUBLIC KEY-----, in X.509 SubjectPublicKeyInfo (SPKI) format. Share it with whoever verifies your signatures.
  • Private key: -----BEGIN PRIVATE KEY-----, unencrypted PKCS#8. Keep it secret.

The Base64 is wrapped at 64 characters per line, as RFC 7468 specifies, so OpenSSL, Node.js, Java, Go and Python read the blocks directly. The # comment lines above each block are ignored by PEM parsers. If you save the halves as separate files, copy only from -----BEGIN to -----END.

The status line shows the key type and the SHA-256 fingerprint of the public key. Under More options, Also export JWK adds both keys as JSON Web Keys, ready for a JWKS endpoint.

Example

An ECDSA P-256 pair from one run (status ECDSA P-256 · SHA256:M5XlCgYDMfeDUbZK5zf4Ls9Yoty6Z7ZMnBRLNDez9ik=; the private key is shortened here):

# Public key (SPKI) — safe to share. Use for: JWT ES256, TLS and WebAuthn.
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFQ9l3IIJeZ/Gr+eTeSxcaz5nRIeK
CjPfYTDHxessE2l0N0Hy04ayLOAStn1hYxZynMjLr4Bx9N8a1Ww5FmNw/w==
-----END PUBLIC KEY-----

# Private key (PKCS#8, unencrypted) — keep it secret and never commit it.
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg…
-----END PRIVATE KEY-----

With Also export JWK, the public key comes out as:

{
  "kid": "LMBFgsOFKkBaHhvdZmMK7lyWELPeXPIpcaT5geRGgpY",
  "use": "sig",
  "alg": "ES256",
  "kty": "EC",
  "x": "FQ9l3IIJeZ_Gr-eTeSxcaz5nRIeKCjPfYTDHxessE2k",
  "y": "dDdB8tOGsizgErZ9YWMWcpzIy6-AcfTfGtVsORZjcP8",
  "crv": "P-256"
}

The kid is the RFC 7638 JWK thumbprint (the SHA-256 of the required members in a fixed order), so it is stable and anyone can recompute it from the key. The private JWK has the same fields plus d.

Key types

Type JWT algorithm Notes
RSA 2048 / 3072 / 4096 RS256, RS384, RS512, PS256 2048 is the minimum RFC 7518 allows; 4096 can take a few seconds to generate.
ECDSA P-256 ES256 Small and fast; widely supported.
ECDSA P-384 ES384 Use it when a policy requires a 384-bit curve.
Ed25519 EdDSA Needs a recent browser and a verifier that supports EdDSA.

To sign a test token with the new key, paste the whole output into the JWT Encoder (it finds the private block), then check the result in the JWT Decoder.

Equivalent OpenSSL commands

openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private.pem
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out private.pem
openssl genpkey -algorithm ed25519 -out private.pem
openssl pkey -in private.pem -pubout -out public.pem          # public half
openssl pkey -in private.pem -aes256 -out private-enc.pem     # add a passphrase
ssh-keygen -i -m PKCS8 -f public.pem                          # RSA/ECDSA public key → OpenSSH format

Common mistakes

  • Committing the private key. Add *.pem to .gitignore and keep keys in a secret manager or your platform’s key store.
  • Mixing up the halves. Verifiers need the public key; only the signer needs the private one.
  • Using a key for the wrong algorithm. An EC P-256 key only works with ES256, and an RSA key works with RS* and PS256. The Hash Generator is for digests, not key pairs.

Frequently asked questions

Which key type should I choose?

For JWTs and most new systems, ECDSA P-256 (ES256) is a good default: keys and signatures are small and fast. Choose RSA 2048 or 3072 when a system only accepts RSA (many SAML and older JWT setups). Ed25519 is the most modern option, but check that your verifier supports EdDSA first.

What is the difference between PKCS#8 and "BEGIN RSA PRIVATE KEY"?

PKCS#8 (BEGIN PRIVATE KEY) wraps any key type and names the algorithm inside. "BEGIN RSA PRIVATE KEY" is PKCS#1, an older RSA-only format. Web Crypto, Java and most modern libraries prefer PKCS#8. OpenSSL converts between them: openssl pkcs8 -topk8 -nocrypt -in rsa.pem -out pkcs8.pem.

Is it safe to generate keys in a browser?

The keys come from the browser's Web Crypto API, which draws on the operating system's cryptographically secure random generator. Nothing is uploaded. The private key is shown unencrypted, though, so treat the page like a terminal showing a key: copy it into a secret manager and close the tab.

How is the fingerprint calculated?

It is the SHA-256 of the public key's DER bytes (SPKI), in Base64. You get the same value with openssl pkey -pubin -in public.pem -outform DER | openssl dgst -sha256 -binary | base64. SSH fingerprints differ because SSH hashes its own public-key encoding.

Why does Ed25519 show an error?

Ed25519 in Web Crypto is fairly new, and older browsers throw a NotSupportedError. Update the browser, pick ECDSA P-256, or generate the key locally with openssl genpkey -algorithm ed25519 -out private.pem.

Last updated