Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
To verify a JWT without a JWT library, validate its compact JWS structure, preserve the original encoded header and payload, and pass their exact signing input to a trusted cryptographic verification primitive. Choose the allowed algorithm and trusted key from your application’s policy—not from the token alone. A valid signature is only one check: you must also validate the issuer, audience, time claims, and intended use.
This guide covers a signed or MAC-protected compact JWS, which has three period-separated segments. It does not cover an encrypted compact JWE, which has five segments, or the additional validation needed for a nested JWT. The goal is to avoid a JWT convenience library, not to implement cryptographic algorithms yourself. See the IETF definitions of JWS and JWT.
What bytes must you verify?
A compact JWS is structured as protected-header.payload.signature. The signing input is the original protected-header segment, a literal period, and the original payload segment, encoded as ASCII bytes:
original_header_segment + "." + original_payload_segment
Do not decode the JSON and serialize it again to construct this input. Whitespace, property order, escaping, or other serialization differences can change the bytes, even if the resulting JSON values appear equivalent. The signature was made over the encoded segments, not over your newly serialized JSON. This signing-input rule is specified in RFC 7515, sections 3.1 and 5.2.
#1 Best Overall
- POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
- WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
- FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
- TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
- BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.
Base64url decoding is needed to inspect the header and payload and to obtain the signature bytes. It does not change which bytes are used as the signing input: retain the original first and second segments for that purpose.
How to verify a compact JWS
- Check the structure. Require exactly three compact segments and reject malformed input. A five-segment token is a compact JWE, not this signed-JWS flow. Do not silently trim whitespace or accept extra characters in segments.
- Decode and parse the protected header. Strictly Base64url-decode the first segment and parse its JSON as UTF-8. Reject invalid encoding or malformed JSON. Check that the header parameters required by your application are present and that you can process every critical parameter. Reject unsupported parameters rather than ignoring them. RFC 8725, section 3.7 requires UTF-8 for JOSE header and JWT claim JSON.
- Apply your algorithm policy. Allow only algorithms your application explicitly accepts for this token and operation. Treat
algas untrusted input; it can be checked against policy, but it must not choose an unrestricted cryptographic operation. Reject unsupported algorithms and any mismatch between the configured algorithm and the key. - Find a trusted key. Obtain a verification key from trusted application configuration or an issuer-controlled key-distribution process that your application validates. A
kidmay select a candidate from that trusted set; it does not prove the key is trustworthy. Do not fetch a URL from an untrusted header or trust an embedded JWK merely because the token contains it. - Build the exact signing input. Join the original encoded header segment, one period, and the original encoded payload segment, without decoding and reserializing either segment.
- Decode the signature and verify it. Strictly Base64url-decode the third segment. Use a well-maintained platform or cryptographic library’s algorithm-appropriate verification primitive, with the selected key, the exact signing input, and the expected signature representation. Reject the token if verification fails or the key is incompatible.
- Validate the token for your application. Only after successful cryptographic verification, check the expected issuer, audience, expiration, not-before time, subject, token purpose, and any other application-specific conditions.
RFC 7515’s JWS validation procedure requires the verifier to process supported header parameters, decode the payload and signature, and validate against the signing input using the algorithm represented by alg. If a required step fails, the JWS cannot be validated. The standard also leaves the choice of acceptable algorithms to the application. See RFC 7515, section 5.2.
Rank #2
- POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
- WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
- FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
- MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
- PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
Choose the key and algorithm as a pair
Algorithm policy belongs to the verifier. RFC 8725 says JWT libraries must let callers specify supported algorithms, and states that each key must be used with exactly one algorithm and that this must be checked during the cryptographic operation. Though the requirement is directed at JWT libraries, the same discipline matters when assembling verification yourself. See RFC 8725, section 3.1.
Free tools Windows power users keep installed
One-click scans. No signup required.
Key provenance is part of that policy. If the JWT has an iss claim, validate that the key used belongs to that issuer. Header values such as kid, jku, and jwk can be useful in a defined key-distribution system, but they are not trust anchors on their own. RFC 7515 discusses these key-identification parameters, while RFC 8725 requires issuer-to-key validation when an issuer is present.
Rank #3
- POWERFUL SECURITY KEY: The YubiKey 5C NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
- WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5C NFC secures 100+ of your favorite accounts, including email, password managers, and more
- FAST & CONVENIENT LOGIN: Plug in your YubiKey 5C NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
- MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
- PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
| Algorithm family | Verification key and trust implication | Implementation detail |
|---|---|---|
| Symmetric, such as HS256 | The verifier needs the shared secret. Anyone who holds it can also produce a valid MAC, so every verifier with that secret has signing capability. | Use a strong, randomly generated secret intended for this algorithm; do not use a human-memorable password directly as an HS256 key. |
| Asymmetric, such as RS256 or ES256 | The signer uses a private key; verification can use its corresponding public key. The application still has to establish that the public key belongs to the expected issuer. | Use the correct algorithm-specific primitive and signature format. In particular, the JWS ECDSA representation may not be the encoding expected by a low-level API. |
These families have different key-management and trust consequences; neither is universally preferable without the application’s requirements and policy. RFC 7515 describes HMAC-SHA-256, RSA PKCS#1 v1.5 with SHA-256, and ES256, among other JWS details, in its appendices A.1–A.3.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What low-level verification APIs may require
Removing a JWT library also removes its handling of compact serialization, Base64url decoding, algorithm mapping, key selection, and claim policy. Those responsibilities do not disappear; your code must address them explicitly. Keep cryptographic operations in a maintained platform or cryptographic library rather than writing the primitive yourself.
Rank #4
- POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
- WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
- FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
- TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
- BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.
- Strict compact parsing: Require the expected segment count and reject malformed Base64url. RFC 7515’s Base64url rules reject encoded lengths whose remainder after division by four is one. Do not silently accept arbitrary whitespace or extra characters.
- UTF-8 JSON: Decode JOSE headers and claims as UTF-8, not another Unicode encoding, as specified in RFC 8725, section 3.7.
- Algorithm-specific signatures: The JWS ES256 signature is a 64-octet concatenation of 32-octet
RandSvalues. Some cryptographic APIs expect a different ECDSA encoding, so a conversion may be required. Handle any conversion with a carefully validated implementation; a generic “verify” call does not necessarily accept every JWS signature representation unchanged. See RFC 7515, appendix A.3. - One algorithm per key: Do not reuse a key under a different algorithm simply because an API accepts it. Enforce the allowed algorithm and key type together during verification.
The standards specify the protocol and security requirements, not a language-specific API call. The right primitive, key format, and any signature-format conversion depend on your runtime and cryptographic provider.
Failures that should reject the token
alg: noneappears in a flow that requires a signature or MAC.- The token’s
algis unsupported, disallowed by policy, or inconsistent with the selected key. - An RSA public key is mistakenly treated as an HMAC secret, creating an algorithm-confusion vulnerability.
- A human-memorable password is used directly as an HS256 key.
- The verifier changes the header or payload bytes by decoding and reserializing them before verification.
- A
kid,jku, or embedded JWK is treated as trusted without validating its provenance and issuer relationship. - Any required cryptographic operation fails. For nested constructions, validating just one operation is insufficient when both inner and outer operations are required.
RFC 8725, sections 2–3 describes attacks involving none, RS256-to-HS256 confusion, weak HMAC keys, and incomplete validation of JWT cryptographic operations. Reject the whole token if an operation required by its construction fails.
What a valid signature does—and does not—prove
A successful verification means the signature or MAC matches the exact signing input under the selected key and algorithm. It does not, by itself, establish that the key belongs to the issuer you expect, that the token was meant for your service, that its time claims are acceptable, or that its claims authorize the requested action. Validate those conditions against your application’s rules; when iss is present, RFC 8725 requires validating the relationship between that issuer and the key used.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

