RS256 vs ES256: RSA or elliptic curve signatures for your JWTs
ES256 makes compact tokens and signs quickly. RS256 is supported everywhere and verifies quickly. Both are safe when your library handles them correctly.
RS256 and ES256 are both public key algorithms, so they solve the same problem: one issuer signs, many services verify. RS256 uses RSA with a 2048-bit or larger key. ES256 uses ECDSA on the P-256 curve with a 256-bit key that gives about the same security. The differences show up in token size, signing speed and how much can go wrong in an implementation.
By TechCompare · Updated
How this is calculated
Size is the most visible difference. An ES256 signature is two 32-byte numbers, r and s, for 64 bytes, or 86 Base64url characters. An RS256 signature with a 2048-bit key is 256 bytes, or 342 characters. That gap matters when tokens travel in cookies or headers on every request. Key generation and signing are quick with ECDSA, while RSA verification is very cheap, so a busy API that only verifies won't feel much difference. ECDSA has sharper edges. Each signature needs a fresh random or deterministic nonce, and a repeated nonce leaks the private key. JWS also writes the signature as raw r and s, not the DER format many crypto libraries produce, so a hand-built signer can create tokens that other libraries reject. A verifier needs care too: in 2022 a Java bug known as Psychic Signatures accepted an ECDSA signature of all zeros. RSA's pitfalls are mostly about key size, since RFC 7518 requires at least 2048 bits. ES384 and ES512 use the P-384 and P-521 curves with 96 and 132 byte signatures, and they're rarely needed for tokens.
Verdict
Pick ES256 for new systems that control both ends and care about token size, like mobile apps and cookies. Pick RS256 when you need every language, gateway and identity provider to work out of the box. Either way, keep libraries patched and let the library build the signature format.
More JWT scenarios
Related guides
Frequently asked questions
Why does my ES256 signature fail in another library?
Is ES256 more secure than RS256?
What about EdDSA?
Related tools
Text Encoding Converter
Convert between Text, Base64, Binary, Hexadecimal, and Decimal formats.
Use tool ➜Unix Timestamp
Convert between Unix timestamps and human-readable dates.
Use tool ➜JSON Formatter
Validate, format, and minify JSON. Browse it as a tree, run JSONPath queries, compare two documents, or validate against a JSON Schema.
Use tool ➜