How do I generate a public and private key pair?
Pick an algorithm (RSA 2048, RSA 4096 or EC P-256) and press Generate. The tool uses the browser WebCrypto API to create a matching public and private key, then exports the public key as an SPKI PEM block and the private key as a PKCS8 PEM block, with an optional JWK view. Everything happens in your browser and no key is ever uploaded.
What a key pair is, and why there are two of them
Asymmetric cryptography uses two keys that belong together: a public key and a private key. The public key is meant to be shared, published, printed on a business card if you like. The private key is the secret half and never leaves your control. What one key locks, only the other can unlock, and that simple asymmetry is what makes secure messaging, digital signatures and HTTPS possible. This tool creates a fresh pair for you and hands you both halves to save.
Everything happens in your browser through the built-in WebCrypto API. The random numbers, the key generation and the export to text all run on your own device. Nothing is uploaded, so you can generate keys you actually intend to use.
PEM, DER and JWK
A key is really just a structured block of numbers. DER is the compact binary form of that structure. PEM is the same bytes base64-encoded and wrapped between BEGIN and END marker lines, which is the plain-text format that servers, SSH-adjacent tools and libraries expect to paste in. JWK is a JSON version favoured in web and token work. The public key is exported in SPKI format and the private key in PKCS8, both standard containers that most software recognises.
Because each key is random, no two runs give the same pair, and there is no fixed example to show: the shape and the labels above are what stay constant, not the contents.
RSA or EC?
RSA is the most widely supported choice and the one to pick if you are unsure. The keys here are generated as RSA-OAEP with a 65537 public exponent, which pairs directly with the public key message encrypter on this site: generate a pair, hand out the public key, and anyone can encrypt a short message that only your private key opens. RSA 2048 is still considered strong for general use; RSA 4096 adds margin at the cost of slower generation and slower operations.
EC, or elliptic curve, produces much smaller and faster keys for a comparable security level, which is why modern systems lean on it. The P-256 keys here are generated for ECDH key agreement rather than for directly encrypting a message, so they are the right choice when your target system asks for an EC key, not when you simply want to encrypt text here.
Keeping the private key safe
The entire security of a key pair rests on the private key staying private. Anyone who obtains it can read messages meant for you and impersonate your signatures, and there is no way to revoke a leaked key on its own. Store it somewhere encrypted, such as a password manager or a protected file, never in a shared document or an email body. The public key, by contrast, is safe to send anywhere: that is its whole job.
This page is a convenience for generating keys and understanding their format, not a key-management system. For production infrastructure, use your platform's proper tooling and hardware-backed storage where you can. This is general guidance, not security advice for a specific system.
How we work it out
crypto.subtle.generateKey creates the pair (RSA-OAEP with a 2048 or 4096-bit modulus and 65537 exponent, or ECDH on the P-256 curve), all marked extractable. The public key is exported as SPKI DER and the private key as PKCS8 DER, each base64-encoded and wrapped at 64 characters between standard PEM header and footer lines. JWK is exported separately on request.
Frequently asked questions
Are my keys sent anywhere?
No. The key pair is created and exported entirely in your browser using the built-in WebCrypto API. Neither the public key nor the private key is uploaded, logged or seen by anyone, so it is safe to generate keys you intend to use for real.
What is the difference between the public and private key?
They are a matched pair. The public key can be shared with anyone and is used to encrypt messages to you or to verify your signatures. The private key must stay secret, because it is the only thing that can decrypt those messages or create signatures. If someone gets your private key, the security is gone.
What is the difference between PEM, DER and JWK?
DER is the raw binary encoding of a key. PEM is that binary base64-encoded and wrapped between BEGIN and END lines, which is the text format most tools and servers expect. JWK is a JSON representation used a lot in web and token work. This tool gives you PEM by default and JWK on request.
Should I choose RSA or EC?
RSA is the most widely supported and pairs with the public key message encrypter here, so it is the safe default. EC keys (elliptic curve) are much smaller and faster for the same security level and are common in modern systems, but they are used for signing or key agreement rather than directly encrypting a message. Pick RSA unless you specifically need EC.
Why does RSA 4096 take a few seconds?
Generating a large RSA key means finding big random prime numbers, which is genuinely slow work. RSA 4096 gives a larger security margin than 2048 but is noticeably slower to generate and to use. For most purposes RSA 2048 is still considered strong. The button is disabled while the key is being made.