DevToolBox

JWT Decoder

JSON Web Token (JWT) をブラウザ内でデコードし、ヘッダー・ペイロード・署名を確認できます。

How to Use the JWT Decoder

This free online JWT decoder lets you inspect JSON Web Tokens directly in your browser. Paste any JWT into the input field and click "Decode" to instantly view the header, payload, and signature components. The tool automatically detects and displays expiration (exp) and issued-at (iat) timestamps in a human-readable format, and indicates whether the token is currently valid or expired. All decoding happens client-side, so your tokens are never transmitted to any external server.

What Is a JSON Web Token (JWT)?

A JSON Web Token is a compact, URL-safe means of representing claims to be transferred between two parties. Defined by RFC 7519, a JWT consists of three Base64URL-encoded parts separated by dots: the header, the payload, and the signature. The header typically contains the token type (JWT) and the signing algorithm (such as HS256 or RS256). The payload contains the claims, which are statements about the entity (typically the user) and additional metadata. The signature is used to verify the token has not been altered and, in the case of tokens signed with a private key, to verify the identity of the sender.

Common JWT Claims

JWTs contain registered claims such as iss (issuer), sub (subject), aud (audience), exp (expiration time), nbf (not before), iat (issued at), and jti (JWT ID). Custom claims can also be included to carry application-specific data such as user roles, permissions, or profile information. Understanding these claims is essential for debugging authentication flows, API integrations, and authorization issues in modern web applications.

Use Cases for JWT Decoding

Developers frequently need to decode JWTs when debugging authentication systems, verifying token contents during API development, inspecting OAuth2 and OpenID Connect tokens, troubleshooting session management issues, and validating token expiration in frontend applications. This tool provides a quick and secure way to inspect token contents without installing any software or using command-line tools. Note that this tool only decodes the token; it does not verify the signature, which requires the signing key.

JWTデコーダーの使い方

この無料オンラインJWTデコーダーは、JSON Web Tokenをブラウザ内で即座にデコードします。 入力欄にJWTトークンを貼り付け、「デコード」ボタンをクリックするだけで、 ヘッダー、ペイロード、署名を確認できます。有効期限(exp)や発行日時(iat)が含まれている場合は 自動的に日本時間で表示され、トークンが有効か期限切れかも判定されます。 全ての処理はブラウザ内で完結し、トークンが外部サーバーに送信されることはありません。

実務での活用例とハマりどころ

よくあるペイロード例

{
  "sub": "user_12345",
  "name": "Taro Yamada",
  "iat": 1713950000,
  "exp": 1713953600,
  "aud": "my-api",
  "iss": "https://auth.example.com",
  "roles": ["user", "admin"]
}

subは主体(通常ユーザーID)、audは想定する送信先API、issは発行元です。APIサーバーがこれらを検証しないとトークン使い回しの脆弱性になります。

401/403が返るときの切り分け

  1. 本ツールで exp を確認。過去ならリフレッシュ
  2. aud が呼び出しAPIの想定と一致するか確認
  3. iss が認証サーバーのURLと一致するか確認
  4. ヘッダーの alg がAPI側の想定(例: RS256)と一致するか

セキュリティ上の注意

  • JWTは署名されていても中身は誰でも読める。パスワードなどの機密をpayloadに入れない
  • 本ツールは署名検証を行いません。検証には発行元の公開鍵が必要で、その場合はサーバーサイドで行うのが原則
  • トークンをlocalStorageに保存するとXSSで抜かれやすい。HttpOnly Cookieの利用が推奨

関連ガイド

exp/iat/nbfの詳しい解説、クロックスキューや401対処フローはJWTの有効期限切れを確認する方法にまとめています。

よくあるエラーと対処 / Common Errors and Fixes

症状 / Symptom原因 / Cause対処 / Fix
401 Unauthorized でトークン拒否
401 on valid-looking token
exp が過去
exp already passed
リフレッシュトークンで再発行、またはクロックスキュー許容
Refresh the token; allow clock skew on server side
signature verification failedalg 不一致 / 鍵の取り違え
alg mismatch or wrong key
ヘッダー alg と検証側設定を一致させる
Make header alg match the verifier config
invalid audienceaud クレームが呼出し API と不一致
aud doesn't match the calling API
トークンを正しい aud で再発行
Reissue with the correct aud
3 分割できない
Not 3 dot-separated parts
コピー欠け / URL エンコードされた .
Truncated copy or URL-encoded dots
原文を再取得。%2E. に戻す
Re-copy the raw token; decode %2E back to .
algorithm not allowedalg: none や弱い HS256 を拒否
alg: none / weak HS256 disallowed
RS256/ES256 などで再発行。alg: none は使わない
Reissue with RS256/ES256; never use alg: none

言語別コード例 / Code Examples by Language

JavaScript (decode only, no verify)

function decodeJwt(token) {
  const [h, p] = token.split(".").slice(0, 2).map(seg => {
    const b64 = seg.replace(/-/g, "+").replace(/_/g, "/");
    const pad = b64.length % 4 ? "=".repeat(4 - (b64.length % 4)) : "";
    return JSON.parse(decodeURIComponent(escape(atob(b64 + pad))));
  });
  return { header: h, payload: p };
}

Node.js (verify with jsonwebtoken)

import jwt from "jsonwebtoken";

try {
  const payload = jwt.verify(token, publicKey, { algorithms: ["RS256"] });
  console.log(payload);
} catch (e) {
  // TokenExpiredError / JsonWebTokenError / NotBeforeError
  console.error(e.name, e.message);
}

Python (PyJWT)

import jwt  # pip install pyjwt

payload = jwt.decode(
    token, public_key, algorithms=["RS256"], audience="my-api"
)

Shell (inspect payload only)

echo "$TOKEN" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null | jq .

Before / After 実例 / Before & After

例1: exp をデコードして UTC/JST で読む / Decode exp

"exp": 1713953600
→ 2024-04-24 21:33:20 JST (2024-04-24 12:33:20 UTC)

例2: ヘッダーを確認 / Inspect header

eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9
→ { "alg": "RS256", "typ": "JWT" }

例3: 署名部はバイナリなので 16 進で / Signature shown in hex

Base64URL: 3f9c...eL4
Hex: 3f9c1a...78be4f

Why browser-only? / なぜブラウザ完結か

A JWT is a bearer credential: anyone who holds it can act as the user until it expires. Server-hosted decoders log the tokens you paste, which means your debugging session leaves a trail of valid credentials on a third-party system. DevToolBox decodes locally — open DevTools → Network and confirm no requests are made while you paste.

JWT は bearer token です。手に入れた相手は期限切れまでユーザーとして振る舞えます。 サーバ型のデコーダはあなたが貼った有効なトークンをログに残します。 DevToolBox はローカルで decode するだけ。DevTools → Network で通信ゼロを確認できます。

関連ガイド / Related Guides

開発をもっと効率的に

PR