RSA Key Pair Generator

Generate RSA key pairs (2048/4096-bit) in PEM or JWK format with your browser's Web Crypto API. Keys are not uploaded or stored by the page.

  • Runs in your browser
  • Tool input is not uploaded to ZeroTool servers
  • Free · No Sign-Up

Generate a key pair to view its public and private keys.

Examples, details and FAQ Worked examples, how it compares with other tools, and answers to common questions.

Security Notes

  • Keep your private key secret. Anyone with the private key can decrypt messages or forge signatures.
  • Share only your public key — it is designed to be public.
  • This tool generates keys for testing and development. For production use, manage keys with a dedicated secret manager (AWS KMS, HashiCorp Vault, etc.).

What the Output Looks Like

PEM gives the public key as SubjectPublicKeyInfo (-----BEGIN PUBLIC KEY-----) and the private key as unencrypted PKCS#8 (-----BEGIN PRIVATE KEY-----). OpenSSL 3.6 reads both directly (Private-Key: (2048 bit, 2 primes)). Older software that expects PKCS#1 (-----BEGIN RSA PRIVATE KEY-----) needs a conversion; see the commands below.

JWK (RFC 7517) is what the browser's Web Crypto API exports. A 2048-bit public key generated with RSA-OAEP has these fields; the modulus n changes on every run and is shown here by its length:

{
  "alg": "RSA-OAEP-256",
  "e": "AQAB",
  "ext": true,
  "key_ops": [
    "encrypt"
  ],
  "kty": "RSA",
  "n": "<342 characters>"
}

The modulus of a 2048-bit key is 256 bytes, so n is always 342 base64url characters. With RSASSA-PKCS1-v1_5 the public JWK has "alg": "RS256" and "key_ops": ["verify"]. The output has no kid or use; add a kid before publishing the key in a JWKS endpoint, because JWT headers refer to keys by kid.

What Stays the Same in Every Key

The random part of a key is its modulus, but the bytes around it are fixed by the key size. That is useful when a form asks you to paste a public key and you want to check that you copied all of it.

For a 2048-bit public key in PEM, the Base64 text between the two header lines is always 392 characters on 7 lines (the last line has 8). It begins with MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA, which encodes the key type and lengths, and ends with IDAQAB, which contains the exponent 65537:

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA…
…
-----END PUBLIC KEY-----

A 4096-bit public key is 736 characters on 12 lines, starts with MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA and ends with AwEAAQ==. The algorithm setting does not change these bytes. If a pasted key is shorter, or ends differently, part of it was lost while copying.

After converting a 2048-bit public key with ssh-keygen -i -m PKCS8 -f public-key.pem, the line always starts with ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ and is 380 characters long, with no comment at the end. Saved as public-key.pub, ssh-keygen -l prints the key size, SHA256: followed by 43 characters, and no comment (RSA):

$ ssh-keygen -l -f public-key.pub
2048 SHA256:… no comment (RSA)

Use the Keys With OpenSSH and OpenSSL

These commands were run on the downloaded files with OpenSSH on macOS and OpenSSL 3.6.1. ssh-keygen refuses a private key file that others can read ("Permissions 0644 … are too open"), so restrict it first:

chmod 600 private-key.pem

# OpenSSH public key for ~/.ssh/authorized_keys
ssh-keygen -y -f private-key.pem
ssh-keygen -i -m PKCS8 -f public-key.pem      # same result from the public key

# PKCS#1 ("BEGIN RSA PRIVATE KEY") for older software
openssl rsa -in private-key.pem -traditional -out private-key-pkcs1.pem

# Inspect the key
openssl pkey -in private-key.pem -noout -text

Choosing Size and Algorithm

Key sizeSecurity strength (NIST SP 800-57 Part 1 Rev. 5, Table 2)
1024-bit80 bits, no longer allowed
2048-bit112 bits
3072-bit128 bits (not offered here)
4096-bitbetween 128 and 192 bits

The algorithm setting decides what the browser lets the key do and what the JWK says: RSA-OAEP (with SHA-256) for encryption, RSASSA-PKCS1-v1_5 (with SHA-256, JWT RS256) for signatures. The PEM files carry no algorithm, so OpenSSL can use the same PEM key for either purpose.

