Telegram Mini App initData Validator
Paste Telegram.WebApp.initData and your bot token to check whether the Mini App hash is valid — the same HMAC-SHA256 check your server must run, done locally in your browser.
The token stays in your browser (localStorage) and is sent only to api.telegram.org.
Algorithm: secret_key = HMAC_SHA256("WebAppData", bot_token); hash = hex(HMAC_SHA256(secret_key, data_check_string)), where data_check_string is all fields except hash sorted by key and joined as key=value with \n.
How to check the Telegram Mini App hash
- Get the raw initData string in your Mini App, for example by logging
Telegram.WebApp.initData(notinitDataUnsafe). A URL fragment starting withtgWebAppData=also works: the prefix is removed. - Paste the token of the bot that opens the Mini App.
- Press Validate. You get a valid/invalid verdict,
auth_datewith its age (a warning if it is older than 24 hours) and all fields parsed, withuserand other JSON values decoded.
How the validation works
The tool follows the official algorithm from Validating data received via the Mini App:
- Parse initData as a query string and set
hashaside. - Build
data_check_string: all other fields askey=value(URL-decoded values), sorted alphabetically, joined with a line feed\n. secret_key = HMAC_SHA256(key="WebAppData", message=bot_token).- The data is valid if
hex(HMAC_SHA256(key=secret_key, message=data_check_string))equalshash.
The same check on a Node.js server:
const crypto = require('crypto');
function checkInitData(initData, botToken) {
const params = new URLSearchParams(initData);
const hash = params.get('hash');
params.delete('hash');
const dataCheckString = [...params]
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
.map(([k, v]) => `${k}=${v}`)
.join('\n');
const secret = crypto.createHmac('sha256', 'WebAppData').update(botToken).digest();
const calc = crypto.createHmac('sha256', secret).update(dataCheckString).digest('hex');
return calc === hash;
}
Also check auth_date on the server so an old, intercepted initData can't be replayed.
Why the hash does not match
- The token is from a different bot than the one that launched the Mini App.
- initData was decoded or modified before validation — always pass the raw string.
- The string was rebuilt from
initDataUnsafe: field order and encoding differ, so the hash won't match.
Privacy
No request leaves your browser: the HMAC is computed with the Web Crypto API, and the token is kept only in localStorage — nothing reaches our server. To see live initData from a real launch, open the /telegram-mini-app-tester.html inside Telegram. The full testing workflow is in /guides/test-telegram-mini-app.html; if you need a new token, see /guides/telegram-bot-token.html.
Frequently asked questions
How do I validate Telegram Web App init data?
Compute secret_key = HMAC_SHA256("WebAppData", bot_token), build the data-check-string from all fields except hash sorted by key and joined with \n, and compare hex(HMAC_SHA256(secret_key, data_check_string)) with hash. The tool above does exactly this.
Why is my initData hash invalid?
Usually the token belongs to another bot, or initData was changed: decoded, re-encoded, trimmed or rebuilt from initDataUnsafe. Paste the raw Telegram.WebApp.initData string.
Can I trust initDataUnsafe?
Not on the server. initDataUnsafe is just parsed data in the client; send the raw initData to your backend and validate the hash there before trusting the user ID.
How old can initData be?
Telegram recommends checking auth_date to reject outdated data, but the limit is up to you. The tool shows the age and warns when the data is older than 24 hours.
Is my bot token sent anywhere?
No. The validator makes no network requests: the hash is computed with the Web Crypto API in your browser. The token is only remembered in localStorage.
Other utilities
Chat ID finderMarkdownV2 & HTML escaperWebhook checkerBot API Tester