Create elliptic-curve keys with this ECDSA key generator
This ecdsa key generator creates elliptic-curve key pairs with WebCrypto. EC keys are much smaller than RSA keys of similar strength, and signing with them is faster, which is why ES256 is a popular JWT algorithm and P-256 is widely used in TLS. The tool also creates Ed25519 keys for EdDSA.
Choosing a curve
| Curve | JWT algorithm | Notes |
|---|---|---|
| P-256 (secp256r1, prime256v1) | ES256 | The most widely supported choice |
| P-384 | ES384 | Required by some government and high-assurance profiles |
| P-521 | ES512 | Largest NIST curve, less commonly used |
| Ed25519 | EdDSA | Deterministic signatures, fast, 32-byte keys |
Ed25519 depends on browser support. If your browser does not offer it in WebCrypto, the tool says so and you can pick P-256 instead or update the browser.
Formats explained
- PKCS#8 / SPKI:
BEGIN PRIVATE KEYandBEGIN PUBLIC KEY. Works with jose, Node.js, Java and Go. - SEC1:
BEGIN EC PRIVATE KEY, the classic OpenSSL format, plus an SPKI public key. It exists for the P curves only, so Ed25519 keys are always shown in PKCS#8. - JWK / JWKS: a private JWK and a public JWKS with
alg,use: "sig"and akidderived from the public key hash.
Example
The public part of a P-256 key in JWK format:
{
"keys": [
{
"kty": "EC",
"x": "RLVHTEmboKyxlzoYnQfN8weFO6bQ1nZXIlfUHpw2d_I",
"y": "JQTKuNKCT8Wy35lx40mdkc5_N87-P_2CiLRZF3kaD9o",
"crv": "P-256",
"alg": "ES256",
"kid": "7-XNZjnLVIzRhP9Y",
"use": "sig"
}
]
}
The private JWK has the same members plus d, the secret scalar. Never publish the private JWK.
Common mistakes
- Curve and algorithm mismatch: a P-384 key cannot sign ES256 tokens. Each curve pairs with exactly one JWT algorithm, as shown in the table above.
- Library cannot read the key: code that expects
BEGIN PRIVATE KEYusually rejects SEC1 files. Generate again in PKCS#8 format. - Signature size surprises: JWT uses raw 64-byte ES256 signatures, while TLS and X.509 use DER-encoded ones. Let your library handle the conversion.
Next steps
Paste the private PEM or JWK into the JWT encoder with ES256 or EdDSA to sign a test token. Need the PEM form of a JWK later? Use the JWK to PEM converter. For server logins, generate keys in OpenSSH format with the SSH key generator, because this page outputs PEM and JWK only.
Checking and using the key with OpenSSL
Once you have saved the PEM files, OpenSSL can confirm what you generated and sign a test file with it. For the P curves:
# show the curve and the public point
openssl pkey -in private.pem -text -noout
# sign a file and verify the signature
openssl dgst -sha256 -sign private.pem -out file.sig file.txt
openssl dgst -sha256 -verify public.pem -signature file.sig file.txt
The last command prints Verified OK when the two halves belong together, which is a quick way to make sure you did not mix up keys from two different runs. Use -sha384 with P-384 and -sha512 with P-521 to match ES384 and ES512. Ed25519 keys sign the message directly without a separate digest, so use openssl pkeyutl -sign -rawin instead of dgst.
Privacy
Keys are generated in your browser by WebCrypto. They are not uploaded, logged or stored, so save the private key before you leave the page.