Producing a token to test an authorization middleware
Constructing a token with specific roles or scopes exercises access-control paths that are otherwise awkward to reach.
Builds and signs a JWT with HS256 in your browser using a secret key.
Builds and signs a JWT with HS256 in your browser using a secret key.
payload: {"sub":"123","role":"admin"}, secret: "test-secret"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjMifQ.signed-part
The signature is HMAC-SHA256 of header.payload with the secret.
The signature proves the token was produced with the secret.
Your input is sent to YAS infrastructure because the tool requires server-side processing or public network queries. Input is not stored.
curl -X POST "https://yas.sh/api/v1/tools/jwt-encode" \
-H "Content-Type: application/json" \
-d '{"payload":{"sub":"123","name":"Yas"},"secret":"your-secret"}'const res = await fetch("https://yas.sh/api/v1/tools/jwt-encode", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"payload": {
"sub": "123",
"name": "Yas"
},
"secret": "your-secret"
}),
});
const data = await res.json();import requests
r = requests.post("https://yas.sh/api/v1/tools/jwt-encode", json={"payload":{"sub":"123","name":"Yas"},"secret":"your-secret"})
data = r.json()| Field | Type | Required | Description |
|---|---|---|---|
| payload | object | Yes | JWT claims (object or JSON string) |
| secret | string | Yes | HMAC signing secret |
{ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "alg": "HS256" }Build and sign a JWT (HS256) from header + payload + secret.
400 VALIDATION_ERROR — invalid input or unsupported option.413 PAYLOAD_TOO_LARGE — input exceeds the 64 KB limit.429 RATE_LIMIT_EXCEEDED — rate limit exceeded (60 req/min).Signing builds three parts: a header naming the algorithm, a payload of claims, and a signature. Header and payload are serialized to JSON, Base64URL-encoded and joined with a dot; that exact ASCII string is then signed. For HS256 the signature is HMAC-SHA256 with a shared secret, and the Base64URL-encoded MAC is appended as the third segment.
The security of an HS256 token is exactly the security of its secret. Anyone holding it can mint tokens with any claims, which makes HMAC-based JWTs appropriate when one party both issues and verifies, and inappropriate when many services verify tokens they did not issue — that case needs an asymmetric algorithm so verifiers hold only a public key.
Constructing a token with specific roles or scopes exercises access-control paths that are otherwise awkward to reach.
Set exp deliberately in the past or the near future to confirm your verifier's leeway behaves as documented.
A signed token with known claims and a test secret makes authenticated test requests deterministic.
Tokens travel in headers on every request; seeing the encoded length makes the case for keeping payloads small.
What this tool deliberately does not do, and where it will disagree with other implementations.