Online JWT encoder

Issuing a JWT Base64URL-encodes header and payload, joins them with a dot as signing input, then writes a third signature segment per header alg. This page supports HS256 through HS512 with a symmetric HMAC secret and RS, PS, and ES families with a PKCS#8 PEM private key (BEGIN PRIVATE KEY). Use typ JWT; write exp and iat as Unix seconds (about ten digits), not milliseconds. Output is one compact token string with colorized segments to copy. To verify, use the

How header JSON, payload claims, and signing key material become a compact three-part JWT

Issuing a JSON Web Token begins with two JSON objects you control. The header states typ JWT and an alg that names the signing primitive for the third segment. The payload holds registered and private claims such as sub, exp, and iat. Each object is serialized to compact UTF-8 JSON without insignificant whitespace, then each byte string is spelled in Base64URL, the URL-safe alphabet described on Base64 where plus becomes minus, slash becomes underscore, and padding equals signs are usually dropped. The compact token concatenates those two spellings with a single dot between them before any cryptographic step runs.

Signing does not encrypt the middle segment. Anyone who receives the finished string can Base64URL-decode the payload and read claim values in plain JSON. What signing adds is integrity: the third segment proves that whoever held the signing secret or private key approved that exact header and payload pair at issuance time. The signing input defined in JOSE is always the UTF-8 bytes of headerBase64URL, one dot, and payloadBase64URL exactly as they will appear in the first two segments of the output. Hash-then-sign or HMAC families consume that string; they never sign pretty-printed JSON or raw claim objects directly.

Symmetric HS256, HS384, and HS512 apply HMAC with a shared secret both issuer and verifier must guard. Asymmetric RS256 through RS512 sign with RSA PKCS#1 using a private key; PS256 through PS512 use RSA-PSS; ES256 through ES512 use ECDSA on named curves with a private key whose public half appears in SPKI PEM on RSA cipher. Pick alg before you paste key material so the header matches the math. After you emit the compact string, confirm structure and signature on JWT debugger. NumericDate claims such as exp and iat must be whole seconds since the Unix epoch, which you can line up on timestamp.

How Base64URL spelling, the dot-separated signing input, alg families, and claims fit issuance

Why the JOSE signing input always uses Base64URL segments joined by a dot before any signature bytes

  1. The input string is header segment text, ASCII dot, payload segment text. It must match the first two segments of the token byte for byte.
  2. Re-encoding the same JSON with different key order or spacing changes Base64URL output and therefore changes the signature even when claims mean the same thing.
  3. Libraries compute the third segment from that dotted string only. Pretty JSON in an editor is a drafting view, not the wire form that HMAC or RSA consumes.

Why the header alg field must name the same algorithm your signing key is built to use at issue time

  1. typ JWT tells parsers the object is a JSON Web Token. alg tells verifiers which primitive validates the third segment.
  2. HS family means HMAC with SHA-256, SHA-384, or SHA-512 and a shared secret string or byte key both sides must protect.
  3. RS and PS mean RSA with PKCS#1 or PSS padding and a private PEM at issuance. ES means ECDSA on a named curve. Mismatch between alg and key type yields tokens nobody can verify.

Why exp and iat claims in the payload should be NumericDate seconds when you set session lifetime

  1. exp is seconds after the Unix epoch when verifiers should stop accepting the token unless local policy overrides expiry.
  2. iat records issuance instant in the same second units. Optional nbf forbids use before a start second with the same NumericDate shape.
  3. Wall clocks in milliseconds pasted into exp look decades in the future when parsers treat them as seconds. Convert civil time on timestamp before you embed exp or nbf.

Why HS256 shared secrets and RS PS ES private PEM keys are never interchangeable signing inputs

  1. HS256, HS384, and HS512 need the symmetric secret bytes the verifier will later use for HMAC comparison, not a public certificate.
  2. RS256 through ES512 need a PKCS#8 or traditional PEM private key for signing. Verifiers hold only the SPKI public PEM, never the private half.
  3. Choosing alg first routes you to the correct key field and keeps the emitted header honest. Compare HS versus RS tradeoffs in the FAQ before you standardize on one family.

Where issuance looks finished but verifiers or expiry checks still fail

A freshly signed token whose third segment never validates on the API that should trust the issuer

The compact string can look well formed while verification fails. HS family tokens require the same shared secret at sign and verify time; a staging secret on the encoder and production secret on the API causes silent mismatch. RS, PS, and ES tokens require the public PEM that pairs with the private key used here, not an old rotation or a certificate with the wrong SPKI extract. After signing, paste the output into JWT debugger with the verify-side key to catch key drift before deployment.

