Advertisement

JWT Token Generator

Generate JWT tokens with custom claims, expiration, and algorithm selection for testing APIs.

Header (auto-generated)

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

Payload Claims

Payload JSON

{
  "sub": "1234567890",
  "name": "John Doe",
  "iat": 1774866292
}

Signing Secret (HS256)

This secret is used to sign the token. Keep it confidential in production.

Encoded JWT Token

..
Header Payload Signature

Security Note

JWT payloads are Base64URL-encoded, not encrypted. Anyone can decode and read the payload. Never store sensitive data (passwords, credit card numbers) in JWT claims. Token signing happens entirely in your browser using the Web Crypto API.

Advertisement

Related Tools

Advertisement

Frequently Asked Questions

What is a JWT (JSON Web Token)?
A JSON Web Token (JWT) is a compact, URL-safe token format used for securely transmitting information between parties as a JSON object. It consists of three parts separated by dots: a header (algorithm and token type), a payload (claims/data), and a signature. JWTs are commonly used for authentication, authorization, and information exchange in web applications.
What are JWT claims?
Claims are statements about an entity (typically the user) and additional data. There are three types: registered claims (predefined like iss, exp, sub, aud), public claims (defined by users but should use collision-resistant names), and private claims (custom claims agreed upon between parties). Common claims include iss (issuer), exp (expiration), sub (subject), and iat (issued at).
What is HS256?
HS256 (HMAC-SHA256) is a symmetric signing algorithm that uses the same secret key for both creating and verifying the JWT signature. It combines the SHA-256 hash function with a secret key to produce a message authentication code. HS256 is the most commonly used JWT algorithm and is suitable when the same party creates and verifies tokens.
Is it safe to use JWTs for authentication?
JWTs are widely used for authentication but require careful implementation. Key security practices include: using strong signing secrets, setting short expiration times, validating all claims on the server, using HTTPS for transmission, and never storing sensitive data in the payload since it is only Base64-encoded (not encrypted). Consider using refresh tokens for long-lived sessions.
Can JWT payload data be read without the secret?
Yes! The JWT payload is only Base64URL-encoded, not encrypted. Anyone can decode and read the payload without knowing the secret key. The signature only verifies that the payload has not been tampered with, not that it is hidden. Never put sensitive information like passwords, credit card numbers, or personal secrets in JWT payloads.
What is the difference between HS256 and RS256?
HS256 is a symmetric algorithm using the same secret for signing and verification. RS256 is an asymmetric algorithm using a private key for signing and a public key for verification. RS256 is preferred when the token issuer and verifier are different parties, as the verification key can be shared publicly without compromising the signing key.

How to Use the JWT Generator

JSON Web Tokens are the de facto standard for stateless authentication in modern web applications. Our JWT generator lets you create properly formatted and signed tokens for development, testing, and learning purposes. Build tokens with custom claims and sign them with HS256 directly in your browser.

Step 1: Configure the header. The JWT header specifies the token type and signing algorithm. Our generator uses HS256 (HMAC-SHA256) by default, which is the most widely supported and commonly used algorithm. The header is automatically generated based on your selection.

Step 2: Add payload claims. Add claims to your JWT payload using the add/remove interface. Common claims include sub (subject/user ID), iss (token issuer), exp (expiration time), and iat (issued at time). You can add any custom claims needed for your application.

Step 3: Set your signing secret. Enter the secret key used to sign the token. This key must be kept confidential and should be shared only with services that need to verify the token. Use a strong, random string of at least 32 characters for production use.

Step 4: Generate and copy. The encoded JWT token is generated in real-time as you modify claims. Copy the complete token or individual parts (header, payload, signature) for use in your application, API testing tool, or development environment.

Understanding JWT Structure

A JWT consists of three Base64URL-encoded parts separated by dots. The header contains metadata about the token, specifically the signing algorithm (alg) and token type (typ). The payload contains claims, which are statements about the user and additional metadata. The signature is computed by hashing the encoded header and payload with the secret key.

The signature ensures the token has not been tampered with. When a server receives a JWT, it recomputes the signature using its copy of the secret key and compares it to the signature in the token. If they match, the token is authentic and the claims can be trusted. If they do not match, the token has been modified and should be rejected.

It is critical to understand that JWTs are not encrypted by default. The payload is merely Base64URL-encoded, which is a reversible encoding. Anyone who intercepts a JWT can read its contents. If you need to transmit sensitive data, use JWE (JSON Web Encryption) or encrypt the entire JWT as an additional layer.

JWT Best Practices for Developers

Set short expiration times. Tokens should expire quickly, typically between 15 minutes and 1 hour for access tokens. Use refresh tokens (stored securely) to issue new access tokens without requiring the user to log in again. This limits the damage window if a token is compromised.

Validate all standard claims. Always validate exp (expiration), iss (issuer), and aud (audience) claims on the server. Do not trust the token blindly just because the signature is valid. Check that the token was issued by your service, intended for your service, and has not expired.

Use strong secrets. For HS256, use a secret key of at least 256 bits (32 bytes). Generate it using a cryptographically secure random number generator. Never use simple strings like "secret" or "password" as your signing key. Rotate secrets periodically and have a plan for handling key rotation.

Why Use Our JWT Generator?

Real-time token generation. See your JWT update instantly as you add or modify claims. The three-part structure is color-coded for easy identification of the header, payload, and signature sections.

Complete privacy. Your secret key and token claims never leave your browser. The HS256 signing is performed entirely client-side using the Web Crypto API. This is critical for development workflows where tokens may contain production-like data.

Educational tool. Understanding JWT structure is essential for web developers. Our generator shows the decoded header and payload alongside the encoded token, making it easy to understand how each part contributes to the final token.

Advertisement