Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 3 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

Decode a JWT with jose

Decoding reads what is inside a token, its header and claims, before the token is validated.

All jose examples jose: usage and stats

Decode a JWT with jose: screenshot of the example below running
The code below, running in Chromium on our server (Oct 12, 2026). Press Run to see it live and change it.

How it works

  1. Make a sample token. The code signs a token with SignJWT and adds a kid to the protected header so there is something to inspect. [1]
  2. Decode the header. decodeProtectedHeader(jwt) returns the header object, so the code can print alg, typ and kid. [1]
  3. Decode the claims. decodeJwt(jwt) returns the claims set. The README lists it as a step before validation, so this example decodes only and does not verify the signature. [1]

Run and edit it

It runs in your browser, in a sandboxed frame that cannot see this site; the packages load from esm.sh only after you press Run.

import { SignJWT, decodeJwt, decodeProtectedHeader } from 'jose'

const secret = new TextEncoder().encode('demo-secret-at-least-32-bytes-long!!')

const jwt = await new SignJWT({ name: 'Ada', roles: ['admin', 'billing'] })
  .setProtectedHeader({ alg: 'HS256', typ: 'JWT', kid: 'key-2024-01' })
  .setSubject('user-42')
  .setIssuedAt()
  .setExpirationTime('1h')
  .sign(secret)

console.log('token:', jwt.slice(0, 44) + '...')

const header = decodeProtectedHeader(jwt)
console.log('header.alg:', header.alg)
console.log('header.typ:', header.typ)
console.log('header.kid:', header.kid)

const claims = decodeJwt(jwt)
console.log('claims.sub:', claims.sub)
console.log('claims.name:', claims.name)
console.log('claims.roles:', claims.roles.join(', '))
console.log('issued at:', new Date(claims.iat * 1000).toISOString())
console.log('expires at:', new Date(claims.exp * 1000).toISOString())
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Paste a token from your own app into the jwt variable to see its header and claims. Code written by AgentGid [1].

Checked Oct 12, 2026: it starts without errors in Chromium with jose 6.2.12. Needs WebGL.

More jose examples

Sign a JWT with jose Verify a JWT with jose Generate keys and export a JWK with jose Encrypt and decrypt a JWT with jose

Sources

  1. jose README (GitHub)

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with jose? Ask AgentGid →