Skip to content
jwecodec

About

jwecodec was created and is maintained by the YouTube channel The Seasoned Programmer, who also makes jwtcodec.com for signed JWTs. Questions or suggestions? Email info@the-seasoned-programmer.com.

Every tool on this site runs in your browser using the built-in Web Crypto API. Tokens, keys and passwords are never sent to a server.

What is a JWE?

JSON Web Encryption (RFC 7516) is the encrypted sibling of the signed JWT. A signed token proves who issued it, but anyone can read it. An encrypted token can only be read by its intended recipient. JWEs are used for encrypted ID tokens in OpenID Connect, for passing sensitive claims between services, and anywhere a token passes through hands that shouldn't see what's inside.

How it works

  1. The sender picks a random content encryption key (CEK) and a random IV.
  2. The plaintext is encrypted with the CEK using the enc algorithm. The protected header is fed in as additional authenticated data, so changing it breaks decryption too.
  3. The CEK is delivered to the recipient using the alg algorithm: encrypted with their public key, wrapped with a shared key, or agreed with ECDH.
  4. The five parts are Base64URL-encoded and joined with dots: header, encrypted key, IV, ciphertext and authentication tag.

Key management algorithms (alg)

Content encryption algorithms (enc)

Nested JWTs

Encryption alone doesn't prove who sent a token: anyone with the recipient's public key can encrypt one. To get both secrecy and proof of origin, sign a JWT first and then encrypt the whole signed token as the JWE plaintext, setting "cty": "JWT" in the header. The decoder recognises nested JWTs and shows their claims.

Best practices