<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[MyToolStudio Blog]]></title><description><![CDATA[MyToolStudio Blog]]></description><link>https://mytoolstudio.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 24 Nov 2026 12:05:26 GMT</lastBuildDate><atom:link href="https://mytoolstudio.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Check Color Contrast for Accessibility (WCAG AA)]]></title><description><![CDATA[Check color contrast for accessibility: WCAG ratios, the formula, Chrome DevTools, opacity and large text, plus a free contrast checker.]]></description><link>https://mytoolstudio.hashnode.dev/how-to-check-color-contrast-for-accessibility</link><guid isPermaLink="true">https://mytoolstudio.hashnode.dev/how-to-check-color-contrast-for-accessibility</guid><category><![CDATA[Accessibility]]></category><category><![CDATA[CSS]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Web Design]]></category><dc:creator><![CDATA[My Tool Studio]]></dc:creator><pubDate>Tue, 24 Nov 2026 07:50:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/dbb39312-6714-46fd-91f4-d4a31c450718.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You pick a nice grey for body text, it looks fine on your monitor, and an audit later flags every paragraph on the site. If you want to know how to check color contrast for accessibility before that happens, the good news is that it is one formula and a few rules. The bad news is that most mistakes happen in the rules, not the formula.</p>
<p>This guide shows the WCAG numbers, how to calculate a ratio yourself, how to check it in Chrome DevTools, and the traps that make a "passing" pair fail.</p>
<h2>Why color contrast matters</h2>
<p>Low contrast text is hard to read for people with low vision or colour vision deficiencies, and for everyone reading a phone in sunlight. It is also the most common accessibility failure on the web. Chrome's own DevTools documentation calls low contrast text "the top accessibility issue on the web", citing WebAIM's Million report.</p>
<p>WCAG covers it in Success Criterion 1.4.3 (Contrast Minimum), which is the level AA requirement most laws and policies point to.</p>
<h2>The WCAG contrast ratios you need to know</h2>
<table>
<thead>
<tr>
<th>What you are checking</th>
<th>AA</th>
<th>AAA</th>
</tr>
</thead>
<tbody><tr>
<td>Normal text</td>
<td>4.5:1</td>
<td>7:1</td>
</tr>
<tr>
<td>Large text (18pt / 24px, or 14pt / about 18.66px bold)</td>
<td>3:1</td>
<td>4.5:1</td>
</tr>
<tr>
<td>UI components and meaningful graphics (SC 1.4.11)</td>
<td>3:1</td>
<td>none</td>
</tr>
</tbody></table>
<p>Two exceptions are easy to miss. Text in a disabled control, pure decoration, or text that is part of a logo has no contrast requirement. Everything else does, including placeholder text, captions and the small print under a form.</p>
<h2>How to check color contrast by hand</h2>
<p>The ratio compares the relative luminance of the two colours: <code>(L1 + 0.05) / (L2 + 0.05)</code>, where L1 is the lighter colour. Luminance comes from the sRGB channels after you convert them to linear light, as defined in the <a href="https://www.w3.org/WAI/GL/wiki/Relative_luminance">W3C relative luminance definition</a>.</p>
<p>Here is the whole thing in Python, no libraries:</p>
<pre><code class="language-python">def lin(c):
    c = c / 255
    return c / 12.92 if c &lt;= 0.04045 else ((c + 0.055) / 1.055) ** 2.4

def luminance(hex_color):
    h = hex_color.lstrip("#")
    r, g, b = (int(h[i:i+2], 16) for i in (0, 2, 4))
    return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b)

def ratio(fg, bg):
    l1, l2 = sorted((luminance(fg), luminance(bg)), reverse=True)
    return (l1 + 0.05) / (l2 + 0.05)

for fg, bg in [("#767676", "#ffffff"), ("#777777", "#ffffff"),
               ("#ffffff", "#3b82f6"), ("#ffffff", "#2563eb")]:
    print(f"{fg} on {bg}: {ratio(fg, bg):.4f}:1")
