企评社

Interface labels are shown in English. Company reviews, forum posts and tool descriptions are currently available in Chinese only.

JWT sign / verify

HS256 signing · three-part decoding · exp/nbf/iat validity status · verification with the same key

token 与密钥只在你浏览器里参与计算,不上传、不留存
使用前必读: 本页只实现 HS256(HMAC-SHA256 对称密钥):签名与验签用同一把密钥,持有同一密钥的人都能产生合法签名。 「验签通过」只表示签名与你输入的密钥匹配,不代表这个 token 可信(签发方、受众、权限以签发服务为准,生产验签请走 RS256/ES256 等非对称算法)。 生成与验签依赖浏览器加密接口(https 或 localhost 安全上下文可用);解析功能不依赖它,http 下也可用。

生成:Header + Payload + 密钥 → 三段式 token

exp 快速填写(自当前时刻):

密钥只存在于页面内存:不上传、不写 localStorage,刷新或关闭页面即消失。

生成的 token(Header.Payload.签名)

使用前请先看清楚:本页适合什么、不适合什么

① 「验签通过」不等于「token 可信」。验签通过只证明「这个 token 的签名与你输入的密钥匹配」——也就是持有这把密钥的人产出了它。谁签发的(iss)、给谁的(sub/aud)、携带什么权限、有没有被滥用,页面都替不了签发服务背书。生产环境请走签发服务自己的校验逻辑。

② 本页只实现 HS256(对称密钥)。HS256 的签名与验签用同一把密钥:密钥一旦泄露,任何人都能伪造合法 token。真实系统普遍使用 RS256 / ES256 等非对称算法(公钥验签、私钥签发);本页不实现它们,遇到这类 token 会如实说「只能解析、无法验签」。

③ token 与密钥不上传、不留存。签名与验签由浏览器内置的 WebCrypto(HMAC-SHA256)在本地完成,页面不发起任何网络请求、不写 localStorage 或 cookie,刷新即清空;密钥不会被存到任何地方。

④ 本页不保管密钥、也不提供密钥管理。不要把生产密钥长期留在这类网页里;本页的定位是调试、联调与学习(看懂 token 结构、核对签名、检查有效期)。

什么是 JWT,这个 JWT 生成器 / 解析器能做什么

JWT(JSON Web Token)是三段用英文句点连接的字符串:Header.Payload.签名。Header 声明算法(如 HS256),Payload 携带声明(claims,如 sub 主体、exp 过期时间),签名是对「前两段拼接结果」用密钥做的 HMAC-SHA256 计算——任何一段被改动,签名都会对不上。三段各自用 base64url 编码,所以内容可以直接肉眼读出,JWT 不是加密格式,Payload 里的内容对所有人可见,不要把密码、证件号这类敏感数据写进 Payload。

本页做三件事:生成——编辑 Header 与 Payload 的 JSON、填写密钥,在浏览器里完成 HS256 签名并拼出标准 token(exp 支持按 1 小时 / 1 天 / 7 天 / 30 天快速填写);解析——粘贴任意 JWT,拆出三段、解码显示 JSON,并对 exp / nbf / iat 给出本地时间与「还剩多久过期 / 已过期多久 / 尚未生效」的状态提示;验签——用相同密钥重新计算签名,与 token 里的签名逐字节比对,告诉你匹配与否。

exp、nbf、iat 都是 Unix 时间戳(秒):exp 过期时间(之后应被拒绝)、nbf 生效时间(之前不算有效)、iat 签发时间。排查「token 为什么被拒」时,先解析看这三个值,再核对服务端时钟与签发参数。

为什么能做到不上传?签名与验签用的是浏览器内置的 WebCrypto(HMAC-SHA256),密钥与 token 全程只在本机内存里参与计算,页面不发起任何网络请求——你可以在开发者工具的 Network 面板核验(只会看到页面自身与统计脚本的请求)。唯一的限制:WebCrypto 只在安全上下文(https 或 localhost)开放,http 打开时生成与验签不可用,解析不受影响。

FAQ

What can this JWT generate / verify page do?

Three things. Generate: edit the Header and Payload claims as JSON, type a signing key, and the page computes the signature with HMAC-SHA256 (HS256) right in your browser and assembles the standard three-part token. Decode: paste an existing token, split it into Header / Payload / signature, show the decoded JSON, and give the local time and status for claims like exp/nbf/iat. Verify: recompute the signature with the same key and compare it with the token's. Everything runs locally in the browser - no registration needed.

Verification passed - can I trust this token?

That proves nothing beyond this: the token's signature matches the key you entered - whoever holds that key produced this token. Whether the token is trustworthy depends on the issuing service: who signed it (iss), for whom (sub/aud), whether it expired (exp), what privileges it carries - this page cannot vouch for any of it. Also, HS256 is a symmetric-key algorithm: anyone holding the same key can forge a valid signature. Verify production tokens through the issuing service's own checks (including RS256/ES256 asymmetric algorithms); this page is for debugging and learning.

What do exp, nbf, iat mean?

exp is the expiry (after that moment the token should be rejected), nbf the not-before time (before it the token is not yet valid), iat the issued-at time; all are Unix timestamps in seconds. After decoding, this page shows each one as your local time plus its position relative to now - how long until expiry, how long since it expired, or not yet in force - so the token's validity window is obvious at a glance.

Are my token and key uploaded?

No. Token and key only take part in local computation inside your browser (WebCrypto HMAC-SHA256): the page makes no network requests, writes nothing to localStorage or cookies, and reloading clears it. The key is never stored anywhere - close the page and no copy remains on your machine.

Why do some pages say 'please use https' when generating or verifying?

Browsers only expose the crypto.subtle web-crypto interface in a secure context (https or localhost), and this page uses it for HMAC signing and verification. Opened over plain http, generate and verify are disabled with a banner at the top; decoding does not need that interface and keeps working. Switch to https and everything works.

Related tools