Developer Tool Runs in your browser. Nothing is uploaded.

Webhook Signature Verifier

Verify HMAC webhook signatures for Stripe, GitHub, Shopify, Razorpay, Slack, and Svix. Identify the exact root cause when verification fails.

Generic Settings:
Request 0 bytes
Raw Body (Untampered) 0 lines, 0 chars
HTTP Headers (or paste raw curl/request) 0 headers
Verification Result Ready
Ready to Verify
Provide payload, headers, and secret to compute and compare cryptographic signatures.
Cryptographic Signatures HMAC-SHA256
COMPUTED SIGNATURE (Calculated by verifier)
—
EXPECTED SIGNATURE (From HTTP Header)
—
Signed Payload Structure (Exact Bytes Signed) 0 bytes
No payload loaded.
Control characters highlighted in cyan: \r \n \t
Correct Verification Snippets
// Loading snippet...

How to Verify Webhook Signatures Correctly

Webhooks transmit asynchronous event notifications between cloud platforms and your application servers. Because webhook HTTP endpoints must be publicly accessible on the internet, verifying cryptographic signatures is your primary defense against fraudulent events, unauthorized tampering, and replay attacks.

  1. Capture the Unmodified Raw Body: You must access the exact raw string or byte stream of the HTTP request before any framework middleware (such as express.json(), Django request parser, or Spring Boot @RequestBody) deserializes it into an object or dictionary.
  2. Extract Signature & Metadata Headers: Retrieve provider-specific signature headers (e.g., Stripe-Signature, X-Hub-Signature-256) and any companion headers like timestamps or delivery identifiers.
  3. Construct the Canonical Signed Payload: Format the exact message template defined by the vendor. For example, Stripe and Svix mandate concatenating the integer timestamp with a period separator and the raw body ({timestamp}.{raw_body}), whereas GitHub signs the raw payload alone.
  4. Calculate HMAC with Webhook Secret: Execute an HMAC-SHA256 (or HMAC-SHA1) digest using your dedicated webhook signing secret and format the digest into hex or Base64 as specified.
  5. Compare in Constant Time: Always verify using a constant-time comparison helper like Node.js crypto.timingSafeEqual(), Python hmac.compare_digest(), or PHP hash_equals() to thwart microsecond side-channel timing attacks.

Before & After Example: Fixing Express.js Raw Body Parsing

The single most frequent reason developers encounter invalid signatures is framework body parsers re-serializing JSON with altered whitespace or differing key order. Here is how to fix this in Express:

Before: Fragile JSON Middleware (Fails Signature Verification)

// ❌ BROKEN: express.json() converts body to an object; re-stringifying alters bytes!
const express = require('express');
const app = express();
app.use(express.json());

app.post('/webhook', (req, res) => {
  // JSON.stringify(req.body) does NOT match the original byte-for-byte stream!
  const computed = crypto.createHmac('sha256', SECRET)
    .update(JSON.stringify(req.body))
    .digest('hex');
  // Result: Verification almost always FAILS!
});

After: Preserving Raw Body with verify callback

// ✅ SECURE & ACCURATE: Preserve raw buffer directly from the incoming stream
const express = require('express');
const crypto = require('crypto');
const app = express();

app.use(express.json({
  verify: (req, res, buf) => {
    // Preserve the pristine buffer directly from the network socket
    req.rawBody = buf;
  }
}));

app.post('/webhook', (req, res) => {
  const signature = req.headers['x-hub-signature-256'];
  const expected = 'sha256=' + crypto.createHmac('sha256', SECRET)
    .update(req.rawBody)
    .digest('hex');

  if (crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) {
    res.status(200).send('Verified');
  } else {
    res.status(400).send('Invalid signature');
  }
});

Common Failure Causes & Diagnosing Inconsistencies

Frequently Asked Questions

Why does my webhook signature not match?
The most common culprit is payload alteration prior to verification: web frameworks like Express, FastAPI, or Rails frequently parse JSON into objects and re-serialize, altering whitespace, key ordering, or Unicode escaping. Other frequent causes include newline conversions (CRLF vs LF), extra trailing whitespace, using a live API secret instead of a webhook signing secret, or failing to construct the signed payload template (like prepending timestamp).
Why must I use the raw body?
HMAC hashes every single byte exactly as transmitted across the wire. If your server parses JSON into a dictionary or object before hashing, any difference in indentation, commas, space around colons, or key ordering creates a completely distinct hash value, causing verification to fail.
What is a timestamp tolerance?
Timestamp tolerance (replay attack prevention) checks whether the webhook was signed recently, usually within 300 seconds (5 minutes). If an attacker intercepts your webhook payload and re-sends it, verifying that the timestamp header is close to the current server time rejects outdated replayed requests.
Is my secret sent anywhere?
No. All cryptographic computations use the native browser Web Cryptography API (window.crypto.subtle) entirely within your device's memory. No data, headers, body, or secrets ever leave your browser or get sent to any server.
How does constant-time comparison prevent timing attacks?
Standard string equality operators (== or ===) terminate at the first mismatched byte, leaking how many initial characters were correct through microsecond timing differences. A constant-time comparison executes a bitwise XOR across the full string length regardless of mismatches, eliminating timing leaks.

Security & Privacy Notice

All signature calculations in this tool are executed locally using standard Web Cryptography (crypto.subtle). Secrets, headers, and request bodies never touch any server. As a general operational best practice, never enter production root secrets on third-party computers, and consider rotating any secrets that have been shared or exposed during debugging sessions.