Skip to content
BetterPass logo

Token Decoder Tools — JWT, PASETO, SAML & OIDC

Work with modern authentication and security token formats. Decode, verify, generate, and inspect — all client-side, zero server exposure for your data.

What Are Security Tokens? JWT, PASETO, and Token Authentication Explained

When you sign in with Google or Facebook on a new app, that app never sees your password — instead, it gets a tiny, signed piece of data that proves who you are. That's a security token — a digital credential used to authenticate users, authorize access, or securely transmit identity information between systems. In modern authentication architectures, tokens replace traditional session-based cookies by providing a stateless, portable way to verify that a request comes from an authenticated party. A token typically contains information about the user (claims), issuance and expiration timestamps, and a cryptographic signature or proof that prevents tampering. Token-based authentication is the foundation of modern APIs, single sign-on (SSO), and distributed system security. Popular token formats include JWT, PASETO, opaque tokens, SAML assertions, and OIDC ID tokens.

Different token types serve different purposes. JWT (JSON Web Tokens) are the most widely adopted — self-contained tokens with JSON claims signed via HMAC or public-key cryptography. PASETO offers a more secure alternative by eliminating algorithm agility vulnerabilities through versioned, fixed-algorithm protocols (v4.public for Ed25519, v4.local for XChaCha20-Poly1305). Opaque tokens are random strings validated via server-side lookup, offering instant revocation at the cost of requiring database queries. SAML assertions are XML-based tokens used primarily in enterprise SSO (often paired with OIDC). OIDC ID Tokens (OpenID Connect) are JWTs specifically designed to convey identity information from identity providers to relying parties.

Choosing the right token format depends on your requirements. JWT is the default choice for most web and mobile APIs due to broad ecosystem support. PASETO is recommended when security is paramount and algorithm agility must be eliminated. Opaque tokens suit scenarios requiring immediate revocation or regulatory limits on embedded claims. SAML remains necessary for enterprise federation with legacy identity providers. For the underlying cryptographic primitives used in token signing and verification, explore our HMAC generator and Base64 decoder. All BetterPass token tools operate entirely client-side — your tokens are decoded, verified, and inspected in your browser without ever being sent to a server.

Curious how these formats actually differ in practice? The JWT vs PASETO Playground lets you feed in one JSON payload and one key, then see both token types generated side by side with live byte-size counts and verification timing.

Choosing the Right Token Type

Token formats serve different purposes. The right type depends on your architecture and security requirements:

1. Stateless API Authentication

JWT (RS256/ES256) — Best for microservices, mobile apps, and SPAs needing offline verification. Self-contained tokens with embedded claims (iss, sub, aud, exp). Stateless — no database lookup required. Use asymmetric algorithms (RS256, ES256) for cross-service trust.

PASETO v4.public — Modern alternative to JWT with Ed25519 signatures. Fixed algorithm per version eliminates JWT's algorithm confusion attacks. Key separation prevents encryption/signing key misuse.

2. Revocable Session Tokens

Opaque Tokens — Best for traditional web apps, admin panels, and compliance-heavy environments. Random string validated via server-side lookup (Redis/DB). Instant revocation — just delete from store. No claims embedded, minimal client-side info.

3. Enterprise SSO & Federation

SAML Assertion — XML-based SSO standard used with ADFS, Okta, Azure AD, and PingIdentity. Supports complex federation scenarios with IdP/SP metadata exchange. Decode Base64/DEFLATE encoded assertions for troubleshooting.

4. OpenID Connect & User Identity

OIDC ID Token — JWT-based identity layer on top of OAuth 2.0. Contains verified user identity claims (sub, email, name). Verify with provider's JWKS endpoint. Used by Google, Microsoft, GitHub, Auth0, Keycloak, and custom providers.

Quick Token Type Selection

Stateless API Auth

Microservices, mobile apps, SPAs needing offline verification

Best: JWT (RS256/ES256)
Alternative: PASETO v4.public

Revocable Session Tokens

Traditional web apps, admin panels, compliance-heavy environments

Best: Opaque Token
Store: Redis/DB with TTL

Enterprise SSO / Federation

SAML 2.0, ADFS, Okta, Azure AD, PingIdentity

Decode: SAML Assertion
Verify: SP-initiated / IdP-initiated

OpenID Connect Login

Google, Microsoft, GitHub, Auth0, Keycloak, custom OIDC providers

Verify: OIDC ID Token
Verify: RS256 with pasted JWK

Modern Crypto-First Design

New projects wanting to avoid JWT algorithm confusion

Use: PASETO v4
v4.local: XChaCha20-Poly1305 (encrypted)
v4.public: Ed25519 (signed)

Simple API Keys / Secrets

Service-to-service, webhook secrets, one-time tokens

Generate: Opaque Token Generator
Length: 8-256 characters (a 32-character URL-safe token ≈ 192 bits)
Store hash: Bcrypt/Argon2 in DB

Which Token Format Should You Use?

Answer a few quick questions and we'll point you at the right tool.

1Q12Q23Q3

What are you building?

JWT vs PASETO vs Opaque vs SAML: Token Format Comparison

