JWT Inspector

Decodes a token into header, payload and signature. Decoding is not verification and the component says so — a green tick without the signing key would be actively dangerous.

src/components/ui/jwt-inspector.tsx

About

From the component's own source, where it was written.

Decodes a JWT into its header, payload and signature.

Decoding is not verification, and the component says so rather than implying a checked token. Signature verification needs the key and belongs on the server; a green tick here would be actively dangerous.

exp and nbf are resolved to real times, because a bare epoch integer is the single most common thing people misread in a token — off-by-1000 between seconds and milliseconds is an afternoon lost.

alg: none is called out loudly. It is the classic JWT vulnerability and it looks like an ordinary field in a JSON dump.

The signature is masked by default. This gets screenshotted into tickets, and a token with its signature is a live credential.

Install

npx astralyx-ui add jwt-inspector

Usage

import { JwtInspector } from '@/components/ui/jwt-inspector'

<JwtInspector token={token} />

Composer

Change the props and the source below follows.

HS256Expired ·
Header
alg:"HS256"
typ:"JWT"
Payload
sub:"usr_8812"
name:"Ada Okafor"
0:"admin"
iat:1787293600
exp:1787380000
Signature••••••••••••••••••••••••••••••••••••••••••

Decoded only — the signature has not been verified. That needs the signing key and belongs on the server.

Props
tsx
<JwtInspector token={token} />

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

JwtInspector

Extends Omit<ComponentProps<'div'>, 'children'>.

PropTypeDefaultDescription
tokenstringrequiredThree base64url segments. A malformed token is reported, not half-rendered.
nowDate—Reference instant for expiry. Defaults to now.
revealSignaturebooleanfalseShow the signature rather than masking it.
headerLabelReactNode'Header'—
payloadLabelReactNode'Payload'—
signatureLabelReactNode'Signature'—
unverifiedNoteReactNode'Decoded only — the signature has not been verified. That needs the signing key and belongs on the server.'—
invalidNoteReactNode'That does not parse as a JWT. A token has three dot-separated base64url segments.'—
algNoneNoteReactNode'alg is "none": this token asserts it is unsigned. Anything accepting it accepts a forgery.'—
expiredLabelReactNode'Expired'—
activeLabelReactNode'Active'—
notYetValidLabelReactNode'Not yet valid'—

Functions

FunctionSignatureDescription
decodeJwtSegment(segment: string) => Record<string, unknown> | nullbase64url → JSON. Padding is restored; atob requires it.

Behaviour

TopicDetailDescription
exp / nbf / iatresolvedShown as real times. A bare epoch integer is the most misread field in a token — off-by-1000 between seconds and milliseconds costs an afternoon.
alg: noneflagged loudlyThe classic JWT vulnerability, and it looks like an ordinary field in a JSON dump.
signaturemasked by defaultThis gets screenshotted into tickets, and a token with its signature is a live credential.