Guide

How to Decode a JWT and Read Its Claims

A JSON Web Token is three Base64URL strings joined by dots. Reading the first two takes no key, but trusting them does.

Updated

Try it now: JWT Decoder. It runs in your browser, with no signup.

The three parts

A token looks like header.payload.signature. The header and payload are JSON encoded with Base64URL, which is Base64 with - instead of + and _ instead of /, and usually without = padding. The signature is binary data used for verification.

  • Header: the signing algorithm (alg) and token type (typ), and sometimes a key ID (kid).
  • Payload: the claims, such as the issuer, subject and expiry.
  • Signature: proves the first two parts were not changed, if you check it.

Decode in JavaScript

function decodePart(part) {
  const b64 = part.replace(/-/g, "+").replace(/_/g, "/");
  const bytes = Uint8Array.from(atob(b64), c => c.charCodeAt(0));
  return JSON.parse(new TextDecoder().decode(bytes));   // handles UTF-8
}
const [h, p] = token.split(".");
console.log(decodePart(h), decodePart(p));

Decode in Python

import base64, json

def decode_part(part):
    padded = part + "=" * (-len(part) % 4)
    return json.loads(base64.urlsafe_b64decode(padded))

header, payload, _ = token.split(".")
print(decode_part(header), decode_part(payload))

Claims worth reading first

If a request fails with 401, check exp first. A token that expired seconds ago is the most common cause, and clock skew between servers can make it look expired early.

  • exp: expiry time, in seconds since 1 January 1970 UTC. Convert it with a timestamp tool.
  • iat: when the token was issued. nbf: not valid before this time.
  • iss: who issued it. aud: who it is meant for. sub: the subject, often a user ID.
  • jti: a unique token ID, useful for revocation lists.

Decoding is not verifying

Anyone can decode a token, and anyone can create one with any claims. Only a signature check with the correct key shows it is genuine. Verify on the server with a maintained library, require the algorithm you expect, reject the none algorithm, and check exp, iss and aud. Never make an authorization decision from a payload you only decoded.

Handle tokens like passwords

A valid access token works as a credential until it expires. Avoid pasting production tokens into tools you do not control. The JWT Decoder runs in your browser, but if a token has been exposed anywhere, revoke it and issue a new one.

Frequently asked questions

Can I read a JWT without the secret?

Yes. The header and payload are only encoded, not encrypted. The secret or public key is needed only to verify the signature.

Is a JWT encrypted?

A standard signed JWT is not. Anything in the payload is readable by whoever holds the token, so do not put secrets in it.

Why does my token fail to decode?

It may be cut off, contain spaces or a Bearer prefix, or use a different format such as an encrypted token with five parts.

Tools used in this guide

onlinedevelopertool.com is a collection of 54 free, browser-based utilities for the small jobs that interrupt real work: formatting a JSON response, decoding a token, converting a timestamp, generating a UUID or checking a hash. Each tool has its own page with a short explanation, a worked example and answers to common questions, so you can use it and learn what it does at the same time.

There is no account to create and nothing to install. Tools run in your browser, so the text you paste is processed on your own device. The one exception is the Website Status Checker, which sends a request from your browser to the address you enter.

Three steps: paste your input, click the tool, copy the result, all inside your browser
Popular developer utilities: JWT decoder, UUID generator, Base64 decoder, SHA-256 hash, regex tester and timestamp converter

What you can do here

  • JSON Tools

    Format, validate, beautify and minify JSON, generate C#, TypeScript, Java, Python, Go, PHP and Kotlin models from it, or convert between JSON, YAML and CSV.

  • Encoders & Decoders

    URL, Base64 and HTML encoding and decoding, plus a JWT decoder for reading token claims.

  • Generators & Hashes

    Generate UUIDs and JWTs, validate UUIDs, and create MD5, SHA-256 and SHA-512 hashes.

  • Web Tools

    Timestamps, color codes, query strings and cron expressions - the small things web work keeps throwing at you.

  • Text & Data

    Format XML and YAML, count text, change case, make slugs, test regex, diff two texts and convert number bases.

  • Website Checking

    Check whether a website or URL is reachable from your browser.

Quick developer reference

  • JSON

    Keys and strings must use double quotes, and trailing commas and comments are not allowed. Those are the three most common reasons a payload fails to parse.

    Validate JSON
  • JWT

    A JSON Web Token is three Base64URL parts joined by dots: header, payload and signature. Decoding shows the claims but does not prove the token is genuine; only signature verification does.

    Decode a JWT
  • Base64

    Base64 is an encoding, not encryption. Anyone can reverse it, and it makes data roughly one third larger, so never use it to hide secrets.

    Decode Base64
  • UUID

    A version 4 UUID is made of random bits and written as 8-4-4-4-12 hexadecimal characters. Collisions are astronomically unlikely, which is why they work well as identifiers.

    Generate a UUID
  • Timestamps

    A Unix timestamp counts time since 1 January 1970 UTC. Ten digits usually means seconds and thirteen digits usually means milliseconds.

    Convert a timestamp
  • Hashes

    MD5 is fine for quick checksums but is not safe for security. Prefer SHA-256 or SHA-512, and remember that hashing is one-way and is not encryption.

    Create a SHA-256 hash

Missing a tool you need? Visit the contact page and tell us what you reach for most often. You can also browse every tool or read the About page to see how the site is built and what it does with your data.