PropertyJWTPASETO v4Opaque TokenSAML AssertionOIDC ID Token
Structureheader.payload.signature (Base64URL)version.purpose.payload.footer (Base64URL)Random bytes (Base64URL/hex)XML (Base64 + optional DEFLATE)JWT with OIDC claims
StatefulNo (self-contained)No (self-contained)Yes (server lookup)No (self-contained)No (self-contained)
RevocationHard (blocklist / short exp)Hard (same as JWT)Instant (delete from store)Hard (short NotOnOrAfter)Hard (same as JWT)
Algorithm AgilityYes (risk)No (fixed per version)N/AXML Signature (configurable)JWT algorithms (RS256/ES256)
Key ManagementJWK / JWKSPASETO keys (distinct from JWT)Symmetric key for DB encryptionX.509 certs / metadataJWKS from provider
Payload VisibilityPublic (Base64URL decode)v4.public: public; v4.local: encryptedOpaque (random)Public (XML)Public (JWT decode)
Size Overhead~100-300 bytes~100-300 bytesMinimal (~32-43 bytes)Large (XML verbosity)~200-500 bytes
Best ForCross-service, stateless, OIDCModern apps, crypto-first designSessions, revocable, complianceEnterprise SSO, federationOIDC login, user identity

JWT (JSON Web Token) — RFC 7519

Diagram showing a JWT split into three dot-separated segments: header in red, payload in blue, signature in green

Anatomy of a JWT

eyJhbGciOiJIUzI1NiJ9
.
eyJzdWIiOiIxMjM0NTY3ODkwfQ
.
SflKxwRJSMeKKF2QT4fwpM
Header
Payload
Signature
alg + typ
claims (iss, sub, exp)
verify integrity

Structure & Claims

Registered Claims (IANA)

  • iss — Issuer
  • sub — Subject (user ID)
  • aud — Audience
  • exp — Expiration (Unix timestamp)
  • nbf — Not Before
  • iat — Issued At
  • jti — JWT ID (anti-replay)

Private / Public Claims

  • Custom: role, permissions, tenant_id
  • Namespaced: https://example.com/claim
  • Avoid collisions: use URI format
⚠ Algorithm Confusion: Never trust the alg header. Always enforce expected algorithm in verification code. Use PASETO to eliminate this class of vulnerability.

Signing Algorithms

AlgorithmTypeKeyUse Case
HS256/384/512HMACShared secret (≥32 bytes)Single-party, internal services
RS256/384/512RSASSA-PKCS1-v1_5RSA keypair (≥2048 bits)Cross-service, public verification
ES256/384/512ECDSAEC keypair (P-256/P-384/P-521)Smaller sigs, mobile/IoT
PS256/384/512RSA-PSSRSA keypairModern RSA (preferred over RS256)
EdDSAEd25519/Ed448Edwards curve keypairPASETO v4.public, high perf

HS256 vs RS256 vs ES256: Choosing a JWT Signing Algorithm

HS256 (HMAC-SHA256)

Symmetric signing with a shared secret. Fastest option — ideal for single-service apps, API gateways, and microservices on the same trust boundary. Key must be ≥32 bytes. No support for third-party verification.

RS256 (RSA-SHA256)

Asymmetric signing with an RSA keypair. Anyone can verify with the public key — essential for cross-service auth, OpenID Connect, and third-party integrations. Larger signatures than ES256 but universally supported.

ES256 (ECDSA P-256)

