FormatterHQ

JWT Encoder & Generator

Paste your claims, add a shared secret or a PEM private key, pick an algorithm and get a signed JSON Web Token. Signing runs in your browser.

Loading tool…
Ready.

How to use the JWT Encoder & Generator

  1. Type or paste your claims as a JSON object in the Payload (claims JSON) pane on the left.
  2. Enter the HMAC secret, or paste a PEM private key, in the Secret or PEM private key pane on the right.
  3. Choose the Algorithm and, if you need them, set Expires in, tick Add "iat" or fill in a Key ID.
  4. Click Sign JWT and copy the token from the Signed JWT output. The header, payload and signature are shown in different colors.

Sign tokens with this JWT encoder

This jwt encoder turns a JSON object of claims into a compact, signed JSON Web Token (JWS). You provide the payload on the left, a secret or private key on the right, and the tool builds the header, Base64URL-encodes both parts and signs them with the algorithm you choose. It is handy for testing an API locally, reproducing a bug report or creating fixtures for automated tests.

What goes into a signed JWT?

A JWT has three dot-separated parts: header.payload.signature. The header generated here is always {"alg": "…", "typ": "JWT"}, plus a kid member when you fill in the Key ID field. The payload is your claims object exactly as you typed it, with iat and exp added only if you ask for them.

The signature covers the first two parts. Anyone can read a JWT, so never put passwords or other secrets in the claims. The signature only proves that the token was not changed and was created by someone holding the key.

Example

Signing the sample claims with HS256 and the secret your-256-bit-secret produces this token:

{
  "sub": "1234567890",
  "name": "John Doe",
  "admin": true,
  "iat": 1516239022
}

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.reGQzG3OKdoIMWLDKOZ4TICJit3EW69cQE72E2CfzRE

The status line also reports "warning: secret is shorter than 256 bits", because that sample secret is only 19 bytes. RFC 7518 asks for an HMAC key at least as long as the hash output.

Options explained

  • Algorithm: HS256, HS384 and HS512 use a shared secret. RS256, RS384, RS512 and PS256 need an RSA private key. ES256, ES384 and ES512 need an EC key on P-256, P-384 or P-521. EdDSA needs an Ed25519 key.
  • Expires in (seconds): adds an exp claim that many seconds after iat, or after the current time when there is no iat. Leave it at 0 for no expiry.
  • Add "iat": sets the issued-at claim to the current Unix time, unless your payload already has one.
  • Key ID: writes a kid header so the verifier can pick the matching key from a JWKS.
  • Secret is Base64 encoded: decodes the secret to raw bytes before signing. Tick this when your server stores the secret as Base64, as many frameworks do.

Which keys are accepted?

For asymmetric algorithms, paste a PEM private key. PKCS#8 (BEGIN PRIVATE KEY), PKCS#1 (BEGIN RSA PRIVATE KEY) and SEC1 (BEGIN EC PRIVATE KEY) all work, because PKCS#1 and SEC1 keys are wrapped into PKCS#8 before import. A private JWK in JSON form is also accepted. Need a key to test with? Create one with the RSA key generator or the ECDSA and Ed25519 key generator.

Common errors and fixes

  • "Signing needs a PRIVATE KEY": you pasted a public key or a certificate. Only the private half can sign.
  • "Payload must be a JSON object": the payload must be an object, not an array or a string. Quote all keys and remove trailing commas.
  • Wrong key type: an RSA key cannot sign ES256 and an EC key cannot sign RS256. Match the algorithm to the key.
  • Token rejected by your server: check that both sides treat the secret the same way (plain text or Base64) and that exp is still in the future.

To inspect the result, paste it into the JWT decoder. To confirm the signature against a public key, use the JWT verifier.

Privacy

Tokens are signed in your browser with the open-source jose library and WebCrypto. Your claims, secrets and private keys are not uploaded. Even so, use test keys here rather than production signing keys.

Frequently asked questions

Is it safe to paste a secret or private key into an online JWT encoder?
This tool signs locally in your browser and does not send the key anywhere. Good practice is still to use development or test keys, and to rotate any production key that has been copied into places it should not be.
Why does the tool warn that my secret is shorter than 256 bits?
HS256 should use a secret of at least 32 bytes, HS384 at least 48 and HS512 at least 64. The token is still produced, but a short secret is easier to brute-force, so use a long random value in real systems.
What is the difference between RS256 and PS256?
Both use an RSA key and SHA-256. RS256 uses the older PKCS#1 v1.5 padding, while PS256 uses RSA-PSS, which has a stronger security proof. Your verifier must support the algorithm you pick.
Can I create an unsigned token with alg "none"?
No. The encoder only produces signed tokens. Unsigned tokens are a common source of authentication bypasses, and most libraries reject them by default.
How do I set a token to expire in one hour?
Enter 3600 in the Expires in field. The encoder adds an exp claim one hour after the iat value, or one hour after the current time if the payload has no iat.

Last updated September 26, 2026

Related tools

JWT Decoder Decode a JSON Web Token to inspect its header, payload claims and expiry time, and verify its signature with your key. Runs locally. JWT Verifier Verify a JWT signature with a shared secret, PEM public key, X.509 certificate or JWKS and check exp, nbf, iss and aud claims. MIME Type Lookup Find the MIME / Content-Type for a file extension or the extensions for a media type — about 150 common types. MongoDB ObjectId to Timestamp Extract the creation date from MongoDB ObjectIds and see the random and counter parts; also builds a date-range _id query. QR Code Generator Create free QR codes for URLs, text, Wi-Fi, vCards, e-mail, SMS, phone numbers, locations and events. Custom colours, PNG and SVG. QR Code Reader & Scanner Scan QR codes from an image, screenshot or your camera and see the content — links, Wi-Fi passwords, contacts — safely before opening. Regex Cheat Sheet Interactive regex cheat sheet: anchors, classes, quantifiers, groups, lookarounds, flags and Unicode, with clickable examples and a flavour table. Regex Escape Escape special characters so any text can be matched literally inside a regular expression in JavaScript, PCRE, Python or Java. Regex Explainer Break a regular expression into tokens and explain each part in plain English: groups, quantifiers, classes, anchors and lookarounds. Regex Patterns Library Copy-ready regex patterns for email, phone, URL, IP, dates, numbers, UUIDs, postal codes and passwords, each with examples and a live test box. Regex Tester Test JavaScript regular expressions live: highlight matches, inspect capture groups and named groups, try flags and preview replacements. SemVer Checker & Range Tester Validate, compare and sort semantic versions and test them against npm-style ranges like ^1.2.0, ~2.3 or >=1.0 <2.