An exp claim set from a thirteen-digit millisecond clock that makes sessions appear immortal

RFC 7519 NumericDate uses seconds, not milliseconds. Embedding a JavaScript Date.now value without scaling tells parsers the token stays valid for an absurd horizon. Set iat and exp using second counts you can read beside civil time on timestamp. Re-sign after correcting units so the header and payload Base64URL segments change and the signature matches the fixed claims.

A header that lists alg none or omits a real signature when the resource server expects integrity

Unsigned tokens may help local experiments but production APIs must reject alg none. This encoder requires a supported alg and real signing material for the third segment. If you inherited claims from a debugger session, reissue with HS, RS, PS, or ES and a proper key rather than shipping a payload anyone could rewrite. Confirm the three segments on JWT debugger after each issuance change.

Common questions

How do I generate a JWT with HS256?
Build a header JSON with alg HS256 and typ JWT, then a payload JSON with your claims. Serialize both to compact UTF-8 JSON, Base64URL-encode each, and form the signing input as those two encodings separated by one dot. Compute HMAC-SHA-256 with your shared secret over that UTF-8 string and Base64URL-encode the result as the third segment. The header alg must stay HS256 so verifiers know to use the same secret. HMAC explains how keyed digests differ from bare hashes when you choose secret length.
How do I sign a JWT with RS256?
Set header alg RS256 and typ JWT, define payload claims, then Base64URL-encode header and payload and join them with a dot for the signing input. Sign that input with RSA PKCS#1 v1.5 using SHA-256 and your RSA private PEM, then Base64URL-encode the signature bytes as the third segment. Distribute only the matching SPKI public PEM to verifiers. Private keys belong solely on the signing side; never embed them in client apps that only need to consume tokens.
What is the JWT header and payload format before Base64URL?
The header is a small JSON object, normally typ JWT plus alg naming the signing method. The payload is JSON holding registered claims like sub, exp, and iat and any private names your policy allows. Both must be UTF-8 JSON without unescaped control characters. Each object is encoded to Base64URL independently; the token does not wrap them in an outer JSON envelope. Decode shape and claim typing on JWT debugger before you reissue edited claims.
Should exp and iat be in seconds or milliseconds?
RFC 7519 NumericDate is seconds since the Unix epoch, not milliseconds. exp marks when validation should stop accepting the token unless your service overrides expiry rules. iat records when you signed. Optional nbf uses the same second units to forbid early use. Millisecond timestamps in exp create tokens that appear valid for centuries when parsers honor the standard. Line up second counts with civil time on timestamp before you embed them in payload JSON.
What is the difference between HS256 and RS256 for signing?
HS256 signs with HMAC-SHA-256 using one shared secret known to issuer and every verifier, which is simple but widens secret exposure. RS256 signs with RSA and SHA-256 using a private key; verifiers need only the public PEM, so compromise of an API node does not reveal signing power. Symmetric HS fits trusted internal services. Asymmetric RS fits public clients and multi-tenant APIs. Key generation context lives on HMAC and RSA cipher.
How do I verify a JWT after I sign it?
Copy the compact three-part string into JWT debugger and supply the verify-side material: shared secret for HS algorithms or SPKI public PEM for RS, PS, and ES. The debugger Base64URL-decodes header and payload, checks alg, and recomputes the signature over the same dotted signing input you used here. Successful verify proves the third segment matches your key and that header and payload bytes were not altered after signing. Failed verify usually means wrong key, wrong alg, or a mutated segment.
Which signing algorithms does this encoder support?
Issuance supports HMAC HS256, HS384, and HS512 with a shared secret. It supports RSA PKCS#1 RS256, RS384, and RS512 with a private PEM. It supports RSA-PSS PS256, PS384, and PS512 with the same private key shape. It supports ECDSA ES256, ES384, and ES512 with a private PEM on the named curves. It does not emit alg none or EdDSA variants outside the supported list. The header alg you pick must match the key field you fill.
Does signing hide the payload from people who see the token?
No. JWT in JWS form is integrity protection, not confidentiality. Base64URL is an encoding, not encryption, so anyone with the string can read claims. Signing proves the issuer approved the contents and detects tampering. Sensitive data belongs in JWE, TLS, or server-side storage, not in signed payloads you hand to browsers or mobile clients. Treat issued tokens as bearer credentials whose possession matters.