Test GitHub webhooks
Get a URL for a repository webhook, see each delivery with its event name, check X-Hub-Signature-256 with your secret, and forward deliveries to your local server. Free, no signup.
Get a webhook URLAdd the URL in GitHub
- Open webhookcat.com, copy your URL and add
/webhooks/githubto the end. Sub-paths are kept when requests are forwarded, so this one reaches the route in the code below. - In the repository, open Settings, then Webhooks, and click Add webhook.
- Paste your WebhookCat URL as the Payload URL, choose
application/jsonas the Content type, and enter a Secret if you want to check signatures. - Pick the events and click Add webhook. GitHub sends a ping event right away, so the first request shows up within seconds.
What GitHub sends
- X-GitHub-Event
- The event name, such as
push,pull_requestorping. - X-GitHub-Delivery
- A unique ID for the delivery.
- X-Hub-Signature-256
sha256=followed by the hex HMAC-SHA256 of the body.- User-Agent
- Starts with
GitHub-Hookshot/.
Check the signature
Open a request in WebhookCat and paste the secret into the Signature box under it. You'll see right away whether it matches. The check runs in your browser, and the secret is never sent or saved.
Use the Secret you entered when you created the webhook. GitHub doesn't show it again after saving, but you can set a new one.
The same check in your own Node.js server:
import crypto from "node:crypto";
import express from "express";
const app = express();
const secret = process.env.GITHUB_WEBHOOK_SECRET;
const raw = express.raw({ type: "application/json" });
// Constant-time comparison; timingSafeEqual needs equal lengths.
const matches = (a, b) => {
const x = Buffer.from(a);
const y = Buffer.from(b);
return x.length === y.length && crypto.timingSafeEqual(x, y);
};
app.post("/webhooks/github", raw, (req, res) => {
const hmac = crypto.createHmac("sha256", secret).update(req.body);
const expected = "sha256=" + hmac.digest("hex");
if (!matches(expected, req.get("x-hub-signature-256") ?? "")) {
return res.status(401).send("Bad signature");
}
console.log(req.get("x-github-event"), JSON.parse(req.body));
res.sendStatus(204);
});Forward to your local server
In the inbox you pasted into GitHub, open Share and run the command shown there. It forwards each request to localhost:3000/webhooks/github with the same headers and body, so the signature check in your code passes too. Needs Node.js 22 or later.
$ npx webhookcat listen 3000 --inbox "https://webhookcat.com/#<id>/<key>"Starting from the terminal instead? npx webhookcat listen 3000 creates a new URL and prints it. Paste that URL plus /webhooks/github into GitHub. More in the docs.
Good to know
- With the
application/x-www-form-urlencodedcontent type, the JSON arrives in a form field namedpayload. The signature still covers the raw body, and WebhookCat lists the field under Form fields. - GitHub waits 10 seconds for a response, then counts the delivery as failed.
- GitHub doesn't retry failed deliveries by itself. Use Redeliver on the webhook's Recent Deliveries tab to send one again.