
JWT Decoder: Decode and Debug JWTs Online — Complete Guide
Decode, verify, and debug JWT tokens. Here's the complete developer guide. JWT Structure A JWT has three base64url-encoded parts: header.payload.signature eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 .eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFsaWNlIiwiaWF0IjoxNTE2MjM5MDIyfQ .SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c Decoded header: {"alg":"HS256","typ":"JWT"} Decoded payload: {"sub":"1234567890","name":"Alice","iat":1516239022} Decode Without Library (JavaScript) function decodeJWT ( token ) { const [ header , payload , signature ] = token . split ( ' . ' ); const decode = ( str ) => JSON . parse ( atob ( str . replace ( /-/g , ' + ' ). replace ( /_/g , ' / ' ))); return { header : decode ( header ), payload : decode ( payload ), signature , // raw base64url — not decoded }; } const { header , payload } = decodeJWT ( token ); console . log ( payload . sub ); // "1234567890" console . log ( payload . exp ); // Unix timestamp jsonwebtoken Library const jwt = require ( ' jsonwebtoken ' ); const SE
Continue reading on Dev.to Webdev
Opens in a new tab

