Download jwt.html from natep2234/dev-tools: direct link, hf CLI and curl.
- Browser
- Download file 7.15 kB
-
https://huggingface.co/spaces/natep2234/dev-tools/resolve/main/jwt.html
- Command line
-
hf download hf://spaces/natep2234/dev-tools/jwt.html
-
curl -L -o jwt.html https://huggingface.co/spaces/natep2234/dev-tools/resolve/main/jwt.html
7.15 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>JWT Decoder — dev.tools</title> | |
| <style> | |
| * { margin: 0; padding: 0; box-sizing: border-box; } | |
| body { | |
| background: #0a0a0a; | |
| color: #c8c0b0; | |
| font-family: 'Courier New', Courier, monospace; | |
| min-height: 100vh; | |
| padding: 2rem; | |
| line-height: 1.6; | |
| } | |
| h1 { | |
| font-size: 1.8rem; | |
| color: #d4a54a; | |
| margin-bottom: 0.3rem; | |
| } | |
| .subtitle { | |
| color: #665e50; | |
| font-size: 0.85rem; | |
| margin-bottom: 2rem; | |
| } | |
| textarea { | |
| width: 100%; | |
| min-height: 120px; | |
| background: #141414; | |
| color: #c8c0b0; | |
| border: 1px solid #2a2520; | |
| border-radius: 4px; | |
| padding: 1rem; | |
| font-family: 'Courier New', Courier, monospace; | |
| font-size: 0.9rem; | |
| resize: vertical; | |
| outline: none; | |
| } | |
| textarea:focus { border-color: #d4a54a; } | |
| textarea::placeholder { color: #44403a; } | |
| .output { margin-top: 1.5rem; } | |
| .section { | |
| background: #141414; | |
| border: 1px solid #2a2520; | |
| border-radius: 4px; | |
| padding: 1rem; | |
| margin-bottom: 1rem; | |
| } | |
| .section-title { | |
| color: #d4a54a; | |
| font-size: 0.8rem; | |
| text-transform: uppercase; | |
| letter-spacing: 0.1em; | |
| margin-bottom: 0.8rem; | |
| } | |
| .field { margin-bottom: 0.5rem; } | |
| .field-key { color: #7a9cc6; } | |
| .field-value { color: #c8c0b0; } | |
| .field-string { color: #a3be8c; } | |
| .field-number { color: #d08770; } | |
| .field-bool { color: #b48ead; } | |
| .error { | |
| color: #bf616a; | |
| background: #1a1210; | |
| border: 1px solid #3a1a1a; | |
| border-radius: 4px; | |
| padding: 1rem; | |
| margin-top: 1.5rem; | |
| } | |
| .expiry-valid { color: #a3be8c; } | |
| .expiry-expired { color: #bf616a; } | |
| .sig-note { | |
| color: #44403a; | |
| font-size: 0.8rem; | |
| font-style: italic; | |
| margin-top: 0.5rem; | |
| } | |
| .token-parts { margin-top: 1rem; margin-bottom: 1.5rem; } | |
| .token-parts span { word-break: break-all; } | |
| .part-header { color: #bf616a; } | |
| .part-payload { color: #b48ead; } | |
| .part-sig { color: #7a9cc6; } | |
| .dot { color: #665e50; } | |
| .brand { | |
| text-align: center; | |
| color: #2a2520; | |
| font-size: 0.75rem; | |
| margin-top: 3rem; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>JWT Decoder</h1> | |
| <p class="subtitle">Paste a token. See what's inside.</p> | |
| <textarea id="input" placeholder="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" spellcheck="false"></textarea> | |
| <div id="tokenParts" class="token-parts"></div> | |
| <div id="output" class="output"></div> | |
| <div class="brand">dev.tools by Atreus & Loki</div> | |
| <script> | |
| const input = document.getElementById('input'); | |
| const output = document.getElementById('output'); | |
| const tokenParts = document.getElementById('tokenParts'); | |
| input.addEventListener('input', decode); | |
| function b64decode(str) { | |
| str = str.replace(/-/g, '+').replace(/_/g, '/'); | |
| while (str.length % 4) str += '='; | |
| return JSON.parse(atob(str)); | |
| } | |
| function formatValue(v) { | |
| if (typeof v === 'string') return `<span class="field-string">"${escHtml(v)}"</span>`; | |
| if (typeof v === 'number') return `<span class="field-number">${v}</span>`; | |
| if (typeof v === 'boolean') return `<span class="field-bool">${v}</span>`; | |
| if (v === null) return `<span class="field-bool">null</span>`; | |
| if (Array.isArray(v)) return `<span class="field-string">[${v.map(i => typeof i === 'string' ? `"${escHtml(i)}"` : i).join(', ')}]</span>`; | |
| if (typeof v === 'object') return `<span class="field-string">${escHtml(JSON.stringify(v))}</span>`; | |
| return escHtml(String(v)); | |
| } | |
| function escHtml(s) { | |
| return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); | |
| } | |
| function timeAgo(ts) { | |
| const now = Math.floor(Date.now() / 1000); | |
| const diff = ts - now; | |
| const abs = Math.abs(diff); | |
| if (abs < 60) return diff > 0 ? `in ${abs}s` : `${abs}s ago`; | |
| if (abs < 3600) return diff > 0 ? `in ${Math.floor(abs/60)}m` : `${Math.floor(abs/60)}m ago`; | |
| if (abs < 86400) return diff > 0 ? `in ${Math.floor(abs/3600)}h` : `${Math.floor(abs/3600)}h ago`; | |
| return diff > 0 ? `in ${Math.floor(abs/86400)}d` : `${Math.floor(abs/86400)}d ago`; | |
| } | |
| const knownClaims = { | |
| iss: 'Issuer', sub: 'Subject', aud: 'Audience', exp: 'Expiration', | |
| nbf: 'Not Before', iat: 'Issued At', jti: 'JWT ID', | |
| alg: 'Algorithm', typ: 'Type', kid: 'Key ID' | |
| }; | |
| function decode() { | |
| const token = input.value.trim(); | |
| if (!token) { output.innerHTML = ''; tokenParts.innerHTML = ''; return; } | |
| const parts = token.split('.'); | |
| if (parts.length !== 3) { | |
| output.innerHTML = `<div class="error">Not a valid JWT — expected 3 parts separated by dots, got ${parts.length}.</div>`; | |
| tokenParts.innerHTML = ''; | |
| return; | |
| } | |
| tokenParts.innerHTML = `<span class="part-header">${escHtml(parts[0])}</span><span class="dot">.</span><span class="part-payload">${escHtml(parts[1])}</span><span class="dot">.</span><span class="part-sig">${escHtml(parts[2])}</span>`; | |
| let header, payload; | |
| try { header = b64decode(parts[0]); } catch(e) { | |
| output.innerHTML = `<div class="error">Failed to decode header: ${escHtml(e.message)}</div>`; | |
| return; | |
| } | |
| try { payload = b64decode(parts[1]); } catch(e) { | |
| output.innerHTML = `<div class="error">Failed to decode payload: ${escHtml(e.message)}</div>`; | |
| return; | |
| } | |
| let html = ''; | |
| // Header | |
| html += `<div class="section"><div class="section-title">Header</div>`; | |
| for (const [k, v] of Object.entries(header)) { | |
| const label = knownClaims[k] ? ` <span style="color:#44403a">// ${knownClaims[k]}</span>` : ''; | |
| html += `<div class="field"><span class="field-key">${escHtml(k)}</span>: ${formatValue(v)}${label}</div>`; | |
| } | |
| html += `</div>`; | |
| // Payload | |
| html += `<div class="section"><div class="section-title">Payload</div>`; | |
| for (const [k, v] of Object.entries(payload)) { | |
| let extra = ''; | |
| const label = knownClaims[k] ? ` <span style="color:#44403a">// ${knownClaims[k]}</span>` : ''; | |
| if ((k === 'exp' || k === 'iat' || k === 'nbf') && typeof v === 'number') { | |
| const date = new Date(v * 1000); | |
| const ago = timeAgo(v); | |
| const isExp = k === 'exp'; | |
| const expired = isExp && v < Math.floor(Date.now()/1000); | |
| extra = ` <span style="color:#44403a">→ ${date.toISOString()}</span>`; | |
| if (isExp) { | |
| extra += expired | |
| ? ` <span class="expiry-expired">(EXPIRED ${ago})</span>` | |
| : ` <span class="expiry-valid">(valid, expires ${ago})</span>`; | |
| } else { | |
| extra += ` <span style="color:#44403a">(${ago})</span>`; | |
| } | |
| } | |
| html += `<div class="field"><span class="field-key">${escHtml(k)}</span>: ${formatValue(v)}${label}${extra}</div>`; | |
| } | |
| html += `</div>`; | |
| // Signature | |
| html += `<div class="section"><div class="section-title">Signature</div>`; | |
| html += `<div style="color:#7a9cc6;word-break:break-all;font-size:0.85rem">${escHtml(parts[2])}</div>`; | |
| html += `<div class="sig-note">Signature cannot be verified client-side without the secret/public key.</div>`; | |
| html += `</div>`; | |
| output.innerHTML = html; | |
| } | |
| </script> | |
| </body> | |
| </html> | |