Asymmetric signing with elliptic curve keys. Compact signatures (~64 bytes vs RSA's ~256 bytes) — ideal for mobile tokens, IoT, and constrained environments. Slower signing than HMAC but faster than RSA.

PASETO — Platform-Agnostic Security Tokens

Version 4 (Current)

v4.public — Public Key Signing

  • Algorithm: Ed25519 (EdDSA)
  • Public verification, private signing
  • Payload: visible (like JWT)
  • Use: Inter-service auth, OIDC-like flows

v4.local — Symmetric Encryption

  • Algorithm: XChaCha20-Poly1305
  • Authenticated encryption (AEAD)
  • Payload: encrypted (confidential)
  • Use: Encrypted cookies, sensitive claims
Key Separation: PASETO derives distinct keys for encryption vs authentication using HKDF. A v4.local key cannot verify v4.public tokens and vice versa. This prevents key confusion attacks.

Opaque Tokens — Server-Side Sessions

Architecture

Generation

  • 32+ bytes from CSPRNG
  • Base64URL encode for transport
  • Store hash (Bcrypt/Argon2) in DB

Validation

  • Lookup token hash in Redis/DB
  • Check expiry, revocation flag
  • Return associated user/session data

Revocation

  • DELETE from store = instant
  • No blocklist needed
  • Supports "logout everywhere"

SAML 2.0 Assertions — Enterprise SSO

Decoding Flow

  1. Receive Base64 string (HTTP Redirect/POST binding)
  2. Base64 decode → raw bytes
  3. Check for DEFLATE compression (zlib header 0x78)
  4. If compressed: inflate (DEFLATE) → XML
  5. Parse XML → inspect assertions, conditions, signatures

Key XML Elements

<Assertion/>

  • Issuer — IdP entity ID
  • Subject/NameID — user identifier
  • Conditions/NotBefore/NotOnOrAfter — validity window
  • AuthnStatement — auth method, timestamp
  • AttributeStatement — user attributes (email, roles)

<Signature/> (XML-DSig)

  • Enveloped signature (covers Assertion)
  • Verify with IdP's public cert (from metadata)
  • Check KeyInfo/X509Data

OIDC ID Tokens — OpenID Connect

Verification Checklist

  1. Decode header → verify alg is RS256 or ES256 (not HS256, not none)
  2. Fetch JWKS from jwks_uri in provider metadata (.well-known/openid-configuration)
  3. Match kid in header to key in JWKS
  4. Verify signature using matched public key
  5. Validate claims:
    • iss matches expected provider
    • aud contains your client_id
    • exp> now (with clock skew tolerance)
    • nonce matches your auth request (if used)

Standard Claims

ClaimRequiredDescription
issYesIssuer URL (HTTPS)
subYesSubject — unique per issuer
audYesAudience — your client_id(s)
expYesExpiration (Unix timestamp)
iatYesIssued at
auth_timeNo*When user authenticated (*if max_age requested)
nonceNo*Opaque value from auth request (*required if sent)
email, name, pictureNoProfile claims (scope-dependent)

Common Workflows

Debug Failed JWT Auth

  1. Paste token in JWT Decode
  2. Check exp vs now (clock skew?)
  3. Verify aud matches your client_id
  4. Check iss matches expected provider
  5. If RS256: use OIDC ID Token to auto-fetch JWKS

Migrate JWT → PASETO

  1. Generate Ed25519 keypair (PBKDF2 for key derivation if needed)
  2. Update issuer to sign v4.public
  3. Update consumers to verify with PASETO lib
  4. Run both in parallel during transition
  5. Deprecate JWT after full rollout

Generate Secure API Key

  1. Open Opaque Token Generator
  2. Generate 32-byte (256-bit) token
  3. Hash with Bcrypt cost 12 (Bcrypt Hash)
  4. Store hash in DB with prefix sk_live_
  5. Return raw token ONCE to user

Debug SAML Login Loop

  1. Capture SAMLResponse from browser (Network tab)
  2. Paste in SAML Decoder
  3. Check NotOnOrAfter hasn't passed
  4. Verify Audience matches SP entity ID
  5. Confirm NameID format matches SP expectation
  6. Verify signature with IdP cert

Add "Login with Google" (OIDC)

  1. Register app in Google Cloud Console
  2. Get client_id, client_secret, redirect_uri
  3. Redirect user to Google's auth endpoint with scope=openid email profile
  4. Receive code at redirect_uri
  5. Exchange code for tokens at token endpoint
  6. Verify ID Token with OIDC ID Token tool

Implement Token Refresh

  1. Issue short-lived access token (15-30 min)
  2. Issue long-lived refresh token (opaque, 30-90 days)
  3. Store refresh token hash in DB (Bcrypt)
  4. On 401: POST refresh_token to /token endpoint
  5. Rotate: issue new access + refresh, revoke old
  6. Detect reuse → revoke entire session (theft detection)

Security Checklist

  • Never put secrets in JWT claims — payload is public (Base64URL decode). Use opaque tokens or PASETO v4.local for confidential data.
  • Always verify signatures — decode ≠ verify. Use JWT tool (HS256) or OIDC tool (RS256/ES256 + JWKS).
  • Enforce algorithm — hardcode expected alg in verification code. Reject none and unexpected algorithms.
  • Use short expirations — access tokens ≤30 min; refresh tokens ≤90 days with rotation.
  • Validate audience — reject tokens not issued for your client_id.
  • Rotate keys — publish new JWKS, overlap validity, retire old keys after grace period.
  • HTTPS only — tokens in transit must be encrypted (TLS 1.2+).
  • Secure storage — HttpOnly Secure SameSite cookies, or memory-only for SPAs (never localStorage).

Frequently Asked Questions

JWT (RFC 7519) lets you negotiate algorithms in the header via the alg parameter. This has led to algorithm confusion attacks over the years.

PASETO (Platform-Agnostic Security Tokens) takes a different approach. It uses versioned protocols with fixed algorithms per version. For example, v4.public always uses Ed25519, and v4.local always uses XChaCha20-Poly1305. This eliminates algorithm agility vulnerabilities entirely.

PASETO also enforces key separation and has a simpler, more opinionated design. You get fewer ways to shoot yourself in the foot.

See these differences hands-on in the JWT vs PASETO Playground — feed in one payload and key, then watch both token types generated side by side with live byte-size counts and timing.

Related Tools — Explore the Full Toolchain

Serializing token payloads? Learn about Protobuf →

Password → Hashing

Password storage & salting with Bcrypt, Argon2, scrypt

Hashing → Encoding

Hex/base64 representation of hash digests

Encoding → Tokens

Base64URL in JWT

Tokens → Serialization

Protobuf for efficient token payload serialization