{jsonbody.com}

JWT Generator

Generate signed JWT test tokens with HS256, HS384 or HS512. Edit the payload, set iat and exp in one click, and copy the token. Signing runs in your browser.

Create test JWTs for development

Testing an authenticated API means you need tokens in specific states: valid, expired, or carrying a particular role. Rather than logging in repeatedly or changing server code, write the payload you want and this tool signs it. You can then call your endpoint with the token and watch how your auth middleware reacts.

The token updates as you edit. Signing uses the browser's Web Crypto API, so your secret stays on your device.

How to generate a token

  • Choose HS256, HS384 or HS512. This must match what your API expects.
  • Keep the random secret, or enter the one from your test environment.
  • Edit the JSON payload and add any claims your application reads, such as role.
  • Use the expiry buttons to set iat and exp, then copy the signed token.

Example: testing an expired token

Press Already expired to set exp one minute in the past. A correct API should reject the token with a 401 status. If your endpoint accepts it, your middleware is not checking expiry.

Sending the token to an API
curl https://api.example.com/v1/me \
  -H 'Authorization: Bearer YOUR_GENERATED_TOKEN'

# Good token       -> 200 OK
# Expired token    -> 401 Unauthorized
# Wrong secret     -> 401 Unauthorized

Test cases worth running

A few tokens can reveal most authentication bugs. Try each of these against a development server:

  • A valid token, as a baseline check.
  • An expired token, and one signed with a different secret.
  • A token with a lower role than the endpoint needs. This should return 403.
  • A token with a missing or incorrect aud or iss, if your API checks them.

Keep secrets out of web tools

These tokens are for testing. Although nothing leaves your browser here, a real production signing secret should never be pasted into any website, because anyone holding it can forge tokens for any user. HMAC secrets should be long and random too. RFC 7518 asks for at least as many bytes as the hash output: 32 for HS256, 48 for HS384 and 64 for HS512. The page warns you if yours is shorter.

Frequently Asked Questions

Can I generate RS256 tokens here?

Not currently. This tool signs with shared secrets using the HS family. RS256 needs a private key, which is best handled in your own code or with a command-line tool.

Why does my server reject the token?

Usually the secret or algorithm does not match. Check that your server does not Base64-decode its secret first, and that the required iss and aud claims are present.

What unit does exp use?

Seconds since 1970, not milliseconds. A value with 13 digits is a common mistake that creates a token lasting for thousands of years.

How can I check the token I made?

Paste it into our JWT Decoder and enter the same secret to confirm the signature and read the claims.