JWT 解码器 使用教程
详细使用指南、最佳实践与常见问题解答
使用场景
JWT 解码器适用于调试登录 Token、验证用户身份、检查 Token 过期时间、排查权限问题等场景。当你拿到一串以 . 分隔的 JWT Token 需要查看其 Header 和 Payload 内容时,这个工具能快速解码并格式化显示。
Use Cases
The JWT decoder is useful for debugging login tokens, verifying user identity, checking token expiration, and troubleshooting permission issues. Use it to view the Header and Payload of a dot-separated JWT token.
功能特点
- 自动解析:粘贴即解码 Header 和 Payload
- JSON 格式化:解码结果自动美化
- 过期检测:自动判断 Token 是否过期
- 示例 Token:内置示例,方便快速体验
- 本地解码:Token 不上传,安全可靠
Features
- Auto-parse: paste to decode Header and Payload instantly
- JSON formatting: decoded results are auto-beautified
- Expiration check: automatically detects if the token is expired
- Sample token: built-in example for quick exploration
- Local decoding: token never uploaded, safe and secure
使用示例
示例 1:场景一:前端登录后拿到 Token,粘贴到工具里查看用户 ID、角色、过期时间。
示例 2:场景二:后端 API 报 401 未授权,解码 Token 检查是否过期或权限不足。
示例 3:场景三:对比两个 Token 的 Payload,确认刷新 Token 后权限是否更新。
Examples
Example 1: Scenario 1: After frontend login, paste the token to view user ID, role, and expiration time.
Example 2: Scenario 2: Backend API returns 401 Unauthorized — decode the token to check if it expired or has insufficient permissions.
Example 3: Scenario 3: Compare the Payload of two tokens to confirm whether permissions were updated after a token refresh.
最佳实践
- 永远不要把 Token 分享给他人,即使解码也在本地进行
- JWT 默认不加密,任何人都能解码 Payload,不要存敏感信息
- Token 应通过 HTTPS 传输,避免中间人攻击
- 过期时间建议设置为 1-2 小时,配合 refresh token 使用
Best Practices
- Never share your token with anyone, even though decoding is local
- JWT is not encrypted by default — anyone can decode the Payload, so do not store sensitive data
- Always transmit tokens over HTTPS to prevent man-in-the-middle attacks
- Set expiration to 1-2 hours and pair with a refresh token
常见问题
JWT 安全吗?会被篡改吗?
JWT 通过 Signature 防篡改,修改 Payload 会导致签名不匹配。但 JWT 默认不加密,任何人都能解码 Payload 内容,所以不要在 Token 里存敏感信息。
为什么我的 Token 显示已过期?
检查 Payload 里的 exp 字段(过期时间戳)。如果当前时间已超过 exp,Token 即过期,需要用 refresh token 获取新的。
能解码加密的 JWT 吗?
本工具仅解码未加密的 JWT(alg: HS256/RS256 等签名算法)。加密的 JWT(JWE)需要密钥才能解密,本工具不支持。
FAQ
Is JWT secure? Can it be tampered with?
JWT uses a Signature to prevent tampering — modifying the Payload breaks the signature match. But JWT is not encrypted by default, so anyone can decode the Payload. Do not store sensitive data in a token.
Why does my token show as expired?
Check the exp field in the Payload (expiration timestamp). If the current time exceeds exp, the token is expired and you need to use a refresh token to get a new one.
Can it decode encrypted JWTs?
This tool only decodes unencrypted JWTs (signed with HS256/RS256 etc.). Encrypted JWTs (JWE) require a key to decrypt and are not supported here.