ตัวถอดรหัส JWT
ถอดรหัส JWT เพื่อดู header และ payload ทำงานในเบราว์เซอร์
JWT ทำงานอย่างไร
การใช้งาน debug ทั่วไป
เคล็ดลับความปลอดภัย JWT
JSON Web Token มีสามส่วนที่เข้ารหัส Base64url คั่นด้วยจุด header ระบุอัลกอริทึมการเซ็น (เช่น HS256, RS256) payload มี claims — คู่ key-value เช่น user ID, roles และวันหมดอายุ signature สร้างโดยการเซ็น header และ payload ด้วย secret หรือ private key
ใครก็ตามสามารถถอดรหัส header และ payload โดยไม่ต้องใช้ key — เป็นแค่การเข้ารหัส Base64url ไม่ใช่การเข้ารหัส มีเพียง signature เท่านั้นที่ต้องการ key ซึ่งหมายความว่าข้อมูลที่ละเอียดอ่อนไม่ควรอยู่ใน payload เว้นแต่ token ทั้งหมดจะถูกเข้ารหัส (JWE)
- ตรวจสอบว่า token หมดอายุหรือยัง (exp claim)
- ยืนยันว่า token เป็นของผู้ใช้หรือเซสชันใด (sub claim)
- ตรวจสอบ role หรือ permission claims ที่ API ของคุณอ่าน
- Debug ปัญหาการยืนยันตัวตนในระหว่างการพัฒนา
- ตรวจสอบโครงสร้าง token ก่อนการ implement
- อย่าเก็บข้อมูลที่ละเอียดอ่อนใน payload — ไม่ได้เข้ารหัส แค่เข้ารหัสเท่านั้น
- กำหนดเวลาหมดอายุสั้น — 15 นาทีถึง 1 ชั่วโมงสำหรับ access tokens
- ใช้ RS256 แทน HS256 ในสถาปัตยกรรม multi-service
- ตรวจสอบ signature ฝั่ง server — ไม่เชื่อ token ที่ client แก้ไข
คำถามที่พบบ่อย
- What is a JWT?
- JWT (JSON Web Token) is an open standard (RFC 7519) for securely transmitting information as a JSON object. It consists of three parts separated by dots: a Header (algorithm), a Payload (claims), and a Signature. JWTs are commonly used for authentication and API authorization.
- Is it safe to paste my JWT here?
- Yes. This tool runs entirely in your browser — no data is sent to any server. That said, treat JWTs like passwords: avoid pasting production tokens from sensitive systems into public tools as a general best practice. Use test tokens for debugging.
- Can this verify the JWT signature?
- No. Signature verification requires the secret key (for HMAC) or the public key (for RSA/ECDSA). Since this is a client-side tool, the secret is never available here. Decoding the payload is always possible without the key — which is why sensitive data should never be stored unencrypted in a JWT payload.
- What are common JWT claims?
- Standard claims include: sub (subject/user ID), iss (issuer), aud (audience), exp (expiry timestamp), iat (issued at), nbf (not before). Custom claims are anything else your application adds, like roles, permissions, or user metadata.
- Why is my JWT showing as expired?
- The exp claim is a Unix timestamp. If the current time is past that timestamp, the token is expired. Your server should also reject it. You need to refresh or re-authenticate to get a new token.
เครื่องมือที่เกี่ยวข้อง
- JSON Formatter, Validator & Repair Tool
Format, minify, validate, and repair JSON instantly in your browser. Sort keys alphabetically, auto-format on paste, download as file, escape/unescape strings — free, no sign-up, 100% client-side.
- ตัวสร้าง QR Code
สร้าง QR code สำหรับ URL ข้อความ Wi-Fi และอื่นๆ ดาวน์โหลดเป็น PNG
- ตัวสร้างรหัสผ่าน
สร้างรหัสผ่านสุ่มที่แข็งแกร่งด้วยความยาวและชุดอักขระที่กำหนดเอง
- Base64 เข้ารหัส / ถอดรหัส
เข้ารหัสข้อความเป็น Base64 หรือถอดรหัสกลับเป็นข้อความธรรมดา
- URL เข้ารหัส / ถอดรหัส
เข้ารหัสหรือถอดรหัส URL และ query strings ด้วย percent-encoding