<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: My Tool Studio</title>
    <description>The latest articles on DEV Community by My Tool Studio (@mytoolstudio).</description>
    <link>https://dev.to/mytoolstudio</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4255941%2F069ed444-cef4-4490-984f-4150d016c760.png</url>
      <title>DEV Community: My Tool Studio</title>
      <link>https://dev.to/mytoolstudio</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mytoolstudio"/>
    <language>en</language>
    <item>
      <title>How to Decode a JWT Without Pasting It Into a Random Website</title>
      <dc:creator>My Tool Studio</dc:creator>
      <pubDate>Fri, 20 Nov 2026 15:24:11 +0000</pubDate>
      <link>https://dev.to/mytoolstudio/how-to-decode-a-jwt-without-pasting-it-into-a-random-website-225k</link>
      <guid>https://dev.to/mytoolstudio/how-to-decode-a-jwt-without-pasting-it-into-a-random-website-225k</guid>
      <description>&lt;p&gt;You're debugging a login bug. The API returns &lt;code&gt;401&lt;/code&gt;, and all you have is a long string that starts with &lt;code&gt;eyJ&lt;/code&gt;. The fastest move is to paste it into the first "JWT decoder" Google shows you.&lt;/p&gt;

&lt;p&gt;Before you do that, stop for a second. That string is a live credential. Whoever holds it can usually act as that user until it expires. Pasting a production token into a site you don't know is the same as pasting a password.&lt;/p&gt;

&lt;p&gt;The good news: you don't need any website to read a JWT. It's two pieces of Base64URL-encoded JSON and a signature. You can decode it in one line of JavaScript, Node or Python, on your own machine.&lt;/p&gt;

&lt;p&gt;This guide shows how to do it by hand, what the claims mean, and why "it decodes" never means "it's valid".&lt;/p&gt;

&lt;h2&gt;
  
  
  What a JWT actually is
&lt;/h2&gt;

&lt;p&gt;A JSON Web Token (defined in &lt;a href="https://datatracker.ietf.org/doc/html/rfc7519" rel="noopener noreferrer"&gt;RFC 7519&lt;/a&gt;) is three parts joined by dots:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;header.payload.signature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the demo token we'll use in this post. It was signed with the HS256 secret &lt;code&gt;demo-secret-not-real&lt;/code&gt;, so it's safe to paste anywhere:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzg0MjEiLCJuYW1lIjoiQXNoYSBEZW1vIiwicm9sZSI6ImVkaXRvciIsImlhdCI6MTc5NTE2NTIwMCwiZXhwIjoxNzk1MTY4ODAwfQ.QIFnuakPNSLDZM2JAkJ6eikvtCzLnzSFBPkWbsNijD0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqclq0ttojezjm3pdcjpd.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqclq0ttojezjm3pdcjpd.webp" alt="A JWT split into its three parts: header and payload decode to JSON, the signature can only be verified" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Header&lt;/strong&gt;: which algorithm signed the token (&lt;code&gt;alg&lt;/code&gt;) and its type (&lt;code&gt;typ&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Payload&lt;/strong&gt;: the claims, such as who the user is and when the token expires.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signature&lt;/strong&gt;: a hash of the first two parts made with a secret or private key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The header and payload are only &lt;em&gt;encoded&lt;/em&gt;, not encrypted. Anyone who has the token can read them. That's also why you should never put passwords, API keys or personal data in a JWT payload.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decode a JWT by hand
&lt;/h2&gt;

&lt;p&gt;Base64URL is normal Base64 with small changes: &lt;code&gt;+&lt;/code&gt; becomes &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt; becomes &lt;code&gt;_&lt;/code&gt;, and the &lt;code&gt;=&lt;/code&gt; padding is dropped. So decoding is: swap the characters back, add the padding, then Base64-decode.&lt;/p&gt;

&lt;h3&gt;
  
  
  In the browser console (JavaScript)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;decodeJwt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;b64&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/-/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'+'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;padded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b64&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'='&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;atob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;padded&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;charCodeAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TextDecoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;decodeJwt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIi...'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;TextDecoder&lt;/code&gt; step matters. &lt;code&gt;atob()&lt;/code&gt; returns raw bytes as a string, so a name like "José" or any emoji in the payload breaks without it.&lt;/p&gt;

&lt;h3&gt;
  
  
  In Node.js
&lt;/h3&gt;

&lt;p&gt;Node understands Base64URL directly, so it's shorter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'base64url'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'base64url'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  In the terminal (Python)
&lt;/h3&gt;

