JWT Generator
Generate JSON Web Tokens instantly with our free online JWT generator. Create signed JWT tokens with custom headers and payloads for testing authentication flows, prototyping API security, or learning JWT structure. Whether you are a backend developer implementing JWT-based authentication, a frontend developer testing token handling, a QA engineer simulating authenticated requests, or a student learning about token-based security, this tool supports HS256, HS384, HS512, RS256, and ES256 algorithms with full control over all token claims, and secret signing.
What Is
JWT Generator is a development and testing tool that creates properly signed JSON Web Tokens (RFC 7519) for use in development, testing, and educational contexts. Generating valid JWTs requires understanding three components: the header (specifying signing algorithm and token type), the payload (containing claims like expiration time, subject, issuer, and custom data), and the signature (computed by hashing the header and payload with a signing key). Our generator lets you customize all three parts through intuitive forms: select from common algorithms (HS256, HS384, HS512 using HMAC with shared secrets; RS256 using RSA with public/private key pairs; ES256 using ECDSA with elliptic curve keys), set standard claims (expiration time, not before time, issued at, subject, issuer, audience, JWT ID), add custom claims for your application needs, provide the signing secret or key, and generate a complete, validly signed JWT copyable for use in API testing. This tool is invaluable for testing authentication middleware, simulating authenticated API requests in Postman or curl, and learning how JWT signature verification works.
How to Use
- Select your signing algorithm from the dropdown: HS256/HMAC-SHA256 (simplest, uses shared secret), RS256/RSA-SHA256 (uses RSA key pair), or ES256/ECDSA-SHA256 (uses elliptic curve keys)
- Enter your claims in the payload section: set standard claims (expiration time as Unix timestamp or relative like 1h for one hour), subject, issuer, audience, and any custom key-value pairs
- For HMAC algorithms, paste or type your shared secret string; for RSA/ECDSA algorithms, paste your private key in PEM format for signing
- Click the Generate JWT button to create the token, which appears in the output field as a complete three-part JWT string (header.payload.signature)
- Copy the generated JWT and use it in your Authorization header (Bearer token) for testing authenticated API endpoints in your application
Examples
Input: Payload: {sub:1,role:admin}, Secret: mykey, Alg: HS256
Process: Base64(Header) → Base64(Payload) → HMAC-SHA256 signature
Result: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsInJvbGUiOiJhZG1pbiJ9.xxx
Input: With exp: now + 3600s
Process: Add iat (issued at) + exp (1hr later) → Sign
Result: Token with 1-hour expiration, valid until [timestamp]
Related Searches
People also search for: jwt generator, generate jwt, create jwt token, jwt token maker, jwt sign, jwt builder.
jwt generatorgenerate jwtcreate jwt tokenjwt token makerjwt signjwt builderjson web token generatorjwt test token
Frequently Asked Questions
When should I use HMAC vs RSA for JWT signing?
Use HMAC (HS256, HS384, HS512) when the same application both creates and verifies tokens — typical for monolithic applications where your authentication server and API servers are controlled by the same team. HMAC uses a shared secret meaning both signing and verification use the same key. This is simpler to implement but the secret must be securely shared between all components that verify tokens. Use RSA (RS256) or ECDSA (ES256) when you want asymmetric signing: the authentication server signs tokens with its private key, and any service with the public key can verify tokens. This is the recommended approach for microservices architectures where multiple services need to verify tokens but should not be able to sign new tokens. Use RSA/ECDSA when integrating with external identity providers (Auth0, Okta) who publish public keys for token verification. Our tool supports both approaches.
How do I choose an appropriate expiration time for my JWT?
JWT expiration (exp claim) is a security critical decision balancing security and user experience. Short-lived tokens (15-60 minutes) better security due to shorter attack window if compromised but inconvenience users with frequent re-authentication. Long-lived tokens (24 hours or more) better user experience but risk from compromised tokens remains active longer. Best practices: access tokens should be short-lived (15 minutes to 1 hour); use refresh tokens (long-lived, stored securely, like 7-30 days) to obtain new access tokens without user interaction; set expiration for sensitive operations (account deletion, payment processing) to under 15 minutes; always check exp claim in your token validation middleware; and use refresh token rotation to mitigate token theft. Our generator supports relative time expressions (1h for one hour, 7d for seven days) for easy expiration time generation.
What are common claims I should include in my JWT?
Essential claims include: exp (expiration time) — required for security, prevents infinite-lived tokens; iat (issued at) — useful for determining token age and implementing expiration policies; sub (subject) — identifies the token owner, typically the user ID from your database; iss (issuer) — identifies which server issued the token, useful in multi-server setups; aud (audience) — identifies which services should accept this token, prevents token reuse across services; and jti (JWT ID) — unique identifier for the token, enables token revocation lists and replay attack prevention. Common custom claims include: roles/permissions for authorization decisions, tenant ID for multi-tenant applications, and session ID linking the token to a server-side session for forced logout. Avoid storing sensitive data (passwords, PII) in JWTs even though they are signed, because signed data is easily decoded by anyone possessing the token.
How can I test my application's JWT validation using generated tokens?
Use our generator to create test tokens for various scenarios: valid token with correct claims and signature — your application should accept this; expired token (set exp to a past timestamp) — your application should reject with 401 Unauthorized; wrong algorithm (generate with HS256 but your app expects RS256) — your application should reject; tampered payload (decode a valid token, modify a claim, re-encode without re-signing) — your application should reject due to signature mismatch; missing required claims (omit exp or sub) — your application should reject if these are required; wrong audience (set aud to a different service) — your application should reject; and token signed with wrong secret — your application should reject. This systematic testing ensures your JWT validation middleware correctly handles all edge cases and security scenarios.
Is it safe to generate JWTs using an online tool for production use?
Our tool is designed for development and testing purposes only. For production JWT generation, always use established libraries in your backend code (jsonwebtoken for Node.js, PyJWT for Python, java-jwt for Go jwt for Go, etc.) running on your secure servers. The security concern with online tools is that secrets entered in the browser could potentially be intercepted or logged. Our tool processes everything client-side in JavaScript without sending data to any server, but for production secrets you should never enter them in any web-based tool. Use our generator for: creating test tokens for development environments, learning JWT structure and claims, prototyping authentication flows, and generating example tokens for documentation. For production, generate tokens in your backend code where secrets are stored in environment variables or secret management systems.