Appearance

JWT Decoder / Generator

/jwt-decoder/

Related tools

Comments

0/500

About this tool

Why use a JWT decoder to look inside a token

A JWT (JSON Web Token) is a signed token that carries, as JSON, who a logged-in user is, what they may do and how long the token is valid. It was standardized as RFC 7519 in 2015 and is now widely used for OAuth and OpenID Connect ID tokens and for authorization headers (Authorization: Bearer) between mobile apps and API servers. Its advantage is that a server can identify the user from the token alone, without storing a session.

Read moreShow less

During development you often need to find out why a 401 error occurs, whether a permission claim made it into the token, or when the token expires. Paste a token into this tool and it decodes the header and payload into readable JSON, converts exp, iat and nbf into this device's local time, and, given a secret, checks whether the HMAC signature matches. Generate mode lets you create test tokens yourself.

The header.payload.signature structure and how JWT signing works

A JWT has three parts separated by dots. The header holds the signing algorithm, as in {"alg":"HS256","typ":"JWT"}, and the payload holds claims such as sub (subject), iss (issuer), aud (audience), exp (expiry), nbf (not before), iat (issued at) and jti (token ID). Both parts are JSON encoded with base64url, and since JSON almost always starts with {", the encoding begins with eyJ. That is why tokens start with eyJ.

The third part, the signature, is an HMAC computed with the secret over the entire 'header.payload' string and written in base64url again. This tool computes the HMAC with the browser's WebCrypto (crypto.subtle) and shows Signature verified when it equals the token's signature. Signature length follows the hash length: HS256 is 32 bytes, or 43 characters, HS384 is 48 bytes, or 64 characters, and HS512 is 64 bytes, or 86 characters. Signing the example payload {"sub":"1234567890","name":"홍길동","admin":true} with the secret my-secret using HS256 yields a 151-character token, and changing a single character of the secret produces a completely different signature, shown as Invalid signature.

exp, iat and nbf are seconds elapsed since 00:00 UTC on January 1, 1970. The tool converts these three numeric claims into dates and times, and compares exp with this device's current time (refreshed every 30 seconds) to show expired or valid. For example, an exp of 1700000000 is 22:13:20 UTC on November 14, 2023, so it shows as expired today.

Using the JWT decoder and generator in development

Frontend developers can paste the token from a login response to confirm that the user ID and permission claims arrived as expected and that the expiry is not too short. Backend developers can enter the test server's secret to check the signature and tell whether a server-side verification failure is a signature problem or a claim problem such as expiry or aud.

In Generate mode, choose HS256, HS384 or HS512, enter payload JSON and a secret, and a token is created immediately. To test API behavior with an expired token or one with different permissions, change only exp or role and make several. The header contains only alg and typ; other header values such as kid cannot be added. Copy copies the payload JSON in Decode mode and the generated token in Generate mode.

Decoding a JWT is not verifying it

The payload is not encrypted, only written in base64url, so anyone holding the token can read all of it without the secret. Passwords, national ID numbers and internal keys should never go into a payload in the first place. Being able to read a token also does not mean it can be trusted. A server must verify the signature and check exp, nbf, iss and aud before accepting a token. Library vulnerabilities that accepted forged tokens whose header alg was changed to none have actually been reported, so servers should pin the algorithms they allow.

Signature checking here supports only HS256, HS384 and HS512. Public-key signatures such as RS256 or ES256 are decoded, but the tool notes that their signatures are not verified. The secret is used as the UTF-8 bytes of the characters you type, so results can differ if your server decodes a Base64-written key before use. RFC 7518 requires HS256 keys at least as long as the hash (256 bits), so short keys like my-secret belong in tests only.

Tokens and secrets are processed only in this browser; they are never sent to a server and are not stored in this browser either. The only things kept for next time are the mode you chose, Decode or Generate, and the algorithm. Even so, it is a safe habit not to paste production secrets or live tokens into any web tool, since they can leak through screen sharing or browser extensions. The expiry indicator relies on this device's clock, so a wrong device time gives a wrong result.

FAQ

Does decoding a JWT tell me whether it is genuine?

No. Decoding only unpacks base64url, which anyone can do, and forged tokens decode just the same. Authenticity can only be established by verifying the signature with the secret or public key. For HS256, HS384 and HS512 tokens, this tool shows whether the signature matches once you enter the secret.

Is my token sent to a server?

No. Decoding and signature computation both happen on this device using the browser's WebCrypto. Even so, it is safer not to put production secrets or live tokens into any web tool.

Can it verify RS256 tokens?

The header and payload are decoded, but the signature is not checked. This tool verifies only HMAC signatures computed with a single secret (HS256, HS384, HS512). RS256 must be verified with the issuer's public key.

Why does my JWT show as expired?

exp is a Unix time in seconds, and the token is marked expired if that time is earlier than this device's current time. A device clock that is off can make it look different from reality. Access tokens are usually issued for minutes to hours, so expiry may be perfectly normal.

Why do I get Invalid signature with the correct secret?

Servers often store the secret written in Base64 and sign with the decoded bytes, while this tool uses the characters you type as the key. Also check for spaces or line breaks around the key, and whether the header alg matches the server configuration.

Can I put personal data in a JWT payload?

As a rule, no. The payload is not encrypted and anyone with the token can read it. Keep it to the minimum values that are harmless if exposed, such as a user ID.