&lt;p&gt;The classic &lt;code&gt;cut | base64 -d&lt;/code&gt; trick often fails with &lt;code&gt;invalid input&lt;/code&gt;, because the padding is missing. Python handles it cleanly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 -c &lt;span class="s2"&gt;"import sys,base64,json; p=sys.argv[1].split('.')[1]; print(json.dumps(json.loads(base64.urlsafe_b64decode(p+'='*(-len(p)%4))),indent=2))"&lt;/span&gt; &lt;span class="s2"&gt;"$TOKEN"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All three give you the same payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user_8421"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Asha Demo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"editor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"iat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1795165200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1795168800&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reading the claims
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sub&lt;/code&gt; is the subject, usually a user ID.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;iat&lt;/code&gt; (issued at) and &lt;code&gt;exp&lt;/code&gt; (expires) are &lt;strong&gt;NumericDate&lt;/strong&gt; values: seconds since 1 January 1970 UTC, not milliseconds. In JavaScript that means &lt;code&gt;new Date(exp * 1000)&lt;/code&gt;. Here, &lt;code&gt;iat&lt;/code&gt; is 20 Nov 2026, 09:00 UTC and &lt;code&gt;exp&lt;/code&gt; is exactly one hour later. If you need to check a date quickly, a &lt;a href="https://mytoolstudio.com/tools/developer/timestamp-converter/?utm_source=devto&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;Unix timestamp converter&lt;/a&gt; does it in a second.&lt;/li&gt;
&lt;li&gt;Anything else, like &lt;code&gt;role&lt;/code&gt; here, is a custom claim your issuer added.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A surprising number of "random 401" bugs are just an &lt;code&gt;exp&lt;/code&gt; in the past, or a server clock that's a few minutes off.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decoding is not verifying
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7r4o0bst6zckk3dvrvxe.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7r4o0bst6zckk3dvrvxe.webp" alt="Decoding vs verifying a JWT: decoding needs no key, verifying needs the secret or public key" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the part that bites people. Decoding tells you what a token &lt;em&gt;says&lt;/em&gt;. It doesn't tell you whether it's &lt;em&gt;true&lt;/em&gt;. Anyone can build a token with &lt;code&gt;"role": "admin"&lt;/code&gt; and encode it. Only the signature proves it came from your issuer and wasn't changed.&lt;/p&gt;

&lt;p&gt;To verify, you need the key:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HS256 / HS384 / HS512&lt;/strong&gt;: the same shared secret the issuer used.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RS256, PS256, ES256, EdDSA&lt;/strong&gt;: the issuer's public key, often published as a JWKS (JSON Web Key Set) at a URL like &lt;code&gt;/.well-known/jwks.json&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your backend should verify with a proper library, and also check &lt;code&gt;exp&lt;/code&gt;, &lt;code&gt;nbf&lt;/code&gt;, &lt;code&gt;iss&lt;/code&gt; and &lt;code&gt;aud&lt;/code&gt;. And never accept a token whose header says &lt;code&gt;"alg": "none"&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The faster way: decode and verify in your browser
&lt;/h2&gt;

&lt;p&gt;If you'd rather not keep a snippet around, we built a &lt;a href="https://mytoolstudio.com/tools/developer/jwt-decoder/?utm_source=devto&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;JWT decoder&lt;/a&gt; into MyToolStudio, our collection of free browser tools.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc9c701xds4d7e6iwq8ti.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc9c701xds4d7e6iwq8ti.webp" alt="MyToolStudio JWT Decoder showing the demo token with Signature verified" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Paste a token and it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;colours the header, payload and signature so you can see where each part starts,&lt;/li&gt;
&lt;li&gt;shows the decoded JSON and a "Claims explained" table, with &lt;code&gt;iat&lt;/code&gt;, &lt;code&gt;nbf&lt;/code&gt; and &lt;code&gt;exp&lt;/code&gt; turned into readable dates,&lt;/li&gt;
&lt;li&gt;verifies the signature when you paste the secret (HS) or a public key, PEM certificate, JWK or JWKS (RS, PS, ES and EdDSA),&lt;/li&gt;
&lt;li&gt;lets you build and sign test tokens in the "Encode and sign" tab.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Verification uses the browser's Web Crypto API, so the token and key are never sent anywhere. That's the whole point. It's free and there's no sign-up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Treating a decoded token as trusted.&lt;/strong&gt; Always verify the signature on the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using &lt;code&gt;atob()&lt;/code&gt; alone.&lt;/strong&gt; It breaks on non-ASCII characters and on missing padding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reading &lt;code&gt;exp&lt;/code&gt; as milliseconds.&lt;/strong&gt; It's seconds. &lt;code&gt;Date.now() / 1000&lt;/code&gt; is the value to compare.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storing secrets in the payload.&lt;/strong&gt; The payload is public to anyone holding the token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pasting production tokens into unknown sites.&lt;/strong&gt; Use a local snippet or a tool that runs fully in your browser.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Can I decode a JWT without the secret?&lt;/strong&gt;&lt;br&gt;
Yes. The header and payload are Base64URL-encoded JSON, so no key is needed to read them. You only need the secret or public key to &lt;em&gt;verify&lt;/em&gt; the signature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is it safe to paste a JWT into an online decoder?&lt;/strong&gt;&lt;br&gt;
Only if the tool runs in your browser and doesn't send the token to a server. If you're not sure, use one of the snippets above. Never paste a production token into a site you don't trust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why does my token decode but my API still rejects it?&lt;/strong&gt;&lt;br&gt;
Usually it's an expired &lt;code&gt;exp&lt;/code&gt;, a wrong &lt;code&gt;aud&lt;/code&gt; or &lt;code&gt;iss&lt;/code&gt;, a clock difference between servers, or a signature made with a different key. Decoding shows the first three; verifying with the right key shows the last one.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;More free developer tools we use every day: &lt;a href="https://mytoolstudio.com/tools/developer/base64-encoder-decoder/?utm_source=devto&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;Base64 encoder and decoder&lt;/a&gt;, &lt;a href="https://mytoolstudio.com/tools/developer/json-formatter/?utm_source=devto&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;JSON formatter&lt;/a&gt;, and the full list of &lt;a href="https://mytoolstudio.com/tools/?utm_source=devto&amp;amp;utm_medium=article" rel="noopener noreferrer"&gt;300+ free tools on MyToolStudio&lt;/a&gt;. Further reading: &lt;a href="https://datatracker.ietf.org/doc/html/rfc7519" rel="noopener noreferrer"&gt;RFC 7519&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Base64" rel="noopener noreferrer"&gt;MDN on Base64&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>security</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
