WebTools

307 Useful Tools & Utilities to make life easier.

JWT Encoder / Decoder

Easily decode, verify, and encode JSON Web Tokens (JWT) directly from your browser.

Encoded Token
Verify Signature
Used to recalculate and verify the hash.
Decoded Data Status

HEADER: ALGORITHM & TOKEN TYPE

PAYLOAD: DATA

The Ultimate JWT Encoder and Decoder

JSON Web Tokens (JWT) have become the industry standard for securely transmitting information between parties as a JSON object. Because this information is digitally signed, it can be verified and trusted. Whether you are developing authentication flows, debugging API endpoints, or working with microservices, understanding and manipulating JWTs is a crucial skill for modern web developers. Our JWT Encoder and Decoder tool provides a seamless, intuitive interface for interacting with your tokens directly in the browser.

The technical architecture of this tool is designed for maximum security and speed. It is built using Alpine.js, a lightweight JavaScript framework that enables instantaneous reactive data binding between the input fields and the token outputs. All cryptographic operations are handled entirely on the client-side using the widely trusted CryptoJS library. This means that when you paste a token, modify the payload, or enter a secret key, the computations (such as Base64Url encoding/decoding and HMAC hashing) happen locally in your web browser. Absolutely no sensitive data or secret keys are transmitted to a backend server, ensuring your authentication tokens remain completely private.

How the Architecture Works

A standard JWT is composed of three distinct parts separated by dots (.):

  • Header: Contains metadata about the token, primarily the cryptographic algorithm used (e.g., HS256) and the token type (JWT).
  • Payload: Contains the claims, which are statements about an entity (typically, the user) and additional data like expiration times (exp) or issued-at timestamps (iat).
  • Signature: Created by taking the encoded header, the encoded payload, a secret key, and the algorithm specified in the header, and cryptographically signing them.

Our tool natively supports the most common symmetric HMAC algorithms: HS256 (HMAC using SHA-256), HS384, and HS512. When you paste an existing token, the tool splits the string, decodes the Base64Url strings back into JSON formatted Header and Payload, and then recalculates the signature using your provided secret to display a "Signature Valid" or "Signature Invalid" status.

Practical Worked Example

Let's look at a concrete example of how to use the encoder to generate a token from scratch.

Step 1: Define the Header

{
  "alg": "HS256",
  "typ": "JWT"
}

Step 2: Define the Payload

{
  "sub": "user_12345",
  "name": "Jane Doe",
  "role": "admin",
  "iat": 1704067200
}

Step 3: Provide a Secret

Let's assume our symmetric secret key is my-secure-256-bit-secret.

Output: The Encoded Token

As you type, the tool reactively processes the JSON and secret, generating the Base64Url-encoded segments and calculating the HMAC signature. The resulting encoded JWT will look like this:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzEyMzQ1IiwibmFtZSI6IkphbmUgRG9lIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNzA0MDY3MjAwfQ.u1nZ7qK8K4vj3lB0zV2bK_8M2oH4sU0eF5jT4qY2a0c

(Note: The signature portion is an illustrative example of a Base64Url encoded HMAC hash.)

Frequently Asked Questions

Is my secret key safe when using this tool?
Yes, absolutely. The entire encoding, decoding, and signature verification process occurs locally in your browser using client-side JavaScript. Your tokens, payloads, and most importantly, your secret keys, are never sent over the network or logged on any server.
Why does my token say "Signature Invalid"?
A "Signature Invalid" warning means that the recalculation of the signature using the decoded Header, Payload, and your provided Secret did not match the Signature segment of the provided token. This usually means the token was modified, corrupted, or you are using the wrong secret key to verify it.
Can I decode a token if I don't know the secret?
Yes. The Header and Payload sections of a JSON Web Token are merely Base64Url encoded, not encrypted. The tool can decode and display the JSON contents of any JWT without needing the secret. The secret is only required for verifying the authenticity (the Signature) of the token or generating a valid signed token.
What algorithms are supported by this encoder?
This tool supports symmetric hashing algorithms, specifically HS256 (HMAC SHA-256), HS384 (HMAC SHA-384), and HS512 (HMAC SHA-512). These are the most commonly used algorithms for JWTs when a shared secret is used between the issuer and the verifier.
What happens if my JSON payload is invalid?
If you enter improperly formatted JSON in the Header or Payload text areas (e.g., missing quotes or trailing commas), the tool will catch the parsing error and safely stop generating the token, typically resulting in an invalid status until the JSON syntax is corrected.

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us