Skip to content
toolbelt
Back to Guides

Signing a JWT and Understanding What You Prove

By ·

Updated

Testing auth code needs a valid token. Generating one by hand is error-prone, and getting the signature wrong teaches you nothing about why.

What is this tool?

Signing a JWT means hashing the header and payload with a secret and appending the result. The signature proves the token was produced by someone holding that secret. It does not hide the contents.

How it works

The header names the algorithm, the payload holds your claims, and together they form the signing input. I hash that with HMAC using your secret through the browser crypto API and append the result as the third segment.

Example

Header:  {"alg":"HS256","typ":"JWT"}
Payload: {"sub":"123","name":"Ada"}

Result:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjMiLCJuYW1lIjoiQWRhIn0.<signature>

When to use it

Producing a token for a local dev server. Checking that your verification code rejects a tampered payload. Reproducing the exact token from a failing test so you can compare it byte for byte.

Optimization Tips

Never paste a production secret into a web tool you did not read the code of. HS256 uses one secret for both signing and verifying, so the secret is the whole security model. Where only public verification matters, use RS256 and keep the private key off the client entirely.

Frequently Asked Questions

Can I use RS256 here?
No. That needs a private key, and a browser tool holding one is a bad idea.
Does signing encrypt the payload?
No. Anyone can read it. Only the signature is protected.
Should I set exp?
Yes. Almost every verifier requires it, and a token without one never expires.
Why does my server reject the signature?
Usually a mismatched secret, a different algorithm, or extra padding on the signature segment.

Ready to try it out?

Put this knowledge into practice with our free tool.

Go to Tool

Related tools