Repository navigation
Expand file tree
/
Copy pathuser-agent-parser.html
More file actions
736 lines (688 loc) Β· 42.5 KB
/
Copy pathuser-agent-parser.html
File metadata and controls
736 lines (688 loc) Β· 42.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
<!DOCTYPE html>
<html lang="en">
<head>
<include src="_partials/meta-base.html"></include>
<title>User Agent Parser β HTML Tools</title>
<meta name="description" content="Paste a user-agent string and instantly see the browser, engine, OS, device type, and CPU architecture. Runs in your browser β no installs, no tracking.">
<link rel="canonical" href="https://tools.mazipan.space/user-agent-parser">
<meta property="og:title" content="User Agent Parser β HTML Tools">
<meta property="og:description" content="Paste a user-agent string and instantly see the browser, engine, OS, device type, and CPU architecture. Runs in your browser β no installs, no tracking.">
<meta property="og:url" content="https://tools.mazipan.space/user-agent-parser">
<meta name="twitter:title" content="User Agent Parser β HTML Tools">
<meta name="twitter:description" content="Paste a user-agent string and instantly see the browser, engine, OS, device type, and CPU architecture. Runs in your browser β no installs, no tracking.">
<include src="_partials/meta-social.html"></include>
<link rel="icon" type="image/png" sizes="32x32" href="favicon-user-agent-parser.png">
<include src="_partials/head-fonts.html"></include>
<link rel="stylesheet" href="styles.css">
<style>
/* Result card β two-column "label / value" rows. */
.ua-card {
border: 1px solid #1f2937;
background: #0b1220;
border-radius: 0.5rem;
overflow: hidden;
}
.ua-row {
display: grid;
grid-template-columns: 9rem 1fr;
gap: 1rem;
padding: 0.7rem 1rem;
border-bottom: 1px solid #1f2937;
align-items: baseline;
}
.ua-row:last-child { border-bottom: none; }
.ua-row .ua-label {
font-size: 0.7rem;
font-weight: 600;
color: #6b7280;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.ua-row .ua-value {
font-family: 'IBM Plex Mono', ui-monospace, monospace;
font-size: 0.9rem;
color: #e5e7eb;
word-break: break-word;
}
.ua-row .ua-icon { margin-right: 0.45rem; }
.ua-row .ua-sub { color: #9ca3af; font-size: 0.75rem; }
.ua-row.ua-raw .ua-value {
font-size: 0.7rem;
color: #9ca3af;
max-height: 5.5em;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
.ua-row .pill-tag {
display: inline-block;
font-family: 'IBM Plex Mono', ui-monospace, monospace;
font-size: 0.65rem;
padding: 0.05rem 0.4rem;
border-radius: 4px;
background: #1f2937;
color: #9ca3af;
margin-left: 0.4rem;
vertical-align: 0.05em;
}
@media (max-width: 540px) {
.ua-row { grid-template-columns: 1fr; gap: 0.2rem; padding: 0.6rem 0.85rem; }
}
</style>
<include src="_partials/head-theme.html"></include>
<!-- BEGIN:json-ld generated by scripts/generate-sections.mjs β re-run after editing tools.json -->
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebApplication","name":"User Agent Parser","url":"https://tools.mazipan.space/user-agent-parser","description":"Paste a user-agent string and instantly see the browser, engine, OS, device type, and CPU architecture. Runs in your browser β no installs, no tracking.","applicationCategory":"DeveloperApplication","operatingSystem":"Any","browserRequirements":"Requires JavaScript","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"isPartOf":{"@type":"WebSite","name":"HTML Tools","url":"https://tools.mazipan.space/"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"HTML Tools","item":"https://tools.mazipan.space/"},{"@type":"ListItem","position":2,"name":"User Agent Parser","item":"https://tools.mazipan.space/user-agent-parser"}]}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Where does the pre-filled UA string come from?","acceptedAnswer":{"@type":"Answer","text":"It's your own browser's navigator.userAgent β the exact value any website you visit would see. Edit it to test other UAs."}},{"@type":"Question","name":"Why does Chrome on iOS show up as CriOS / 'Chrome (iOS)'?","acceptedAnswer":{"@type":"Answer","text":"Apple requires every browser on iOS to use WebKit. CriOS / FxiOS / EdgiOS are the tokens Chrome / Firefox / Edge add on iOS so servers can still distinguish them, even though the engine is WebKit underneath."}},{"@type":"Question","name":"Can it tell Windows 10 apart from Windows 11?","acceptedAnswer":{"@type":"Answer","text":"Not reliably β Microsoft kept the UA at \"Windows NT 10.0\" for both. The tool shows \"Windows 10/11\" for that NT version. UA Client Hints (Sec-CH-UA-Platform-Version) can distinguish them, but those aren't present in a plain UA string."}},{"@type":"Question","name":"Is the parser 100% accurate?","acceptedAnswer":{"@type":"Answer","text":"UA strings are best-effort by design β browsers spoof each other for compatibility (Chrome includes 'Safari', Edge includes 'Chrome', etc.). The parser uses the priority order most servers do, but for high-stakes detection prefer UA Client Hints or feature detection."}},{"@type":"Question","name":"Does my UA string leave my computer?","acceptedAnswer":{"@type":"Answer","text":"No. Parsing happens entirely in your browser β the page is a single static HTML file with no network requests."}}]}</script>
<!-- END:json-ld -->
</head>
<body class="bg-gray-950 text-gray-200 min-h-screen flex flex-col">
<header class="border-b border-gray-800 px-6 py-4">
<nav aria-label="Breadcrumb" class="max-w-[1100px] mx-auto flex items-center gap-3">
<a href="index.html" class="no-underline text-white font-bold text-lg tracking-tight hover:text-blue-400 transition-colors">HTML Tools</a>
<span class="text-gray-700">/</span>
<span class="text-gray-400 text-sm flex items-center gap-1.5" aria-current="page">π΅οΈ User Agent Parser</span>
</nav>
</header>
<main class="max-w-[1100px] mx-auto w-full flex-1 py-8 px-6">
<header class="mb-7">
<h1 class="text-3xl font-bold text-white flex items-center gap-3">π΅οΈ User Agent Parser</h1>
<p class="mt-1.5 text-sm text-gray-500">Paste a user-agent string to see the browser, engine, OS, device type, and CPU architecture.</p>
</header>
<!-- Sample chips -->
<div class="flex flex-wrap items-center gap-1.5 mb-3">
<span class="text-xs text-gray-500 mr-1">Samples:</span>
<button class="chip" data-sample="chrome-win" onclick="loadSample('chrome-win')">π Chrome / Windows</button>
<button class="chip" data-sample="safari-mac" onclick="loadSample('safari-mac')">π§ Safari / macOS</button>
<button class="chip" data-sample="firefox-linux" onclick="loadSample('firefox-linux')">π¦ Firefox / Linux</button>
<button class="chip" data-sample="safari-ios" onclick="loadSample('safari-ios')">π± Safari / iOS</button>
<button class="chip" data-sample="chrome-android" onclick="loadSample('chrome-android')">π€ Chrome / Android</button>
<button class="chip" data-sample="edge-win" onclick="loadSample('edge-win')">π· Edge / Windows</button>
<button class="chip" data-sample="samsung" onclick="loadSample('samsung')">π£ Samsung Internet</button>
<button class="chip" data-sample="googlebot" onclick="loadSample('googlebot')">π€ Googlebot</button>
<button class="chip" data-sample="ie11" onclick="loadSample('ie11')">πͺ¦ IE 11</button>
</div>
<!-- Action row -->
<div class="flex flex-wrap items-center gap-2 mb-3">
<button class="btn btn-secondary" onclick="fillOwnUA()" title="Replace with your browser's own UA">π My UA</button>
<button class="btn btn-secondary" onclick="pasteUA()" title="Paste from clipboard">π Paste</button>
<button class="btn btn-secondary" onclick="clearUA()" title="Clear">ποΈ Clear</button>
</div>
<label for="ua-input" class="block text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1.5">User-agent string</label>
<textarea id="ua-input" class="textarea input-mono w-full" rows="3"
placeholder="Paste a user-agent string hereβ¦"
spellcheck="false" autocomplete="off" autocapitalize="off"></textarea>
<!-- Error / placeholder -->
<div id="ua-error" class="error-bar mt-4 hidden"></div>
<div id="ua-empty" class="text-sm text-gray-500 mt-6 hidden">Paste a user-agent string above or pick a sample to see the breakdown.</div>
<!-- Result card -->
<section id="ua-result" class="mt-6 hidden">
<h2 class="text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2">Breakdown</h2>
<div class="ua-card" id="ua-card"></div>
<details class="disclosure mt-4">
<summary>π Raw token list</summary>
<div class="disclosure-content"><div class="disclosure-body">
<p class="text-xs text-gray-500 mb-3">Every <code>Token/Version</code> pair the parser extracted from the string, in source order.</p>
<table class="cheat-table">
<thead>
<tr><th>Token</th><th>Version</th></tr>
</thead>
<tbody id="ua-tokens"></tbody>
</table>
<p id="ua-tokens-empty" class="text-xs text-gray-500 mt-2 hidden">No <code>Token/Version</code> pairs found.</p>
</div></div>
</details>
<details class="disclosure mt-2">
<summary>π Detection notes</summary>
<div class="disclosure-content"><div class="disclosure-body">
<div class="grid gap-4 md:grid-cols-2">
<div>
<h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2">Browser priority</h3>
<table class="cheat-table">
<tbody>
<tr><td>Edg / EdgA / EdgiOS</td><td>Edge (checked before Chrome)</td></tr>
<tr><td>SamsungBrowser</td><td>Samsung Internet</td></tr>
<tr><td>OPR / Opera</td><td>Opera</td></tr>
<tr><td>FxiOS / Firefox</td><td>Firefox</td></tr>
<tr><td>CriOS / Chrome</td><td>Chrome</td></tr>
<tr><td>Version + Safari</td><td>Safari (after the above)</td></tr>
<tr><td>MSIE / Trident rv:</td><td>Internet Explorer</td></tr>
<tr><td>bot / crawl / spider</td><td>generic bot fallback</td></tr>
</tbody>
</table>
</div>
<div>
<h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2">Windows NT β marketing</h3>
<table class="cheat-table">
<tbody>
<tr><td>NT 10.0</td><td>Windows 10/11</td></tr>
<tr><td>NT 6.3</td><td>Windows 8.1</td></tr>
<tr><td>NT 6.2</td><td>Windows 8</td></tr>
<tr><td>NT 6.1</td><td>Windows 7</td></tr>
<tr><td>NT 6.0</td><td>Windows Vista</td></tr>
<tr><td>NT 5.1 / 5.2</td><td>Windows XP</td></tr>
</tbody>
</table>
</div>
</div>
</div></div>
</details>
</section>
<section class="mt-12 grid gap-6 md:grid-cols-2">
<div>
<h2 class="text-xl font-bold text-white mb-4">About the User Agent Parser</h2>
<p class="text-gray-400 leading-relaxed">Every HTTP request from a browser includes a <code>User-Agent</code> header β a single string identifying the browser, OS, and device. This tool breaks one down into the structured fields most analytics and server-side detection use: browser family + version, layout engine, OS + marketing name, device type, and CPU architecture.</p>
</div>
<div>
<h2 class="text-xl font-bold text-white mb-4">How to use</h2>
<ol class="text-gray-400 leading-relaxed space-y-2 list-decimal list-inside">
<li>The textarea starts with <strong class="text-gray-300">your own browser's UA</strong> β edit or replace it to test others.</li>
<li>Pick a sample chip for a representative UA from a different platform.</li>
<li>Read the breakdown card; expand <strong class="text-gray-300">Raw token list</strong> to see every parsed <code>Token/Version</code> pair.</li>
<li>Paste a server log line directly β anything around the UA gets ignored.</li>
</ol>
</div>
<div>
<h2 class="text-xl font-bold text-white mb-4">Common use cases</h2>
<ul class="text-gray-400 leading-relaxed space-y-2 list-disc list-inside">
<li>Reproducing a bug report β "which browser version was the user on?"</li>
<li>Spot-checking server logs to tell humans from bots.</li>
<li>Sanity-checking what your analytics dashboard parsed.</li>
<li>Learning how spoofing works β note how Chrome's UA still includes "Safari" and "Mozilla".</li>
</ul>
</div>
<div>
<h2 class="text-xl font-bold text-white mb-4">Tips & caveats</h2>
<ul class="text-gray-400 leading-relaxed space-y-2 list-disc list-inside">
<li>UA strings are advisory β every modern browser pretends to be several others for backwards compatibility.</li>
<li>Windows 10 and 11 share <code>NT 10.0</code>; this tool labels them "Windows 10/11".</li>
<li>iOS UAs say <code>Mac OS X</code>; iPad UAs since iPadOS 13 default to a desktop Safari UA.</li>
<li>For production detection prefer feature detection or UA Client Hints (<code>Sec-CH-UA-*</code>) over UA parsing.</li>
</ul>
</div>
</section>
</main>
<script>
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Samples
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const SAMPLES = {
'chrome-win': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.82 Safari/537.36',
'safari-mac': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15',
'firefox-linux': 'Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0',
'safari-ios': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1',
'chrome-android':'Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.82 Mobile Safari/537.36',
'edge-win': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.2478.51',
'samsung': 'Mozilla/5.0 (Linux; Android 13; SAMSUNG SM-S918B) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/23.0 Chrome/115.0.0.0 Mobile Safari/537.36',
'googlebot': 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/124.0.6367.78 Safari/537.36',
'ie11': 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko'
};
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Parser
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Order matters: Edge UAs contain "Chrome", Chrome UAs contain "Safari", etc.
// We check the most specific tokens first.
const BROWSERS = [
{ name: 'Edge', icon: 'π·', re: /\bEdgiOS\/([\d.]+)/, suffix: ' (iOS)' },
{ name: 'Edge', icon: 'π·', re: /\bEdgA\/([\d.]+)/, suffix: ' (Android)' },
{ name: 'Edge', icon: 'π·', re: /\bEdg(?:e)?\/([\d.]+)/ },
{ name: 'Samsung Internet', icon: 'π£', re: /\bSamsungBrowser\/([\d.]+)/ },
{ name: 'Opera', icon: 'π΄', re: /\bOPR\/([\d.]+)/ },
{ name: 'Opera', icon: 'π΄', re: /\bOpera(?:\/| )([\d.]+)/ },
{ name: 'UC Browser', icon: 'π', re: /\bUCBrowser\/([\d.]+)/ },
{ name: 'Yandex Browser', icon: 'π‘', re: /\bYaBrowser\/([\d.]+)/ },
{ name: 'Brave', icon: 'π¦', re: /\bBrave\/([\d.]+)/ },
{ name: 'Vivaldi', icon: 'πΈ', re: /\bVivaldi\/([\d.]+)/ },
{ name: 'Firefox', icon: 'π¦', re: /\bFxiOS\/([\d.]+)/, suffix: ' (iOS)' },
{ name: 'Firefox', icon: 'π¦', re: /\bFirefox\/([\d.]+)/ },
{ name: 'Chrome', icon: 'π', re: /\bCriOS\/([\d.]+)/, suffix: ' (iOS)' },
{ name: 'Chrome', icon: 'π', re: /\bChromium\/([\d.]+)/, displayName: 'Chromium' },
{ name: 'Chrome', icon: 'π', re: /\bChrome\/([\d.]+)/ },
{ name: 'Safari', icon: 'π§', re: /Version\/([\d.]+).+Safari\// },
{ name: 'Safari', icon: 'π§', re: /\bSafari\/([\d.]+)/ },
{ name: 'Internet Explorer', icon: 'πͺ¦', re: /\bMSIE ([\d.]+)/ },
{ name: 'Internet Explorer', icon: 'πͺ¦', re: /\bTrident\/[\d.]+.*rv:([\d.]+)/ }
];
// Bots are detected *separately* from the browser β many bots (Googlebot,
// Bingbot, Twitterbot, β¦) carry a Chrome/Safari sub-string too; we don't
// want to lose the underlying engine info.
const BOTS = [
{ name: 'Googlebot', re: /Googlebot\/([\d.]+)?/ },
{ name: 'Bingbot', re: /bingbot\/([\d.]+)?/i },
{ name: 'DuckDuckBot', re: /DuckDuckBot\/([\d.]+)?/ },
{ name: 'YandexBot', re: /YandexBot\/([\d.]+)?/ },
{ name: 'Baiduspider', re: /Baiduspider(?:\/([\d.]+))?/ },
{ name: 'Slurp (Yahoo)', re: /Slurp(?:\/([\d.]+))?/ },
{ name: 'Applebot', re: /Applebot\/([\d.]+)?/ },
{ name: 'AhrefsBot', re: /AhrefsBot\/([\d.]+)?/ },
{ name: 'SemrushBot', re: /SemrushBot(?:\/([\d.]+))?/i },
{ name: 'facebookexternalhit', re: /facebookexternalhit\/([\d.]+)?/i },
{ name: 'Twitterbot', re: /Twitterbot\/([\d.]+)?/ },
{ name: 'LinkedInBot', re: /LinkedInBot\/([\d.]+)?/ },
{ name: 'WhatsApp', re: /WhatsApp\/([\d.]+)?/ },
{ name: 'TelegramBot', re: /TelegramBot/ },
{ name: 'Discordbot', re: /Discordbot\/([\d.]+)?/i },
{ name: 'Slackbot', re: /Slackbot(?:-LinkExpanding)?\/([\d.]+)?/ },
{ name: 'PetalBot', re: /PetalBot\/([\d.]+)?/ }
];
function detectBot(ua) {
for (const b of BOTS) {
const m = ua.match(b.re);
if (m) return { name: b.name, version: m[1] || null };
}
if (/bot|crawl|spider|HeadlessChrome/i.test(ua)) {
return { name: 'Bot (generic)', version: null };
}
return null;
}
function detectBrowser(ua) {
for (const b of BROWSERS) {
const m = ua.match(b.re);
if (m) {
const name = (b.displayName || b.name) + (b.suffix || '');
return { name, version: m[1] || 'Unknown', icon: b.icon };
}
}
return { name: 'Unknown', version: 'Unknown', icon: 'β' };
}
function detectEngine(ua, browser) {
// Trident first β IE is unambiguous.
if (/Trident\//.test(ua) || /MSIE /.test(ua)) {
const m = ua.match(/Trident\/([\d.]+)/);
return { name: 'Trident', version: m ? m[1] : null };
}
// Old EdgeHTML
if (/Edge\//.test(ua) && !/Edg\//.test(ua)) {
const m = ua.match(/Edge\/([\d.]+)/);
return { name: 'EdgeHTML', version: m ? m[1] : null };
}
// Gecko (Firefox) β must not be just the "Gecko" compatibility token used by Chrome / Safari.
if (/Firefox\/|FxiOS\//.test(ua)) {
const m = ua.match(/rv:([\d.]+)/);
return { name: 'Gecko', version: m ? m[1] : null };
}
// Blink β Chrome and its descendants (Edge, Opera, Samsung, Vivaldi, Brave, β¦).
// On iOS *all* browsers are WebKit underneath, even when their UA says Chrome / Firefox / Edge.
const isIOS = /iPhone|iPad|iPod|CriOS|FxiOS|EdgiOS/.test(ua);
if (!isIOS && /Chrome\/|Chromium\//.test(ua)) {
const m = ua.match(/Chrome\/([\d.]+)/) || ua.match(/Chromium\/([\d.]+)/);
return { name: 'Blink', version: m ? m[1] : null };
}
// WebKit (Safari and everything on iOS).
if (/AppleWebKit\//.test(ua)) {
const m = ua.match(/AppleWebKit\/([\d.]+)/);
return { name: 'WebKit', version: m ? m[1] : null };
}
// Presto (old Opera <15)
if (/Presto\//.test(ua)) {
const m = ua.match(/Presto\/([\d.]+)/);
return { name: 'Presto', version: m ? m[1] : null };
}
return { name: 'Unknown', version: null };
}
// Marketing-name lookup for Windows NT versions. NT 10.0 covers both
// Windows 10 and 11 β Microsoft never bumped the UA value.
const WIN_NAMES = {
'10.0': 'Windows 10/11',
'6.3': 'Windows 8.1',
'6.2': 'Windows 8',
'6.1': 'Windows 7',
'6.0': 'Windows Vista',
'5.2': 'Windows XP',
'5.1': 'Windows XP',
'5.0': 'Windows 2000'
};
// macOS code names (post-Cheetah). 10.15 is the last "Mac OS X 10_" version
// β 11+ are pure majors, though plenty of UAs still claim 10_15_7.
const MAC_NAMES = {
'10.7': 'Lion', '10.8': 'Mountain Lion', '10.9': 'Mavericks',
'10.10': 'Yosemite', '10.11': 'El Capitan', '10.12': 'Sierra',
'10.13': 'High Sierra', '10.14': 'Mojave', '10.15': 'Catalina',
'11': 'Big Sur', '12': 'Monterey', '13': 'Ventura',
'14': 'Sonoma', '15': 'Sequoia'
};
function detectOS(ua) {
let m;
// iPadOS / iOS β must come before macOS because iPad UAs since iPadOS 13
// can claim "Macintosh; Intel Mac OS X" with a Mobile/ token.
if ((m = ua.match(/iPhone OS (\d+)[._](\d+)(?:[._](\d+))?/))) {
const ver = `${m[1]}.${m[2]}${m[3] ? '.' + m[3] : ''}`;
return { name: 'iOS', version: ver, marketing: `iOS ${ver}`, icon: 'π±' };
}
if (/iPad/.test(ua) && (m = ua.match(/OS (\d+)[._](\d+)(?:[._](\d+))?/))) {
const ver = `${m[1]}.${m[2]}${m[3] ? '.' + m[3] : ''}`;
return { name: 'iPadOS', version: ver, marketing: `iPadOS ${ver}`, icon: 'π±' };
}
// Android
if ((m = ua.match(/Android (\d+(?:\.\d+)?(?:\.\d+)?)/))) {
return { name: 'Android', version: m[1], marketing: `Android ${m[1]}`, icon: 'π€' };
}
// ChromeOS
if (/CrOS/.test(ua)) {
const cm = ua.match(/CrOS [^ ]+ ([\d.]+)/);
return { name: 'ChromeOS', version: cm ? cm[1] : null, marketing: 'ChromeOS' + (cm ? ` ${cm[1]}` : ''), icon: 'π’' };
}
// Windows
if ((m = ua.match(/Windows NT ([\d.]+)/))) {
const nt = m[1];
const name = WIN_NAMES[nt] || `Windows NT ${nt}`;
return { name: 'Windows', version: nt, marketing: `${name} (NT ${nt})`, icon: 'πͺ' };
}
// macOS β "Mac OS X 10_15_7" or "Macintosh; Intel Mac OS X 14_4"
if ((m = ua.match(/Mac OS X (\d+)[._](\d+)(?:[._](\d+))?/))) {
const major = m[1], minor = m[2], patch = m[3];
const verShort = major === '10' ? `10.${minor}` : major;
const verFull = patch ? `${major}.${minor}.${patch}` : `${major}.${minor}`;
const codename = MAC_NAMES[verShort];
const marketing = `macOS ${verFull}` + (codename ? ` (${codename})` : '');
return { name: 'macOS', version: verFull, marketing, icon: 'π' };
}
// Linux (after Android, since Android UAs include "Linux")
if (/Linux/.test(ua)) {
return { name: 'Linux', version: null, marketing: 'Linux', icon: 'π§' };
}
// FreeBSD / OpenBSD / NetBSD
if (/FreeBSD/.test(ua)) return { name: 'FreeBSD', version: null, marketing: 'FreeBSD', icon: 'πΉ' };
return { name: 'Unknown', version: null, marketing: 'Unknown', icon: 'β' };
}
function detectDevice(ua, os, isBot) {
if (isBot) return { type: 'Bot', icon: 'π€' };
// Tablet detection β iPad always counts. Android Tablet is Android-without-Mobile token.
if (/iPad|Tablet|PlayBook|Kindle|Silk/.test(ua)) return { type: 'Tablet', icon: 'π±' };
if (/Android/.test(ua) && !/Mobile/.test(ua)) return { type: 'Tablet', icon: 'π±' };
// Mobile
if (/Mobi|iPhone|iPod|Mobile|webOS|BlackBerry|IEMobile|Opera Mini/.test(ua)) {
return { type: 'Mobile', icon: 'π±' };
}
// Smart TVs etc. β best-effort
if (/SmartTV|TV;|AppleTV|GoogleTV/.test(ua)) return { type: 'TV', icon: 'πΊ' };
return { type: 'Desktop', icon: 'π₯οΈ' };
}
function detectCPU(ua) {
if (/x86_64|Win64; x64|x64;|WOW64|amd64|AMD64/.test(ua)) return 'x86-64';
if (/arm64|aarch64|Mac OS X.+Apple Silicon/i.test(ua)) return 'ARM 64-bit';
if (/armv7|armv8|ARM[;)\s]/.test(ua)) return 'ARM';
if (/i[3-6]86|x86;|x86\)/.test(ua)) return 'x86 (32-bit)';
if (/PPC|PowerPC/i.test(ua)) return 'PowerPC';
if (/Intel Mac OS X/.test(ua)) return 'Intel (x86)';
return 'Unknown';
}
// Pulls every `Token/Version` pair from a UA string, in source order.
// Skips the "Mozilla/5.0" prefix β it's a lie every modern browser tells.
function extractTokens(ua) {
const pairs = [];
const re = /([A-Za-z][A-Za-z0-9._-]*)\/([0-9A-Za-z._-]+)/g;
let m;
while ((m = re.exec(ua)) !== null) {
pairs.push({ token: m[1], version: m[2] });
}
return pairs;
}
function parseUA(ua) {
ua = (ua || '').trim();
if (!ua) return null;
const bot = detectBot(ua);
const browser = bot ? { name: bot.name, version: bot.version || 'Unknown', icon: 'π€' } : detectBrowser(ua);
const engine = detectEngine(ua, browser);
const os = detectOS(ua);
const device = detectDevice(ua, os, !!bot);
const cpu = detectCPU(ua);
const tokens = extractTokens(ua);
return { raw: ua, browser, engine, os, device, cpu, tokens, isBot: !!bot };
}
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Render
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const $ = id => document.getElementById(id);
function renderRow(label, value, opts = {}) {
const row = document.createElement('div');
row.className = 'ua-row' + (opts.raw ? ' ua-raw' : '');
const l = document.createElement('div');
l.className = 'ua-label';
l.textContent = label;
const v = document.createElement('div');
v.className = 'ua-value';
if (opts.icon) {
const i = document.createElement('span');
i.className = 'ua-icon';
i.textContent = opts.icon;
v.appendChild(i);
}
v.appendChild(document.createTextNode(value));
if (opts.tag) {
const t = document.createElement('span');
t.className = 'pill-tag';
t.textContent = opts.tag;
v.appendChild(t);
}
row.appendChild(l);
row.appendChild(v);
return row;
}
function render(parsed) {
const errEl = $('ua-error');
const empty = $('ua-empty');
const result = $('ua-result');
errEl.classList.add('hidden');
if (!parsed) {
result.classList.add('hidden');
empty.classList.remove('hidden');
return;
}
empty.classList.add('hidden');
const card = $('ua-card');
card.innerHTML = '';
const browserLabel = `${parsed.browser.name}${parsed.browser.version && parsed.browser.version !== 'Unknown' ? ' ' + parsed.browser.version : ''}`;
card.appendChild(renderRow('Browser', browserLabel, {
icon: parsed.browser.icon,
tag: parsed.isBot ? 'bot' : null
}));
const engineLabel = parsed.engine.version ? `${parsed.engine.name} ${parsed.engine.version}` : parsed.engine.name;
card.appendChild(renderRow('Engine', engineLabel));
card.appendChild(renderRow('OS', parsed.os.marketing, { icon: parsed.os.icon }));
card.appendChild(renderRow('Device type', parsed.device.type, { icon: parsed.device.icon }));
card.appendChild(renderRow('CPU', parsed.cpu));
card.appendChild(renderRow('Raw string', parsed.raw, { raw: true }));
// Token table
const tbody = $('ua-tokens');
const emptyMsg = $('ua-tokens-empty');
tbody.innerHTML = '';
if (parsed.tokens.length === 0) {
emptyMsg.classList.remove('hidden');
} else {
emptyMsg.classList.add('hidden');
for (const { token, version } of parsed.tokens) {
const tr = document.createElement('tr');
const td1 = document.createElement('td');
td1.textContent = token;
const td2 = document.createElement('td');
td2.textContent = version;
tr.appendChild(td1);
tr.appendChild(td2);
tbody.appendChild(tr);
}
}
result.classList.remove('hidden');
}
function run() {
const ua = $('ua-input').value;
render(parseUA(ua));
}
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Wiring
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function loadSample(key) {
const ua = SAMPLES[key];
if (!ua) return;
document.querySelectorAll('.chip[data-sample]').forEach(el => {
el.classList.toggle('on', el.dataset.sample === key);
});
$('ua-input').value = ua;
run();
}
function fillOwnUA() {
$('ua-input').value = navigator.userAgent || '';
document.querySelectorAll('.chip[data-sample]').forEach(el => el.classList.remove('on'));
run();
}
async function pasteUA() {
try {
const txt = await navigator.clipboard.readText();
if (txt) {
$('ua-input').value = txt.trim();
document.querySelectorAll('.chip[data-sample]').forEach(el => el.classList.remove('on'));
run();
}
} catch {
$('ua-error').textContent = 'β Clipboard read failed β paste manually with Ctrl/Cmd+V.';
$('ua-error').classList.remove('hidden');
}
}
function clearUA() {
$('ua-input').value = '';
document.querySelectorAll('.chip[data-sample]').forEach(el => el.classList.remove('on'));
run();
}
let debounceTimer;
$('ua-input').addEventListener('input', () => {
document.querySelectorAll('.chip[data-sample]').forEach(el => el.classList.remove('on'));
clearTimeout(debounceTimer);
debounceTimer = setTimeout(run, 100);
});
// Init β pre-fill with the visitor's own UA so the page is useful immediately.
$('ua-input').value = navigator.userAgent || '';
run();
</script>
<include src="_partials/footer-script.html"></include>
<!-- BEGIN:faq generated by scripts/generate-sections.mjs β re-run after editing tools.json -->
<section class="max-w-[1100px] mx-auto w-full px-6 py-8 border-t border-gray-800">
<h2 class="text-xl font-bold text-white mb-6">FAQ</h2>
<div class="space-y-2">
<details class="disclosure">
<summary>Where does the pre-filled UA string come from?</summary>
<div class="disclosure-content"><div class="disclosure-body">It's your own browser's navigator.userAgent β the exact value any website you visit would see. Edit it to test other UAs.</div></div>
</details>
<details class="disclosure">
<summary>Why does Chrome on iOS show up as CriOS / 'Chrome (iOS)'?</summary>
<div class="disclosure-content"><div class="disclosure-body">Apple requires every browser on iOS to use WebKit. CriOS / FxiOS / EdgiOS are the tokens Chrome / Firefox / Edge add on iOS so servers can still distinguish them, even though the engine is WebKit underneath.</div></div>
</details>
<details class="disclosure">
<summary>Can it tell Windows 10 apart from Windows 11?</summary>
<div class="disclosure-content"><div class="disclosure-body">Not reliably β Microsoft kept the UA at "Windows NT 10.0" for both. The tool shows "Windows 10/11" for that NT version. UA Client Hints (Sec-CH-UA-Platform-Version) can distinguish them, but those aren't present in a plain UA string.</div></div>
</details>
<details class="disclosure">
<summary>Is the parser 100% accurate?</summary>
<div class="disclosure-content"><div class="disclosure-body">UA strings are best-effort by design β browsers spoof each other for compatibility (Chrome includes 'Safari', Edge includes 'Chrome', etc.). The parser uses the priority order most servers do, but for high-stakes detection prefer UA Client Hints or feature detection.</div></div>
</details>
<details class="disclosure">
<summary>Does my UA string leave my computer?</summary>
<div class="disclosure-content"><div class="disclosure-body">No. Parsing happens entirely in your browser β the page is a single static HTML file with no network requests.</div></div>
</details>
</div>
</section>
<!-- END:faq -->
<!-- BEGIN:more-tools generated by scripts/generate-sections.mjs β re-run after editing tools.json -->
<section class="max-w-[1100px] mx-auto w-full px-6 py-8 border-t border-gray-800">
<h2 class="text-xl font-bold text-white mb-6">More tools</h2>
<div class="space-y-4">
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">JSON</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/json-formatter" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">ποΈ JSON Formatter</a>
<a href="/json-to-ts" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π· JSON to TypeScript</a>
<a href="/json-diff" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π JSON Diff</a>
<a href="/json-sort" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π€ JSON Sort</a>
<a href="/csv-to-json" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π JSON β CSV</a>
<a href="/json-to-yaml" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π JSON β YAML</a>
<a href="/json-to-schema" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π‘οΈ JSON to Validator Schema</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Code</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/regex-tester" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π§ͺ Regex Tester</a>
<a href="/svg-to-jsx" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">βοΈ SVG to JSX</a>
<a href="/svg-rasterizer" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π· SVG to Raster</a>
<a href="/cron-decoder" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">β±οΈ Cron Decoder</a>
<a href="/snippet-to-image" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πΈ Code Snippet to Image</a>
<a href="/text-diff" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Text Diff</a>
<a href="/markdown-preview" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Markdown Preview</a>
<a href="/semver-checker" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π·οΈ SemVer Checker</a>
<a href="/jwt-decoder" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π JWT Decoder</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Ornaments</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/gradients" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π¨ Gradients</a>
<a href="/blob" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π«§ Blob Generator</a>
<a href="/waves" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">γ°οΈ Wave Generator</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Image</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/image-compressor" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">ποΈ Image Compressor</a>
<a href="/image-resizer" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Image Resizer</a>
<a href="/image-cropper" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">βοΈ Image Cropper</a>
<a href="/image-converter" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πΌοΈ Image Format Converter</a>
<a href="/image-watermark" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Image Watermark</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Audio</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/mp3-tag-editor" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π΅ MP3 Tag Editor</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Web / SEO</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/meta-tag-preview" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Meta Tag Preview</a>
<a href="/og-image-builder" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πΌοΈ OG Image Builder</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Generators</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/qr-code-generator" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π± QR Code Generator</a>
<a href="/lorem-ipsum" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Lorem Ipsum Generator</a>
<a href="/avatar-generator" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π€ Avatar Generator</a>
<a href="/favicon-generator" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">β Favicon Generator</a>
<a href="/uuid-generator" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πͺͺ UUID Generator</a>
<a href="/wheel-of-names" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π‘ Wheel of Names</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">PDF</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/pdf-merger" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π PDF Merger</a>
<a href="/image-to-pdf" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π Image to PDF</a>
<a href="/pdf-compressor" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π€ PDF Compressor</a>
<a href="/pdf-splitter" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">βοΈ PDF Splitter</a>
<a href="/pdf-page-manager" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">ποΈ PDF Page Manager</a>
<a href="/pdf-watermark" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π§ PDF Watermark</a>
<a href="/pdf-signature" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">βοΈ PDF Signature</a>
<a href="/pdf-to-image" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">πΌοΈ PDF to Image</a>
</div>
</div>
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Time</h3>
<div class="flex flex-wrap gap-x-5 gap-y-2">
<a href="/pomodoro-timer" class="text-sm text-gray-300 hover:text-blue-400 transition-colors no-underline">π
Pomodoro Timer</a>
</div>
</div>
</div>
</section>
<!-- END:more-tools -->
<footer class="max-w-[1100px] mx-auto w-full py-8 px-6 border-t border-gray-800 text-center text-sm text-gray-600">
<div>© <span id="year"></span> <a href="https://mazipan.space" rel="noreferrer noopener" target="_blank" class="text-blue-400 transition-colors">Irfan Maulana</a> & Claude</div>
<div><span id="deploy-time"></span></div>
<div><span id="commit-sha"></span><a href="https://github.com/mazipan/html-tools" rel="noreferrer noopener" target="_blank" class="text-blue-400 transition-colors">Source</a></div>
<div><a href="design-system.html" rel="nofollow" class="text-blue-400 transition-colors">Design system</a></div>
<div><a href="https://baca-quran.id" rel="noreferrer noopener" target="_blank" class="text-blue-400 transition-colors">Baca Quran</a> Β· <a href="https://games.mazipan.space" rel="noreferrer noopener" target="_blank" class="text-blue-400 transition-colors">Games</a></div>
</footer>
</body>
</html>