RSA key pair generator — PEM or JWK, made by your browser

Choose a key size and what the key is for, and your browser's Web Crypto API creates an RSA key pair; you get the public and private keys as PEM or JWK files plus a SHA-256 fingerprint of the public key.

Live demo · real result from this tool
Key size
Format

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the RSA key pair generator

  1. Choose the Key size: 2048, 3072 or 4096 bits.
  2. Choose the Use: Signing — RSASSA-PKCS1-v1_5 / SHA-256 (RS256), Signing — RSA-PSS / SHA-256 (PS256) or Encryption — RSA-OAEP / SHA-256.
  3. Choose the Format: PEM or JWK.
  4. Press Generate. Larger keys can take a few seconds.
  5. Download or copy the public key (public.pem or public.jwk.json) and the private key (private.pem or private.jwk.json), and note the fingerprint.

What it does and when to use it

RSA key pairs let one side sign or encrypt and the other side verify or decrypt. Developers need them to sign JSON Web Tokens, to test an OAuth or OpenID Connect setup, to encrypt a secret for one recipient, or to try out a library without touching production keys.

The PEM option gives the standard text blocks: the public key in SPKI form (-----BEGIN PUBLIC KEY-----) and the private key in PKCS#8 form (-----BEGIN PRIVATE KEY-----). Most languages and libraries read both. The JWK option gives JSON objects for JWKS endpoints and JavaScript code.

For symmetric secrets such as AES or HMAC keys, use the encryption key generator. For an API token, the API key generator is simpler. To derive a key from a password, see the PBKDF2 generator.

How it works

The page calls crypto.subtle.generateKey with the chosen algorithm, the modulus length, the public exponent 65537 and SHA-256. The browser’s own cryptography code finds two large random primes and builds the key pair. The keys are exported as SPKI and PKCS#8 (PEM) or as JWK. The fingerprint is a SHA-256 digest of the SPKI bytes. Web Crypto only works on secure pages; if it is missing, the tool shows a message instead.

Worked examples

  • Default RS256 key. Size 2048, PEM: the result starts with -----BEGIN PUBLIC KEY-----, followed by -----BEGIN PRIVATE KEY----- and the stats Key size: 2048 bits and Algorithm: RSASSA-PKCS1-v1_5.
  • Encryption key as JWK. RSA-OAEP, JWK: the public key contains "alg": "RSA-OAEP-256", "kty": "RSA" and "e": "AQAB" (65537 in Base64url).
  • PS256 at 3072 bits. The stats show Key size: 3072 bits and Algorithm: RSA-PSS, plus a fingerprint such as 32:f7:24:b3:….

Limits and tips

  • Never commit the private key to a repository or paste it into a ticket.
  • Every press of Generate makes a new, unrelated pair. Download both halves before you leave the page.
  • The private key file is unencrypted. If you need a passphrase, wrap it with openssl or your key store.

Frequently asked questions

Which key size should I choose?
2048 bits is the common minimum today and is the fastest. NIST guidance (SP 800-57) pairs 3072 bits with protection beyond 2030. 4096 bits gives more margin but makes signing slower and keys larger. For new systems where you have a choice, elliptic-curve keys are smaller and faster, but this tool makes RSA only.
What is the difference between the three Use options?
RSASSA-PKCS1-v1_5 with SHA-256 is the RS256 algorithm used by most JSON Web Tokens. RSA-PSS is the newer signature scheme (PS256). RSA-OAEP is for encrypting small pieces of data, such as a symmetric key. The key maths is the same, but the browser tags each key for one job, and JWK exports record it.
Is the private key sent anywhere?
No. The key pair is created by crypto.subtle.generateKey inside your browser and stays on this page until you copy or download it. Note that the private key is not password-protected, so store the file somewhere safe or import it into a key store straight away.
Can I use these keys for SSH or a TLS certificate?
Not directly. SSH uses its own public key format, and a TLS certificate needs a certificate signing request built from the key. For those jobs, create the key with ssh-keygen or openssl instead.
What is the fingerprint for?
It is the SHA-256 hash of the public key in SPKI form, written as hex pairs. Compare it on both sides to confirm that the public key you installed is the one you made.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close