Limits

  • Generation and export failures show a reason in the page language: unavailable Web Crypto, an unsupported operation, a browser security block, or a general failure. Old keys are cleared when generation starts. Copy first uses the Clipboard API and then a temporary selected text field if that API is missing or fails. If both methods fail, select the key manually or use Download. The temporary field is removed after the copy attempt.

  • Key sizes 2048 and 4096 only; the public exponent is always 65537 (AQAB).

  • The private key PEM is not encrypted with a passphrase. Store the file somewhere protected, or encrypt it with openssl pkcs8 -topk8 -in private-key.pem -out encrypted.pem.

  • No OpenSSH private key format and no certificate or CSR output; use ssh-keygen and openssl req for those.

  • 4096-bit keys take noticeably longer to generate than 2048-bit keys. The page waits for crypto.subtle.generateKey, which returns a Promise; Chromium runs RSA key generation on a separate thread named "WebCrypto" (source), so in Chromium the page does not freeze while it waits.

  • There is no Clear button. Press Ctrl or Command + L inside the tool to empty both outputs.

Check a Generated Export Pair

For a reproducible check, select 2048-bit, RSASSA-PKCS1-v1_5, and PEM. Generate a pair. The public output begins with -----BEGIN PUBLIC KEY-----; the private output begins with -----BEGIN PRIVATE KEY-----. Import the public output as SPKI and the private output as PKCS8, using SHA-256. The imported private key reports a 2048-bit modulus. Export those same imported keys as JWK: their n values match and both e values are AQAB. The private JWK contains d; the public JWK does not. Sign the UTF-8 message ZeroTool RSA export example with the private key. Verification with the public key succeeds for that message and fails after replacing it with ZeroTool RSA export changed.

FAQ

Are my keys sent to any server?

No. The page calls the browser's Web Crypto API (crypto.subtle.generateKey) and makes no network request with the keys. It does not write them to localStorage or cookies, and because this page handles private keys it does not load Google Analytics or AdSense. The keys stay in the page until you press Ctrl or Command + L in the tool, generate again or close the tab. Copy puts a key on your system clipboard and Download writes a file, so delete those copies when you no longer need them.

What is the difference between RSA-OAEP and RSASSA-PKCS1-v1_5?

RSA-OAEP is used for asymmetric encryption (encrypt data with public key, decrypt with private key). RSASSA-PKCS1-v1_5 is used for digital signing (sign with private key, verify with public key). The choice changes the JWK fields alg and key_ops; the PEM files are the same kind of key for both.

Which key size should I choose?

A 2048-bit key gives 112 bits of security strength (NIST SP 800-57 Part 1 Rev. 5, Table 2), and 2048 bits is the smallest RSA modulus the CA/Browser Forum Baseline Requirements (section 6.1.5) allow for TLS certificates. A 4096-bit key gives between 128 and 192 bits, takes longer to generate, and makes every signature 512 bytes instead of 256. Use what the system that will read the key asks for.

What is the PEM format?

PEM (Privacy Enhanced Mail) is Base64-encoded DER data wrapped in -----BEGIN/END----- lines; the label says what is inside (PUBLIC KEY, PRIVATE KEY, CERTIFICATE). It is the usual format for keys and certificates in OpenSSL, nginx, and most TLS software. This tool writes 64 characters per line.

What is the JWK format?

JWK (JSON Web Key) is a JSON representation of cryptographic keys defined by RFC 7517. It is commonly used in OAuth 2.0, OIDC, and JWT authentication flows. The exported JWK has no kid or use field.

Can I use the key for SSH?

Yes, after a conversion. ssh-keygen -y -f private-key.pem prints the ssh-rsa line for ~/.ssh/authorized_keys, and ssh-keygen -i -m PKCS8 -f public-key.pem gives the same line from the public key. ssh-keygen refuses the private key file until only you can read it (chmod 600). The tool cannot write the OpenSSH private key format; use ssh-keygen -t rsa for that.