About jwt generator
A JSON Web Token (JWT) is a compact, signed string that carries claims such as a user ID and an expiry time. This tool creates one from your payload and secret, for testing.
The three parts
- Header: the algorithm used to sign, such as HS256.
- Payload: the claims, for example sub, iat (issued at) and exp (expiry).
- Signature: proves the token was not changed, made from the header, payload and secret.
Important to know
The payload is only encoded, not encrypted, so anyone holding the token can read it. Never put passwords or sensitive personal data in it.
Testing only
Use a throwaway secret for experiments. Real signing secrets belong on your server.
A worked example
A payload of {"sub": "1234", "name": "Asha", "iat": 1700000000, "exp": 1700003600} signed with HS256 gives a token valid for one hour from the issue time. The exp claim is the time the token stops being accepted.
Choosing a secret
- For HS256, use a random secret of at least 32 bytes.
- Keep it on the server and never in front-end code.
- Rotate secrets periodically, and expect all old tokens to become invalid.
