b2KIT

OAuth PKCE Code Challenge Generator

Generate PKCE code_verifier and code_challenge pairs for OAuth 2.0 authorization code flow with S256 method.

Tested tool guide Tested browser tools Checked August 16, 2026

What OAuth PKCE Code Challenge Generator does and how it behaves

This OAuth-specific generator prepares the two values that bind an authorization request to its later code exchange. It creates a PKCE code_verifier and computes the matching S256 code_challenge as the unpadded base64url representation of the verifier's SHA-256 digest. Generation stays in the browser, so the verifier is not uploaded. A frequent mistake is treating the challenge as another random value. It is derived from the verifier, and even a case change or extra character produces a different challenge.

How the result is produced

1

Verifier format

A valid PKCE code_verifier is case-sensitive and 43 through 128 characters long. Its allowed characters are ASCII letters, digits, hyphen, period, underscore, and tilde. A client uses the verifier for one pending authorization transaction. The matching challenge goes in the authorization request, while the original verifier must be retained for the later token request.

2

S256 derivation

With S256, code_challenge equals BASE64URL-ENCODE(SHA256(ASCII(code_verifier))). SHA-256 first produces 32 bytes. Base64url represents those bytes with its URL-safe alphabet, and trailing equals-sign padding is omitted. Send the result as code_challenge with code_challenge_method set to S256. During code redemption, the authorization server repeats this derivation from code_verifier and performs the PKCE comparison.

Good uses

  • Preparing a fresh S256 pair while implementing an OAuth authorization-code flow in a browser-based, mobile, or desktop client.
  • Supplying concrete code_challenge and code_verifier values when manually testing the authorization and token requests of a PKCE-capable provider.
  • Replacing a lost or malformed verifier by starting a new authorization transaction with a newly generated, internally matching PKCE pair.

Limits and checks

  • The generated pair applies to a new flow. It cannot recover the verifier belonging to an existing challenge, and a newly generated verifier will not match that earlier challenge.
  • Copy both values exactly. The verifier is case-sensitive, and added spaces or line breaks change its digest. The challenge must use base64url without trailing equals-sign padding.
  • A matching pair does not confirm that an authorization server supports S256 or that request parameters, redirect URIs, and client settings are correct. It also does not obtain an authorization code or tokens.

Common questions

Can I reuse the same PKCE pair for several sign-in attempts?

No. Generate a new verifier and challenge for each authorization request. Reuse can confuse concurrent attempts and weakens the intended binding between one authorization request and its code exchange. Store the verifier with the matching pending transaction, then discard it after successful redemption or when that transaction is abandoned.

Where do the verifier and challenge go in OAuth requests?

Put code_challenge and code_challenge_method=S256 in the authorization request. Keep code_verifier in the initiating client until the authorization code is returned, then include it in the token request. Do not place the verifier in the authorization URL. PKCE protects the exchange because a party holding only an intercepted code should not also possess the verifier.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools