RSA Key Pair Generator

Generate a 2048, 3072, or 4096-bit RSA key pair in your browser. You get the private and public key as PEM, the public key in OpenSSH format, and both as JWK.

Updated
Generated in your browser and never sent anywhere.
For production keys, prefer generating on the machine that uses them.

How to use the RSA Key Generator

  1. Choose the Key size, the Purpose, and the Hash. Add an SSH key comment if you'll use the key for SSH.
  2. Press Generate key pair. A 4096-bit key can take a few seconds.
  3. Copy or download each format. Save the private key right away; the page doesn't keep it.

How it works

The key pair is created by your browser's Web Crypto API (crypto.subtle.generateKey) with the public exponent 65537, then exported:

  • Private key: PKCS#8, wrapped as PEM (-----BEGIN PRIVATE KEY-----).
  • Public key: SubjectPublicKeyInfo (SPKI) as PEM (-----BEGIN PUBLIC KEY-----), the format OpenSSL, Java, and most JWT libraries read.
  • OpenSSH: the ssh-rsa wire format built from the key's modulus n and exponent e, ready for ~/.ssh/authorized_keys. The fingerprint is the SHA-256 of that blob, the same value ssh-keygen -lf prints.
  • JWK: the JSON Web Key form for JOSE libraries, with the algorithm set by the purpose you chose.

The purpose is stored with the key: a signing key can't be used for encryption in Web Crypto and the other way round, but the PEM files work anywhere.

Examples

  • A 2048-bit OpenSSH public key starts with ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB. The AQAB part is the exponent 65537.
  • To use a key for JWT RS256, choose Signing (RS256, PKCS#1 v1.5) with SHA-256 and give the private PEM to your signing library.
  • To check a generated key with OpenSSL: openssl pkey -in private-key.pem -noout -text shows Private-Key: (2048 bit, 2 primes).

Which key size to choose

SizeSecurity (approx.)Use
2048 bits112-bitMinimum today; fine for most TLS, JWT, and SSH keys until about 2030
3072 bits128-bitRecommended for keys meant to last past 2030
4096 bitsabout 140-bitLong-lived keys; slower to generate and use

Limitations

  • The private key is not encrypted with a passphrase. Protect the file, or encrypt it afterwards with openssl pkcs8 -topk8 or ssh-keygen -p.
  • Private keys are given in PKCS#8 PEM, not the OpenSSH private key format. Current OpenSSH accepts PKCS#8 PEM directly.
  • For production servers and certificate authorities, generate keys on the machine that uses them or in a hardware security module.
  • Only RSA is offered. For SSH, Ed25519 keys are shorter and faster.

Frequently asked questions

Is it safe to generate keys in a browser?

The keys come from the browser's cryptographic random generator and never leave the page. For keys that protect production systems, many teams still prefer generating them on the server itself.

What is the difference between PEM and OpenSSH format?

Both hold the same public key. PEM (BEGIN PUBLIC KEY) is used by OpenSSL and most libraries; the OpenSSH line (ssh-rsa AAAA...) is what goes into authorized_keys.

Can I use the key for JWT signing?

Yes. Choose a signing purpose, then use the private PEM to sign and the public PEM or JWK to verify RS256 or PS256 tokens.

Do you keep a copy of my key?

No. The key exists only in this page until you close it. Download it before you leave.

Often used together with the RSA Key Generator.

  • JWT Decoder

    Decodes JSON Web Tokens, explains the claims, and verifies HS, RS, PS, and ES signatures.

  • HMAC Generator

    Signs text or files with HMAC-SHA256 and other hashes, and checks signatures.

  • Random Token Generator

    Generates secure random tokens and API keys with a chosen length, alphabet, and prefix.