The jjwt library (Java JWT, io.jsonwebtoken) is an open-source Java library for creating, signing, parsing and validating JSON Web Tokens (JWTs). It hides the Base64URL encoding, JSON handling and cryptographic details behind a fluent builder and parser API, which makes it a common choice for stateless authentication in Spring Boot applications.
The current API line is 0.12.x. It replaced several older methods that you will still see in tutorials, so the examples below use the modern calls and point out what changed.
A JWT has three Base64URL parts separated by dots: a header, a payload of claims and a signature. Building and checking those correctly is easy to get wrong. jjwt gives you:
sub, iss, iat, exp) and custom claims.Keep in mind that a signed JWT is readable by anyone who holds it. Never put passwords or other secrets in the claims.
jjwt 0.12 is split into an API artifact and runtime-only implementation artifacts.
Check Maven Central for the latest 0.12.x or newer release before pinning a version.
signWith(key) picks the strongest HMAC algorithm the key length allows. The builder methods subject, issuer, issuedAt and expiration replace the old setSubject, setIssuer, setIssuedAt and setExpiration, which are deprecated.
parseSignedClaims only accepts a signed token, so an unsigned token with alg: none is rejected. The older Jwts.parserBuilder().setSigningKey(...) and parseClaimsJws calls are deprecated in 0.12.
Spring Security 6 ships its own resource server support for JWTs (spring-boot-starter-oauth2-resource-server), which is usually the better choice when tokens come from an identity provider. jjwt fits when your own service issues and verifies its tokens. A minimal filter looks like this:
Register the filter in your SecurityFilterChain with addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class) and make the session policy stateless.
exp, and check iss and aud when you have several issuers.No. They are separate libraries with different APIs. Both create and verify JWTs; jjwt uses a fluent builder and parser, and Spring Security itself builds on Nimbus JOSE.
jjwt enforces the RFC 7518 minimum key sizes. An HS256 key must be at least 256 bits, so a short string secret is rejected. Use a longer random secret or Jwts.SIG.HS256.key().build() to generate one.
A JWT is valid until it expires, so keep lifetimes short and track revoked token IDs (the jti claim) or refresh tokens in a store if you need immediate revocation.
Yes. 0.12 supports JWE for encrypted tokens, but most applications only need signed tokens.
jjwt is a compact library for issuing and verifying JWTs in Java. Use the 0.12 API (subject, signWith, verifyWith, parseSignedClaims), keep keys out of code, use short expiry times, and consider Spring Security's resource server support when an external identity provider issues your tokens.