JWT Encoder / Decoder

The encoded token will appear here...

How to use the JWT Encoder / Decoder

This tool creates (encodes) and reads (decodes) JSON Web Tokens signed with HMAC (HS256, HS384 or HS512). It runs entirely in your browser, so your tokens and secrets are not sent to any server.

Step by step

  1. To create a token, open the Encode tab and edit the Header and Payload JSON.
  2. Pick an Algorithm (HS256, HS384 or HS512), type your Secret and click Generate JWT. Copy the result from the Encoded Token box.
  3. To read a token, open the Decode tab and paste the token (it looks like header.payload.signature).
  4. Optionally enter the secret to verify the signature, then click Decode JWT.
  5. Read the decoded Header and Payload. A badge tells you whether the signature is valid, invalid or not verified, and if the payload has an exp claim it also shows when the token expires or expired.
  6. Use Clear to reset the form and start over.

Tips

  • The alg value in the header is always replaced by the algorithm selected in the dropdown, so the header and the signature always match.
  • Only HMAC algorithms (HS256, HS384, HS512) are supported. Tokens signed with other algorithms, such as RS256, cannot be verified here.
  • A JWT is encoded, not encrypted. Anyone who has the token can read its payload, so never put passwords or other secrets inside it.
  • Avoid pasting real production secrets into any online tool, even one that works in your browser.

Good to know

A JSON Web Token has three Base64URL-encoded parts: a header, a payload of claims and a signature. The first two are readable by anyone, so a JWT is signed, not hidden. The signature proves that the header and payload were not changed after they were issued by someone who knows the key.

The signing algorithms HS256, HS384 and HS512 use HMAC with SHA-256, SHA-384 and SHA-512 and one shared secret. The time claims exp, nbf and iat are Unix timestamps in seconds.

When to use it

  • Debugging a login problem by reading the claims in a token.
  • Checking whether a token has expired and when.
  • Creating a test token with chosen claims for an API you are building.

Example: Claims in a decoded payload

Input

eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjMiLCJleHAiOjE3MDAwMDM2MDB9.<signature>

Result

Header:  { "alg": "HS256" }
Payload: { "sub": "123", "exp": 1700003600 }
exp 1700003600 = 2023-11-14 23:13:20 UTC

Common mistakes

  • Assuming a decoded token is a valid one. Only signature verification with the correct key proves it.
  • Putting sensitive data in the payload. Anyone holding the token can read it.
  • Using a short or guessable secret for HS256. Use at least 32 random bytes.
  • Forgetting that exp is in seconds. A value in milliseconds looks like a date far in the future.

Frequently asked questions

Is it safe to paste my JWT into this tool?
Decoding, signing and verifying all happen in your browser with the built-in Web Crypto API, and the token and secret are not sent to a server. You can confirm this by opening your browser developer tools on the Network tab while you decode a token. Even so, it is good practice to use test tokens and test secrets instead of production ones on any website.
Do I need the secret to decode a JWT?
No. The header and payload of a JWT are only Base64URL-encoded, not encrypted, so they can be read without any secret. The secret is needed only to verify the signature, and to sign a new token on the Encode tab.
What are the three parts of a JWT?
A JWT is made of a header, a payload and a signature, joined by two dots (header.payload.signature). The header says which algorithm was used, the payload carries the claims such as the subject or the expiry time, and the signature lets the receiver check that the first two parts were not changed.
Why does it show "Signature invalid"?
The most common reasons are a wrong secret, a token that was modified after it was signed, or an algorithm that this tool cannot verify. Only HS256, HS384 and HS512 are supported here, so a token signed with RS256 or ES256 is reported as invalid. The secret is used exactly as you type it, as plain text, so a secret that is stored Base64-encoded will not match unless you enter the decoded value.
Can I read a token signed with RS256 or ES256?
Yes, you can read its header and payload, because decoding does not depend on the algorithm. What this tool cannot do is check the signature of those tokens, since it only supports the HMAC algorithms (HS256, HS384, HS512).
How do I know if a token has expired?
If the payload has an exp claim (a Unix timestamp in seconds), the tool shows the date and whether the token has expired, by comparing it with the clock on your device. A token without an exp claim shows no expiry information. The tool reads only exp; it does not check other time claims such as nbf.
What is the difference between HS256, HS384 and HS512?
All three use HMAC with the same shared secret and differ only in the hash size: SHA-256, SHA-384 and SHA-512. HS256 is the most widely used. Because the same secret both signs and verifies, anyone who has the secret can create valid tokens, so keep it private.
Why do I get an error that the JWT must have 3 parts?
The input must be exactly header.payload.signature with two dots. Paste only the token itself, without a prefix such as Bearer, and without extra characters that were copied by accident.

Related searches: decode jwt token online · verify jwt signature hs256 online · jwt debugger online free · create jwt token online

Tìm kiếm liên quan: công cụ giải mã jwt token online · kiểm tra chữ ký jwt hs256 · tạo jwt token online · xem header và payload của jwt