</code></pre>
<p>We ran it, and this is the output:</p>
<pre><code class="language-text">#767676 on #ffffff: 4.5422:1
#777777 on #ffffff: 4.4781:1
#ffffff on #3b82f6: 3.6779:1
#ffffff on #2563eb: 5.1686:1
</code></pre>
<p>Look at the first two lines. <code>#767676</code> and <code>#777777</code> are one step apart, and they land on opposite sides of 4.5:1. The W3C Understanding document is explicit that the ratios are thresholds and must not be rounded: 4.499:1 does not meet 4.5:1. So a tool that shows "4.5" for <code>#777777</code> and a green tick is giving you the wrong answer.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/518de97c-6741-41a2-92df-6eb31db47d68.png" alt="A ruler from 2.5:1 to 7.5:1 with the 3:1, 4.5:1 and 7:1 thresholds marked, and four example pairs plotted: 3.68, 3.95, 4.48 and 5.17" style="display:block;margin:0 auto" />

<p>The third line is a very common case: white text on a mid blue button (<code>#3b82f6</code>, the Tailwind blue-500). At 3.68:1 it fails for normal text but passes for large text and for the button's outline as a UI component. Moving one shade darker to <code>#2563eb</code> gets you to 5.17:1 and the problem is gone.</p>
<h2>How to check color contrast in Chrome DevTools</h2>
<p>You do not need an extension for a quick check:</p>
<ol>
<li>Right-click the text and choose <strong>Inspect</strong>.</li>
<li>Hover the element with the inspect tool. The tooltip shows a <strong>Contrast</strong> value, with a warning sign if it is too low.</li>
<li>In the <strong>Styles</strong> pane, click the colour swatch next to <code>color</code>. The colour picker has a <strong>Contrast ratio</strong> section that shows the AA and AAA lines and can suggest a passing colour.</li>
</ol>
<p>For a whole page, the Lighthouse accessibility audit and the CSS Overview panel list every low contrast element. The <a href="https://developer.chrome.com/docs/devtools/accessibility/contrast">Chrome DevTools contrast guide</a> walks through each of these.</p>
<h2>Check it with a free contrast checker</h2>
<p>When you are choosing colours rather than auditing a live page, a dedicated checker is faster. We built MyToolStudio, and its <a href="https://mytoolstudio.com/tools/wcag/color-contrast-checker/?utm_source=hashnode&amp;utm_medium=article">free WCAG color contrast checker</a> runs in your browser with no sign up.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/88b2a4ce-63e9-41fd-88cf-ac45c9820311.png" alt="The MyToolStudio color contrast checker showing white text on #3b82f6 at 3.68:1, failing AA for normal text and passing for large text and UI components" style="display:block;margin:0 auto" />

<p>We put the failing button pair from above into it: text <code>#ffffff</code>, background <code>#3b82f6</code>. It reports 3.68:1, the same number as the script, with AA normal text marked as a fail and large text and UI components as a pass. A few things that save time:</p>
<ul>
<li><strong>Font size and bold controls.</strong> Set the real size of your text and the tool tells you whether it counts as normal or large, so you know which threshold applies.</li>
<li><strong>Opacity.</strong> Semi-transparent text is measured as it actually appears on the background (more on that below).</li>
<li><strong>Suggested fixes.</strong> For our pair it offered <code>#0d70e1</code> as a background that keeps white text and reaches 4.75:1.</li>
<li><strong>Contrast grid.</strong> Paste up to 12 colours and every text and background pair is checked at once, which is handy for a whole palette.</li>
</ul>
<p>If a palette fails everywhere, the <a href="https://mytoolstudio.com/tools/wcag/accessible-color-palette-generator/?utm_source=hashnode&amp;utm_medium=article">accessible color palette generator</a> starts from passing pairs, and the <a href="https://mytoolstudio.com/tools/wcag/color-blindness-simulator/?utm_source=hashnode&amp;utm_medium=article">color blindness simulator</a> shows how the result looks with different types of colour vision.</p>
<h2>Common mistakes when checking contrast</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/9c98f069-3821-4c81-b6a8-987242fd2350.png" alt="White text on #3b82f6 at three sizes: 16px regular fails, 18.66px bold and 24px regular pass because they count as large text" style="display:block;margin:0 auto" />

<p><strong>Rounding up.</strong> Covered above, and worth repeating: 4.48:1 is a fail.</p>
<p><strong>Ignoring opacity.</strong> <code>color: rgba(0, 0, 0, 0.5)</code> on white looks like a dark grey in your CSS, but on screen it blends to roughly <code>#808080</code>. Our script gives 3.95:1 after rounding the blended channel, and the checker reports 3.98:1 because it does not round it first. Either way it fails for normal text. Always measure the blended colour, not the CSS value.</p>
<p><strong>Testing one state only.</strong> Hover, focus, visited and disabled styles all have their own colours. A link can pass at rest and fail on hover. Placeholder text is not exempt either.</p>
<p><strong>Text over images and gradients.</strong> One check against the "average" colour proves nothing. W3C lists this as a known failure (F83). Check the lightest part of the image behind the text, or add a solid or semi-opaque layer under it.</p>
<p><strong>Treating large text as "anything that looks big".</strong> Large means at least 24px regular or about 18.66px bold. A 20px regular heading is still normal text and needs 4.5:1.</p>
<h2>FAQ</h2>
<p><strong>What is a good color contrast ratio?</strong> For WCAG AA, at least 4.5:1 for normal text and 3:1 for large text and UI parts. If you can reach 7:1 for body text, you also meet AAA.</p>
<p><strong>Does WCAG 2.2 change the contrast rules?</strong> No. WCAG 2.2 keeps 1.4.3, 1.4.6 and 1.4.11 the same as 2.1. APCA, the new contrast method for WCAG 3, is still a draft, so treat its Lc score as extra information and keep using the 2.x ratios for compliance.</p>
<p><strong>Do logos and disabled buttons need to meet contrast?</strong> No. Text that is part of a logo, pure decoration, and inactive controls are exempt from 1.4.3. Everything a user needs to read or operate is not.</p>
<h2>Wrapping up</h2>
<p>Checking contrast is quick once you know the rules: use the real blended colours, match the threshold to the text size, check every state, and never round up. If you are working through other web checks, our earlier guides on <a href="https://mytoolstudio.hashnode.dev/how-to-test-a-robots-txt-file">testing a robots.txt file</a> and <a href="https://mytoolstudio.hashnode.dev/how-to-decode-a-jwt-without-pasting-it-into-a-random-website">decoding a JWT safely</a> follow the same hands-on approach.</p>
<p>You can find the rest of our free developer, SEO and accessibility utilities on the <a href="https://mytoolstudio.com/tools/?utm_source=hashnode&amp;utm_medium=article">MyToolStudio tools page</a>. For the official wording of the criterion, read the <a href="https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html">W3C Understanding page for SC 1.4.3</a>.</p>
<h3>More from this series</h3>
<ul>
<li><a href="https://mytoolstudio.hashnode.dev/how-to-decode-a-jwt-without-pasting-it-into-a-random-website">How to Decode a JWT Without Pasting It Into a Random Website</a></li>
<li><a href="https://mytoolstudio.hashnode.dev/how-to-test-a-robots-txt-file">How to Test a robots.txt File (and Why Your Tester Might Be Wrong)</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to Test a robots.txt File (and Why Your Tester Might Be Wrong)]]></title><description><![CDATA[Google reads robots.txt by the longest matching rule. Test yours the right way: real file, status checks, a Python gotcha and a free tester.]]></description><link>https://mytoolstudio.hashnode.dev/how-to-test-a-robots-txt-file</link><guid isPermaLink="true">https://mytoolstudio.hashnode.dev/how-to-test-a-robots-txt-file</guid><category><![CDATA[SEO]]></category><category><![CDATA[SEO for Developers]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Python]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[My Tool Studio]]></dc:creator><pubDate>Mon, 23 Nov 2026 07:12:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/b9de2393-690b-494a-8705-e232df5f06e2.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You add one line to robots.txt, push it, and two days later Search Console says half your product pages are "Blocked by robots.txt". Or the opposite: you meant to keep a folder out of Google and it is still being crawled.</p>
<p>Both come from the same habit: reading robots.txt top to bottom like code. Crawlers don't read it that way. This guide shows how to test a robots.txt file the way Google actually applies it, with a real file you can copy, a quick script, and a free tester.</p>
<p>We built MyToolStudio, a set of free browser tools, and robots.txt questions come up a lot. Last time in this series we looked at <a href="https://mytoolstudio.hashnode.dev/how-to-decode-a-jwt-without-pasting-it-into-a-random-website">decoding a JWT without pasting it into a random website</a>. This one is for the SEO side of the team.</p>
<h2>Why testing robots.txt matters</h2>
<p>robots.txt controls <strong>crawling</strong>, not indexing. A wrong <code>Disallow</code> can stop Google from fetching pages you need, and a wrong <code>Allow</code> can let crawlers waste time on endless filter URLs.</p>
<p>A few facts from Google's own documentation that change how you test:</p>
<ul>
<li>Google generally caches robots.txt for up to 24 hours, so a fix is not seen instantly.</li>
<li>Google ignores anything after the first 500 KiB of the file.</li>
<li>If robots.txt returns a 4xx error (except 429), Google acts as if there are no restrictions at all.</li>
<li>If it returns a 5xx error, Google stops crawling the site for the first 12 hours.</li>
</ul>
<p>So testing is not only "is this URL allowed". It is also "can Google fetch the file, and what status code does it get".</p>
<h2>The rule most testers skip: the longest match wins</h2>
<p>Here is a small file for an online store:</p>
<pre><code class="language-txt">User-agent: *
Disallow: /shop/
Allow: /shop/products/
Disallow: /*?sort=
Disallow: /*.pdf$

User-agent: GPTBot
Disallow: /

Sitemap: https://example.com/sitemap.xml
</code></pre>
<p>Read top to bottom, <code>/shop/products/blue-mug</code> looks blocked, because <code>Disallow: /shop/</code> comes first. But Google uses the <strong>most specific rule, based on the length of the rule path</strong>. <code>Allow: /shop/products/</code> is longer than <code>Disallow: /shop/</code>, so the product page is allowed. When an Allow and a Disallow rule are equally specific, Google uses the least restrictive one, which is the Allow. The same logic is written into RFC 9309, the robots.txt standard.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/44f4c7bb-e9a5-4749-b23e-6d571d3f5dc4.webp" alt="Diagram showing that the longest matching robots.txt rule decides the result" style="display:block;margin:0 auto" />

<p>Two more things in that file:</p>
<ul>
<li><code>*</code> matches any run of characters, so <code>Disallow: /*?sort=</code> blocks every URL with a <code>?sort=</code> parameter.</li>
<li><code>$</code> anchors the end of the URL. <code>Disallow: /*.pdf$</code> blocks <code>/files/guide.pdf</code> but <strong>not</strong> <code>/files/guide.pdf?v=2</code>, because that URL doesn't end in <code>.pdf</code>.</li>
</ul>
<p>And groups: a crawler follows only the one group that names it most specifically. GPTBot matches <code>User-agent: GPTBot</code>, so it ignores the <code>*</code> group completely and is blocked everywhere.</p>
<h2>How to test robots.txt by hand</h2>
<h3>1. Check the file Google can actually fetch</h3>
<p>Open <code>https://yoursite.com/robots.txt</code> in a browser, then check the status code from the command line:</p>
<pre><code class="language-bash">curl -s -o /dev/null -w "%{http_code}\n" https://example.com/robots.txt
</code></pre>
<p>You want <code>200</code>. A <code>403</code> from a firewall or a <code>503</code> from a busy server changes how Google treats the whole site. Note that a CDN or bot-protection rule may treat Google's IP addresses differently from your laptop, so a 200 here is a good sign, not proof.</p>
<h3>2. Check what Google saw</h3>
<p>In Search Console, the <strong>robots.txt report</strong> (under Settings) lists the robots.txt files Google found for the top 20 hosts on your site, when each was last crawled, and any warnings or errors. You can also request a recrawl after a fix. It only works for domain-level properties, so a URL-prefix property with a path won't show it.</p>
<h3>3. Test the rules with a script (carefully)</h3>
<p>Python ships with <code>urllib.robotparser</code>, which looks like the perfect quick check:</p>
<pre><code class="language-python">import urllib.robotparser as rp

robots = open("robots.txt").read().splitlines()
r = rp.RobotFileParser()
r.parse(robots)

tests = [
    ("Googlebot", "/shop/products/blue-mug"),
    ("Googlebot", "/shop/cart"),
    ("Googlebot", "/blog/post?sort=new"),
    ("Googlebot", "/files/guide.pdf"),
    ("Googlebot", "/files/guide.pdf?v=2"),
    ("GPTBot", "/blog/"),
]
for ua, path in tests:
    ok = r.can_fetch(ua, "https://example.com" + path)
    print(f"{ua:10} {path:28} {'allowed' if ok else 'BLOCKED'}")
</code></pre>
<p>We ran this exact script on three Python versions with the file above. Python 3.13.18 matched Google's rules on all six URLs. Python 3.11.18 and 3.12.3 got <strong>three of the six wrong</strong>: they reported the product page as blocked (first match instead of longest match) and treated <code>*</code> and <code>$</code> literally, so the <code>?sort=</code> URL and the PDF came back as allowed.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/857325f1-7a09-488a-a3e0-8db0df555067.webp" alt="Python 3.11 and 3.12 robotparser results compared with Google's rules" style="display:block;margin:0 auto" />

<p>The lesson: a script is only as good as its parser. If you script robots.txt checks, check your Python version first, or compare against a tester that follows Google's precedence rules.</p>
<h2>Test robots.txt with a free tool</h2>
<p>We built the <a href="https://mytoolstudio.com/tools/seo/robots-txt-tester/?utm_source=hashnode&amp;utm_medium=article">robots.txt tester</a> for exactly this. You can fetch a live file from any site or paste a draft you haven't uploaded yet, list up to 100 URLs or paths, and tick the crawlers you care about, from Googlebot and Bingbot to AI crawlers like GPTBot, ClaudeBot and PerplexityBot.</p>
<p>We pasted the file above, added the six paths and ticked Googlebot and GPTBot. Each result shows Allowed or Blocked plus the exact line that decided it:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/cd903474-da93-4387-98f6-91de9686d78b.webp" alt="MyToolStudio robots.txt tester showing Googlebot and GPTBot results with the deciding rule for each URL" style="display:block;margin:0 auto" />

<p><code>/shop/products/blue-mug</code> is allowed for Googlebot by <code>Allow: /shop/products/ (line 3)</code>, <code>/files/guide.pdf?v=2</code> shows "No rule matches", and GPTBot is blocked on every path by line 8. You can also download the results as CSV, which helps when you check a long list of URLs from a crawl.</p>
<p>If you are writing a new file, the <a href="https://mytoolstudio.com/tools/seo/robots-txt-generator/?utm_source=hashnode&amp;utm_medium=article">robots.txt generator</a> gives you a clean starting point, and since your <code>Sitemap:</code> line should point to a working file, run it through the <a href="https://mytoolstudio.com/tools/seo/xml-sitemap-validator/?utm_source=hashnode&amp;utm_medium=article">XML sitemap validator</a> too.</p>
<h2>Common robots.txt mistakes</h2>
<ul>
<li><strong>Using Disallow to hide a page from Google.</strong> Disallow stops crawling, not indexing. A blocked URL can still appear in results if other pages link to it. Use <code>noindex</code> on a page Google is allowed to crawl.</li>
<li><strong>Blocking CSS and JavaScript.</strong> Google renders pages. If <code>/assets/</code> is blocked, it may not see your layout or content.</li>
<li><strong>Forgetting the trailing slash.</strong> <code>Disallow: /blog</code> also blocks <code>/blog-tips</code> and <code>/blogger.html</code>. Use <code>Disallow: /blog/</code> if you mean the folder.</li>
<li><strong>Expecting a</strong> <code>*</code> <strong>group to cover every bot.</strong> A crawler with its own group ignores the <code>*</code> group, so repeat any shared rules inside that group.</li>
<li><strong>Leaving staging rules in production.</strong> A <code>Disallow: /</code> copied from a staging site is still one of the most painful mistakes to find.</li>
<li><strong>Testing once and forgetting.</strong> Plugins, CDNs and migrations change robots.txt. Re-test after every big release.</li>
</ul>
<h2>FAQ</h2>
<h3>How do I test a robots.txt file?</h3>
<p>Check that <code>/robots.txt</code> returns a 200 status, look at the robots.txt report in Search Console to see what Google fetched, then test your important URLs against the rules with a tester that uses the longest-match rule, such as our free robots.txt tester.</p>
<h3>Does robots.txt stop a page from being indexed?</h3>
<p>No. It stops crawling. A disallowed page can still be indexed from links, usually without a description. To keep a page out of results, allow crawling and add a <code>noindex</code> meta tag or header.</p>
<h3>How long does Google take to see robots.txt changes?</h3>
<p>Google generally caches robots.txt for up to 24 hours. After a fix, you can request a recrawl from the robots.txt report in Search Console.</p>
<h2>Wrap-up</h2>
<p>Test robots.txt the way crawlers read it: longest match wins, ties go to Allow, <code>*</code> and <code>$</code> are patterns, and each bot follows only its own group. Check the status code, check what Google saw, and test real URLs, not just the file.</p>
<p>All our free SEO, developer and design tools are on the <a href="https://mytoolstudio.com/tools/?utm_source=hashnode&amp;utm_medium=article">MyToolStudio tools page</a>. No sign-up.</p>
<p><strong>References:</strong> <a href="https://developers.google.com/crawling/docs/robots-txt/robots-txt-spec">How Google interprets the robots.txt specification</a> · <a href="https://www.rfc-editor.org/rfc/rfc9309">RFC 9309: Robots Exclusion Protocol</a> · <a href="https://support.google.com/webmasters/answer/6062598">robots.txt report, Search Console Help</a></p>
<p><strong>Next in this series:</strong> <a href="https://mytoolstudio.hashnode.dev/how-to-check-color-contrast-for-accessibility">How to Check Color Contrast for Accessibility (WCAG AA)</a></p>
]]></content:encoded></item><item><title><![CDATA[How to Decode a JWT Without Pasting It Into a Random Website]]></title><description><![CDATA[Decode a JWT header and payload in one line of JavaScript, Node or Python, learn why decoding is not verifying, and check signatures in your browser.]]></description><link>https://mytoolstudio.hashnode.dev/how-to-decode-a-jwt-without-pasting-it-into-a-random-website</link><guid isPermaLink="true">https://mytoolstudio.hashnode.dev/how-to-decode-a-jwt-without-pasting-it-into-a-random-website</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[JWT]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Security]]></category><category><![CDATA[authentication]]></category><dc:creator><![CDATA[My Tool Studio]]></dc:creator><pubDate>Fri, 20 Nov 2026 15:21:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/ccfe43c7-76b0-46d6-b731-7eb3dade6b81.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You're debugging a login bug. The API returns <code>401</code>, and all you have is a long string that starts with <code>eyJ</code>. The fastest move is to paste it into the first "JWT decoder" Google shows you.</p>
<p>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.</p>
<p>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.</p>
<p>This guide shows how to do it by hand, what the claims mean, and why "it decodes" never means "it's valid".</p>
<h2>What a JWT actually is</h2>
<p>A JSON Web Token (defined in <a href="https://datatracker.ietf.org/doc/html/rfc7519">RFC 7519</a>) is three parts joined by dots:</p>
<pre><code class="language-text">header.payload.signature
</code></pre>
<p>Here's the demo token we'll use in this post. It was signed with the HS256 secret <code>demo-secret-not-real</code>, so it's safe to paste anywhere:</p>
<pre><code class="language-text">eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzg0MjEiLCJuYW1lIjoiQXNoYSBEZW1vIiwicm9sZSI6ImVkaXRvciIsImlhdCI6MTc5NTE2NTIwMCwiZXhwIjoxNzk1MTY4ODAwfQ.QIFnuakPNSLDZM2JAkJ6eikvtCzLnzSFBPkWbsNijD0
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/8a49ff96-5b0a-4152-a44e-d9c984a3c639.webp" alt="A JWT split into its three parts: header and payload decode to JSON, the signature can only be verified" style="display:block;margin:0 auto" />

<ul>
<li><strong>Header</strong>: which algorithm signed the token (<code>alg</code>) and its type (<code>typ</code>).</li>
<li><strong>Payload</strong>: the claims, such as who the user is and when the token expires.</li>
<li><strong>Signature</strong>: a hash of the first two parts made with a secret or private key.</li>
</ul>
<p>The header and payload are only <em>encoded</em>, 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.</p>
<h2>Decode a JWT by hand</h2>
<p>Base64URL is normal Base64 with small changes: <code>+</code> becomes <code>-</code>, <code>/</code> becomes <code>_</code>, and the <code>=</code> padding is dropped. So decoding is: swap the characters back, add the padding, then Base64-decode.</p>
<h3>In the browser console (JavaScript)</h3>
<pre><code class="language-js">function decodeJwt(token) {
  const [header, payload] = token.split('.').slice(0, 2).map((part) =&gt; {
    const b64 = part.replace(/-/g, '+').replace(/_/g, '/');
    const padded = b64 + '='.repeat((4 - (b64.length % 4)) % 4);
    const bytes = Uint8Array.from(atob(padded), (c) =&gt; c.charCodeAt(0));
    return JSON.parse(new TextDecoder().decode(bytes));
  });
  return { header, payload };
}

decodeJwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIi...');
</code></pre>
<p>The <code>TextDecoder</code> step matters. <code>atob()</code> returns raw bytes as a string, so a name like "José" or any emoji in the payload breaks without it.</p>
<h3>In Node.js</h3>
<p>Node understands Base64URL directly, so it's shorter:</p>
<pre><code class="language-js">const [h, p] = token.split('.');
console.log(JSON.parse(Buffer.from(h, 'base64url').toString()));
console.log(JSON.parse(Buffer.from(p, 'base64url').toString()));
</code></pre>
<h3>In the terminal (Python)</h3>
<p>The classic <code>cut | base64 -d</code> trick often fails with <code>invalid input</code>, because the padding is missing. Python handles it cleanly:</p>
<pre><code class="language-bash">python3 -c "import sys,base64,json; p=sys.argv[1].split('.')[1]; print(json.dumps(json.loads(base64.urlsafe_b64decode(p+'='*(-len(p)%4))),indent=2))" "$TOKEN"
</code></pre>
<p>All three give you the same payload:</p>
<pre><code class="language-json">{
  "sub": "user_8421",
  "name": "Asha Demo",
  "role": "editor",
  "iat": 1795165200,
  "exp": 1795168800
}
</code></pre>
<h2>Reading the claims</h2>
<ul>
<li><code>sub</code> is the subject, usually a user ID.</li>
<li><code>iat</code> (issued at) and <code>exp</code> (expires) are <strong>NumericDate</strong> values: seconds since 1 January 1970 UTC, not milliseconds. In JavaScript that means <code>new Date(exp * 1000)</code>. Here, <code>iat</code> is 20 Nov 2026, 09:00 UTC and <code>exp</code> is exactly one hour later. If you need to check a date quickly, a <a href="https://mytoolstudio.com/tools/developer/timestamp-converter/?utm_source=hashnode&amp;utm_medium=article">Unix timestamp converter</a> does it in a second.</li>
<li>Anything else, like <code>role</code> here, is a custom claim your issuer added.</li>
</ul>
<p>A surprising number of "random 401" bugs are just an <code>exp</code> in the past, or a server clock that's a few minutes off.</p>
<h2>Decoding is not verifying</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/b2e71272-83d5-44c1-bb36-a3f71d0bce68.webp" alt="Decoding vs verifying a JWT: decoding needs no key, verifying needs the secret or public key" style="display:block;margin:0 auto" />

<p>This is the part that bites people. Decoding tells you what a token <em>says</em>. It doesn't tell you whether it's <em>true</em>. Anyone can build a token with <code>"role": "admin"</code> and encode it. Only the signature proves it came from your issuer and wasn't changed.</p>
<p>To verify, you need the key:</p>
<ul>
<li><strong>HS256 / HS384 / HS512</strong>: the same shared secret the issuer used.</li>
<li><strong>RS256, PS256, ES256, EdDSA</strong>: the issuer's public key, often published as a JWKS (JSON Web Key Set) at a URL like <code>/.well-known/jwks.json</code>.</li>
</ul>
<p>Your backend should verify with a proper library, and also check <code>exp</code>, <code>nbf</code>, <code>iss</code> and <code>aud</code>. And never accept a token whose header says <code>"alg": "none"</code>.</p>
<h2>The faster way: decode and verify in your browser</h2>
<p>If you'd rather not keep a snippet around, we built a <a href="https://mytoolstudio.com/tools/developer/jwt-decoder/?utm_source=hashnode&amp;utm_medium=article">JWT decoder</a> into MyToolStudio, our collection of free browser tools.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b006060be701d1d5eff7cd1/ce39f9c1-4c29-4a33-8daa-d3971ded7db2.webp" alt="MyToolStudio JWT Decoder showing the demo token with Signature verified" style="display:block;margin:0 auto" />

<p>Paste a token and it:</p>
<ul>
<li>colours the header, payload and signature so you can see where each part starts,</li>
<li>shows the decoded JSON and a "Claims explained" table, with <code>iat</code>, <code>nbf</code> and <code>exp</code> turned into readable dates,</li>
<li>verifies the signature when you paste the secret (HS) or a public key, PEM certificate, JWK or JWKS (RS, PS, ES and EdDSA),</li>
<li>lets you build and sign test tokens in the "Encode and sign" tab.</li>
</ul>
<p>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.</p>
<h2>Common mistakes</h2>
<ol>
<li><strong>Treating a decoded token as trusted.</strong> Always verify the signature on the server.</li>
<li><strong>Using</strong> <code>atob()</code> <strong>alone.</strong> It breaks on non-ASCII characters and on missing padding.</li>
<li><strong>Reading</strong> <code>exp</code> <strong>as milliseconds.</strong> It's seconds. <code>Date.now() / 1000</code> is the value to compare.</li>
<li><strong>Storing secrets in the payload.</strong> The payload is public to anyone holding the token.</li>
<li><strong>Pasting production tokens into unknown sites.</strong> Use a local snippet or a tool that runs fully in your browser.</li>
</ol>
<h2>FAQ</h2>
<p><strong>Can I decode a JWT without the secret?</strong> 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 <em>verify</em> the signature.</p>
<p><strong>Is it safe to paste a JWT into an online decoder?</strong> 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.</p>
<p><strong>Why does my token decode but my API still rejects it?</strong> Usually it's an expired <code>exp</code>, a wrong <code>aud</code> or <code>iss</code>, 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.</p>
<hr />
<p><em>More free developer tools we use every day:</em> <a href="https://mytoolstudio.com/tools/developer/base64-encoder-decoder/?utm_source=hashnode&amp;utm_medium=article"><em>Base64 encoder and decoder</em></a><em>,</em> <a href="https://mytoolstudio.com/tools/developer/json-formatter/?utm_source=hashnode&amp;utm_medium=article"><em>JSON formatter</em></a><em>, and the full list of</em> <a href="https://mytoolstudio.com/tools/?utm_source=hashnode&amp;utm_medium=article"><em>300+ free tools on MyToolStudio</em></a><em>. Further reading:</em> <a href="https://datatracker.ietf.org/doc/html/rfc7519"><em>RFC 7519</em></a> <em>and</em> <a href="https://developer.mozilla.org/en-US/docs/Glossary/Base64"><em>MDN on Base64</em></a><em>.</em></p>
<p>Next in this series: <a href="https://mytoolstudio.hashnode.dev/how-to-test-a-robots-txt-file">how to test a robots.txt file the way Google reads it</a>.</p>
]]></content:encoded></item></channel></rss>