-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumber-base.html
More file actions
1084 lines (1007 loc) · 58.7 KB
/
Copy pathnumber-base.html
File metadata and controls
1084 lines (1007 loc) · 58.7 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
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Base Converter — Binary, Hex, Octal | FreeDevTool</title>
<meta name="description" content="Free number base converter — binary, decimal, hex, octal, any base 2-36. BigInt precision, bit-length, grouped nibbles. Browser-only.">
<meta name="robots" content="index, follow">
<meta name="author" content="Anees Ur Rehman">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","datePublished":"2026-05-02","dateModified":"2026-05-19","inLanguage":"en-US","isPartOf":{"@type":"WebSite","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Person","name":"Anees Ur Rehman","url":"https://freedevtool.org/about","jobTitle":"Full-stack developer","worksFor":{"@type":"Organization","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "HowTo",
"name": "How to convert numbers between binary, decimal, hex, and octal",
"description": "Convert any number between bases 2 through 36 with BigInt precision, bit-length display, and two's complement support.",
"step": [
{"@type":"HowToStep","name":"Enter the number","text":"Type the number in any of the input fields (binary, decimal, hex, or octal). All other bases update simultaneously."},
{"@type":"HowToStep","name":"Choose source base if non-standard","text":"For arbitrary bases (2-36), pick the source base from the dropdown — useful for base32 (Crockford), base36 (alphanumeric), or hex variants."},
{"@type":"HowToStep","name":"Read all conversions","text":"Binary, octal, decimal, hex (and your custom base) display side-by-side with bit-length and grouped-nibble formatting."},
{"@type":"HowToStep","name":"Copy the result","text":"Click any output to copy. Hex with 0x prefix, binary with 0b prefix, decimal as-is — match the format your code expects."}
]
}
</script>
<link rel="canonical" href="https://freedevtool.org/number-base">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap" as="style">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap">
<link rel="preload" href="style.css?v=20260502-cards" as="style">
<link rel="stylesheet" href="style.css?v=20260502-cards">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/favicon.svg">
<meta property="og:image" content="https://freedevtool.org/og-image.svg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="FreeDevTool — 50+ free, fast, privacy-first developer tools">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://freedevtool.org/og-image.svg">
<meta name="twitter:title" content="Number Base Converter — Binary, Hex, Octal, Decimal Free">
<meta name="twitter:description" content="Convert between binary, octal, decimal, hexadecimal, and any base 2–36 with BigInt precision. Bit length, grouped nibbles, two's complement helpers.">
<!-- Google Analytics 4 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3L0CMH3X36"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-3L0CMH3X36');
</script>
<meta property="og:title" content="Number Base Converter — Binary, Hex, Octal, Decimal Free Tool">
<meta property="og:description" content="Convert between binary, hexadecimal, octal, and decimal with BigInt support. Free radix conversion tool for developers.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://freedevtool.org/number-base">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "Number Base Converter",
"url": "https://freedevtool.org/number-base",
"description": "Convert between binary, decimal, hexadecimal, octal, and any base (2-36) instantly. Free online number base converter with BigInt support.",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "Any",
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" }
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "How do I convert binary to decimal?",
"acceptedAnswer": { "@type": "Answer", "text": "To convert binary to decimal, multiply each bit by its positional power of 2 and sum the results. For example, binary 1011 = (1×2³) + (0×2²) + (1×2¹) + (1×2⁰) = 8 + 0 + 2 + 1 = 11 in decimal. This positional notation principle applies to all numeral systems — each digit is multiplied by the base raised to its position index." }
},
{
"@type": "Question",
"name": "What is hexadecimal and why is it used in programming?",
"acceptedAnswer": { "@type": "Answer", "text": "Hexadecimal (base-16) uses digits 0-9 and letters A-F. Each hex digit maps to exactly 4 binary bits, making it a compact way to represent binary data. For example, 0xFF = 11111111 in binary = 255 in decimal. Programmers use hex for memory addresses, color codes (#FF5733), byte values, and bitwise operations because it's far more readable than long binary strings while maintaining a direct relationship with the underlying binary." }
},
{
"@type": "Question",
"name": "How do I convert between octal and binary?",
"acceptedAnswer": { "@type": "Answer", "text": "Each octal digit corresponds to exactly 3 binary bits. To convert octal to binary, replace each octal digit with its 3-bit binary equivalent: 0=000, 1=001, 2=010, 3=011, 4=100, 5=101, 6=110, 7=111. For example, octal 357 = 011 101 111 = 011101111 in binary. To go from binary to octal, group binary digits into sets of 3 from the right and convert each group." }
},
{
"@type": "Question",
"name": "What bases are commonly used in computer science?",
"acceptedAnswer": { "@type": "Answer", "text": "The most common bases are: Binary (base-2) — the fundamental language of computers using 0s and 1s. Octal (base-8) — used in Unix file permissions and some legacy systems. Decimal (base-10) — the standard human numeral system. Hexadecimal (base-16) — widely used for memory addresses, color codes, and representing byte values compactly. Base-64 encoding is also common for data transfer, though it works differently from positional numeral systems." }
},
{
"@type": "Question",
"name": "What is the difference between signed and unsigned binary numbers?",
"acceptedAnswer": { "@type": "Answer", "text": "Unsigned binary numbers represent only non-negative values — an 8-bit unsigned number ranges from 0 to 255. Signed binary uses the most significant bit (MSB) as a sign indicator. In two's complement (the most common signed format), an 8-bit signed number ranges from -128 to 127. The binary value 11111111 is 255 unsigned but -1 in signed two's complement. Understanding this distinction is crucial when working with low-level programming, bitwise operations, and data types in languages like C and Rust." }
},{"@type":"Question","name":"What is two complement and why is it used?","acceptedAnswer":{"@type":"Answer","text":"Two complement is how CPUs represent negative integers in binary. Negate by inverting all bits and adding 1. This lets the same hardware addition circuit handle positive and negative numbers — no separate subtraction unit needed. Every modern CPU uses two complement."}},{"@type":"Question","name":"Why do programmers use hexadecimal?","acceptedAnswer":{"@type":"Answer","text":"Each hex digit represents exactly 4 bits (a nibble). Memory addresses, color codes, machine instructions, and bit patterns map cleanly to hex — easier to read than binary, more compact than decimal. 0xFF is 1 byte; 0xFFFF is 2 bytes."}},{"@type":"Question","name":"What is the largest 32-bit signed integer?","acceptedAnswer":{"@type":"Answer","text":"2,147,483,647 (0x7FFFFFFF). With one bit reserved for sign you get 31 bits of magnitude. The minimum 32-bit signed integer is -2,147,483,648. The Unix epoch timestamp overflows this on January 19, 2038 — the famous Y2K38 problem."}}
]
}
</script>
<style>
.base-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
}
@media (max-width: 560px) {
.base-grid { grid-template-columns: 1fr; }
}
.base-field {
background: var(--bg3);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 14px;
transition: border-color .2s;
}
.base-field:hover { border-color: var(--border2); }
.base-field.has-error { border-color: var(--red); }
.base-field-label {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
.base-field-name {
font-family: var(--mono);
font-size: 11px;
color: var(--text3);
text-transform: uppercase;
letter-spacing: .5px;
}
.base-field-tag {
font-family: var(--mono);
font-size: 10px;
color: var(--accent);
background: var(--accent-dim);
padding: 2px 7px;
border-radius: 4px;
}
.base-field textarea {
width: 100%;
background: var(--bg2);
border: 1px solid var(--border);
border-radius: 6px;
color: var(--text);
font-family: var(--mono);
font-size: 14px;
padding: 10px 12px;
resize: vertical;
min-height: 44px;
line-height: 1.5;
transition: border-color .2s, box-shadow .2s;
}
.base-field textarea:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-dim);
}
.base-field textarea.invalid {
border-color: var(--red);
box-shadow: 0 0 0 3px rgba(255,90,90,.1);
}
.base-field .field-error {
font-family: var(--mono);
font-size: 11px;
color: var(--red);
margin-top: 4px;
display: none;
}
.base-field .copy-btn {
background: none;
border: none;
color: var(--text3);
font-family: var(--mono);
font-size: 11px;
cursor: pointer;
padding: 2px 6px;
border-radius: 4px;
transition: color .2s, background .2s;
}
.base-field .copy-btn:hover {
color: var(--accent);
background: var(--accent-dim);
}
.custom-base-row {
display: flex;
align-items: center;
gap: 10px;
margin-top: 16px;
}
.custom-base-row label {
font-family: var(--mono);
font-size: 12px;
color: var(--text2);
white-space: nowrap;
}
.custom-base-row input[type="number"] {
width: 64px;
background: var(--bg2);
border: 1px solid var(--border);
border-radius: 6px;
color: var(--text);
font-family: var(--mono);
font-size: 14px;
padding: 8px 10px;
text-align: center;
}
.custom-base-row input[type="number"]:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-dim);
}
.custom-base-row input[type="text"] {
flex: 1;
}
.info-bar {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 16px;
}
.info-chip {
font-family: var(--mono);
font-size: 11px;
color: var(--text2);
background: var(--bg3);
border: 1px solid var(--border);
border-radius: 20px;
padding: 4px 12px;
white-space: nowrap;
}
.info-chip strong {
color: var(--accent);
font-weight: 500;
}
.nibble-display {
margin-top: 16px;
background: var(--bg3);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 14px;
}
.nibble-label {
font-family: var(--mono);
font-size: 11px;
color: var(--text3);
text-transform: uppercase;
letter-spacing: .5px;
margin-bottom: 8px;
}
.nibble-value {
font-family: var(--mono);
font-size: 14px;
color: var(--text);
word-break: break-all;
line-height: 1.7;
cursor: pointer;
transition: color .2s;
}
.nibble-value:hover { color: var(--accent); }
.nibble-group {
background: var(--accent-dim);
border-radius: 3px;
padding: 2px 4px;
margin: 0 1px;
}
.nibble-group:nth-child(even) {
background: rgba(245,197,66,.06);
}
.action-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 16px;
}
.action-btn {
display: inline-flex;
align-items: center;
gap: 6px;
background: var(--bg3);
border: 1px solid var(--border);
border-radius: var(--radius);
color: var(--text2);
font-family: var(--mono);
font-size: 12px;
padding: 8px 14px;
cursor: pointer;
transition: border-color .2s, color .2s, background .2s;
}
.action-btn:hover {
border-color: var(--accent);
color: var(--accent);
background: var(--accent-dim);
}
</style>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://freedevtool.org/"
},
{
"@type": "ListItem",
"position": 2,
"name": "All Tools",
"item": "https://freedevtool.org/all-tools"
},
{
"@type": "ListItem",
"position": 3,
"name": "Number Base Converter",
"item": "https://freedevtool.org/number-base"
}
]
}
</script>
<script src="/ga4-events.js" defer></script>
</head>
<body>
<nav>
<a class="nav-logo" href="/" aria-label="FreeDevTool home"><svg class="logo-mark" width="22" height="22" viewBox="0 0 24 24" aria-hidden="true" fill="none"><rect x="1" y="1" width="22" height="22" rx="6" fill="currentColor" opacity=".12"/><path d="M9.5 8.5L6 12l3.5 3.5M14.5 8.5L18 12l-3.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>FreeDevTool</a>
<div class="nav-links">
<div class="nav-dropdown" id="tools-dropdown">
<a href="all-tools" onclick="event.preventDefault();this.parentElement.classList.toggle('open')" aria-haspopup="true">Tools <svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></a>
<div class="nav-dropdown-menu">
<a href="encoding-tools">
<div class="dd-icon">b64</div>
<div class="dd-info"><div class="dd-name">Encoding & Conversion</div><div class="dd-count">11 tools · Base64, YAML, px→rem</div></div>
</a>
<a href="generation-tools">
<div class="dd-icon">{ }</div>
<div class="dd-info"><div class="dd-name">Generation & Formatting</div><div class="dd-count">16 tools · JSON, SQL, gradients</div></div>
</a>
<a href="security-tools">
<div class="dd-icon">#</div>
<div class="dd-info"><div class="dd-name">Security & Hashing</div><div class="dd-count">3 tools · JWT, MD5, SHA</div></div>
</a>
<a href="text-tools">
<div class="dd-icon">.*</div>
<div class="dd-info"><div class="dd-name">Code & Text Tools</div><div class="dd-count">9 tools · Regex, diff, tokens</div></div>
</a>
<a href="devops-tools">
<div class="dd-icon">JS</div>
<div class="dd-info"><div class="dd-name">Optimization & DevOps</div><div class="dd-count">7 tools · Minifiers, cURL, git</div></div>
</a>
<a href="network-tools">
<div class="dd-icon">IP</div>
<div class="dd-info"><div class="dd-name">Network & Time</div><div class="dd-count">4 tools · IP, DNS, timestamps</div></div>
</a>
<a href="seo-tools">
<div class="dd-icon">SEO</div>
<div class="dd-info"><div class="dd-name">SEO & Meta Tools</div><div class="dd-count">3 tools · OG, meta, slug</div></div>
</a>
<div class="nav-dropdown-divider"></div>
<a class="dd-all" href="all-tools">
<div class="dd-icon">All</div>
<div class="dd-info"><div class="dd-name">Browse all 50 tools</div><div class="dd-count">Searchable catalog & categories</div></div>
</a>
</div>
</div>
<a href="/guides">Guides</a>
<a href="about">About</a>
<a href="privacy">Privacy</a>
</div>
</nav>
<div id="copy-toast">Copied!</div>
<div class="wrapper">
<a class="tool-back" href="/" aria-label="Back to home">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg>
Back
</a>
<div class="tool-header">
<div class="tool-badge">Math Tool</div>
<h1>Number Base Converter</h1>
<p class="tool-description">
Convert between binary, decimal, hexadecimal, and octal number systems instantly. This free online number base converter supports radix conversion for any base from 2 to 36, with BigInt precision for arbitrarily large numbers. Explore positional notation across base-2, base-8, base-10, and base-16 numeral systems with grouped nibbles, bit-length display, and real-time input validation. All conversions happen client-side in your browser.
</p>
<div class="last-updated">Last updated: May 2026 · Written by <a href="/about">Anees Ur Rehman</a>, full-stack developer</div>
</div>
<div class="tool-card">
<div class="tool-card-header">
<div class="dot dot-red"></div>
<div class="dot dot-yellow"></div>
<div class="dot dot-green"></div>
<span class="tool-card-title">number-base.tool</span>
</div>
<div class="tool-body">
<div class="base-grid">
<div class="base-field" id="field-bin">
<div class="base-field-label">
<span class="base-field-name">Binary</span>
<span class="base-field-tag">Base 2</span>
<button class="copy-btn" onclick="copyField('bin')">Copy</button>
</div>
<textarea id="input-bin" rows="2" placeholder="e.g. 11010110" spellcheck="false" oninput="convert('bin')"></textarea>
<div class="field-error" id="err-bin"></div>
</div>
<div class="base-field" id="field-oct">
<div class="base-field-label">
<span class="base-field-name">Octal</span>
<span class="base-field-tag">Base 8</span>
<button class="copy-btn" onclick="copyField('oct')">Copy</button>
</div>
<textarea id="input-oct" rows="2" placeholder="e.g. 326" spellcheck="false" oninput="convert('oct')"></textarea>
<div class="field-error" id="err-oct"></div>
</div>
<div class="base-field" id="field-dec">
<div class="base-field-label">
<span class="base-field-name">Decimal</span>
<span class="base-field-tag">Base 10</span>
<button class="copy-btn" onclick="copyField('dec')">Copy</button>
</div>
<textarea id="input-dec" rows="2" placeholder="e.g. 214" spellcheck="false" oninput="convert('dec')"></textarea>
<div class="field-error" id="err-dec"></div>
</div>
<div class="base-field" id="field-hex">
<div class="base-field-label">
<span class="base-field-name">Hexadecimal</span>
<span class="base-field-tag">Base 16</span>
<button class="copy-btn" onclick="copyField('hex')">Copy</button>
</div>
<textarea id="input-hex" rows="2" placeholder="e.g. D6" spellcheck="false" oninput="convert('hex')"></textarea>
<div class="field-error" id="err-hex"></div>
</div>
</div>
<div class="custom-base-row">
<label>Custom Base</label>
<input type="number" id="custom-radix" min="2" max="36" value="3" oninput="convert('custom')">
<input type="text" id="input-custom" placeholder="Enter value in custom base" spellcheck="false" oninput="convert('custom')">
<button class="copy-btn" onclick="copyField('custom')" style="flex-shrink:0;">Copy</button>
</div>
<div class="field-error" id="err-custom" style="margin-left:0;margin-top:4px;"></div>
<div class="action-row">
<button class="action-btn" onclick="swapEndian()">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M7 16V4m0 0L3 8m4-4l4 4M17 8v12m0 0l4-4m-4 4l-4-4"/></svg>
Swap Endianness
</button>
<button class="action-btn" onclick="clearAll()">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
Clear All
</button>
</div>
<div class="info-bar" id="info-bar">
<div class="info-chip"><strong id="info-bits">—</strong> bits</div>
<div class="info-chip">Fits in <strong id="info-fit">—</strong></div>
</div>
<div class="nibble-display" id="nibble-display" style="display:none;">
<div class="nibble-label">Binary (Grouped Nibbles)</div>
<div class="nibble-value" id="nibble-value" onclick="copyNibble()"></div>
</div>
</div>
</div>
<p class="aeo-lead" style="font-size:16px;line-height:1.7;color:var(--text);max-width:760px;margin:24px auto 18px;padding:0 4px">
<strong>Number base conversion</strong> converts integers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Signed integers in binary use two's complement representation — the high bit indicates sign, and negative values are the bitwise inverse plus one. This <strong>free number base converter</strong> handles two's complement for negative numbers, missing from most online converters.
</p>
<section id="examples" style="max-width:760px;margin:24px auto 32px">
<h2 style="font-size:18px;margin-bottom:14px">Examples</h2>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Common conversions§§42 (decimal) = 101010 (binary) = 52 (octal) = 0x2A (hex)§§The same 6 bits viewed in 4 different bases.</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Hex for memory addresses§§Memory addresses use hex because each hex digit is exactly 4 bits — 0xFF is 1 byte, 0xFFFF is 2 bytes. Easier to read than binary, more compact than decimal.</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Two complement for negatives§§-5 in 8-bit two complement = 11111011 = 0xFB§§The high bit is the sign bit. To negate: invert all bits, add one. Used by every modern CPU to handle negative integers.</strong>
</div>
</section>
<aside class="founder-note" style="max-width:760px;margin:24px auto 32px;padding:20px 24px;background:rgba(0,208,132,0.05);border-left:3px solid var(--accent);border-radius:6px;font-size:14px;line-height:1.7;color:var(--text2)"><div style="font-family:var(--mono);font-size:11px;color:var(--accent);letter-spacing:1.5px;text-transform:uppercase;margin-bottom:10px;font-weight:600">💡 Why I built this</div><p style="margin:0 0 12px">I built this after debugging an embedded firmware bug where a signed 8-bit register read as 254 instead of -2. The conversion tool I was using only did unsigned, so I could not see what value the device was actually reporting. This converter supports two’s complement for negative numbers in binary and hex — the way actual hardware encodes signed integers. Critical for embedded, missing from most calculators.</p><p style="margin:0;font-size:13px;color:var(--text3)">— <a href="/about" style="color:var(--accent);text-decoration:none">Anees Ur Rehman</a>, full-stack developer</p></aside>
<section class="article-section">
<h2>Number bases explained — binary, octal, hex, decimal, and the math behind radix conversion</h2>
<p>If you have ever stared at <code>0xDEADBEEF</code> in a stack trace or typed <code>chmod 755</code> without thinking about it, you are already using positional number systems. This guide unpacks why programmers care about base-2, base-8, and base-16 — what each one buys you, how the conversion math actually works, what "two's complement" means in practice, and the language-specific syntax you need so the same number reads the same in JavaScript, Python, Go, Rust, and C.</p>
<h3>Positional notation — the one rule behind every base</h3>
<p>A number written in any base is a sum of digits multiplied by powers of that base. The decimal number 214 is <code>2×10² + 1×10¹ + 4×10⁰</code>. Take the same idea and swap 10 for any other base:</p>
<ul>
<li><strong>Binary 11010110</strong> = <code>1×2⁷ + 1×2⁶ + 0×2⁵ + 1×2⁴ + 0×2³ + 1×2² + 1×2¹ + 0×2⁰</code> = 128 + 64 + 16 + 4 + 2 = <strong>214</strong>.</li>
<li><strong>Octal 326</strong> = <code>3×8² + 2×8¹ + 6×8⁰</code> = 192 + 16 + 6 = <strong>214</strong>.</li>
<li><strong>Hexadecimal D6</strong> = <code>13×16¹ + 6×16⁰</code> = 208 + 6 = <strong>214</strong>.</li>
</ul>
<p>Notice that 214 has eight binary digits, three octal digits, three decimal digits, and two hex digits. Higher bases are denser — that is why programmers prefer hex over binary for byte-level work.</p>
<h3>Why each base matters</h3>
<table class="ref-table">
<thead><tr><th>Base</th><th>Digits</th><th>Where you see it</th></tr></thead>
<tbody>
<tr><td>Binary (2)</td><td>0, 1</td><td>Bit flags, hardware registers, network masks, low-level protocols.</td></tr>
<tr><td>Octal (8)</td><td>0–7</td><td>Unix file permissions (<code>chmod 755</code>), legacy PDP-11 systems, some C string escapes (<code>\137</code>).</td></tr>
<tr><td>Decimal (10)</td><td>0–9</td><td>Human-readable numbers, financial values, anything user-facing.</td></tr>
<tr><td>Hexadecimal (16)</td><td>0–9, A–F</td><td>Memory addresses, RGB color (<code>#FF5733</code>), MAC addresses, JWT signatures, hashes, byte dumps.</td></tr>
<tr><td>Base-32 / Base-36</td><td>0–9, A–V or A–Z</td><td>Crockford base32 in ULIDs, base36 in short-link IDs.</td></tr>
<tr><td>Base-58</td><td>Bitcoin alphabet (no 0, O, I, l)</td><td>Bitcoin addresses, Solana keys.</td></tr>
<tr><td>Base-64</td><td>A–Z, a–z, 0–9, +, /</td><td>Embedding binary in text (data URIs, basic auth, JWT body).</td></tr>
</tbody>
</table>
<p>Octal feels archaic, but every Unix admin uses it daily — <code>chmod 644 file</code> sets permissions to <code>110 100 100</code> in binary (rw- r-- r--).</p>
<h3>Two's complement — how computers represent negatives</h3>
<p>Computers store integers as fixed-width bit patterns. The trick to representing negative numbers is <strong>two's complement</strong>: the most-significant bit's place-value is negated. In an 8-bit signed integer, the leftmost bit's value is −128 instead of +128:</p>
<table class="ref-table">
<thead><tr><th>Binary (8 bits)</th><th>Unsigned</th><th>Signed (two's complement)</th></tr></thead>
<tbody>
<tr><td>00000000</td><td>0</td><td>0</td></tr>
<tr><td>00000001</td><td>1</td><td>1</td></tr>
<tr><td>01111111</td><td>127</td><td>127</td></tr>
<tr><td>10000000</td><td>128</td><td><strong>−128</strong></td></tr>
<tr><td>11111111</td><td>255</td><td><strong>−1</strong></td></tr>
</tbody>
</table>
<p>To negate a two's-complement number: invert every bit, then add 1. So +5 = <code>00000101</code>, invert → <code>11111010</code>, +1 → <code>11111011</code> = −5. The reason this encoding won is that addition and subtraction work the same circuit regardless of sign — no special case for negatives.</p>
<h3>Bitwise operators — what each one is for</h3>
<table class="ref-table">
<thead><tr><th>Operator</th><th>Effect</th><th>Use it for</th></tr></thead>
<tbody>
<tr><td><code>&</code> AND</td><td>1 only when both bits are 1</td><td>Mask: keep specific bits, drop the rest. <code>x & 0xFF</code> = low 8 bits.</td></tr>
<tr><td><code>|</code> OR</td><td>1 when either bit is 1</td><td>Set bits: <code>flags | READ</code> turns on READ.</td></tr>
<tr><td><code>^</code> XOR</td><td>1 when bits differ</td><td>Toggle bits, simple cipher round, parity check.</td></tr>
<tr><td><code>~</code> NOT</td><td>Flip every bit</td><td>Bitmask building: <code>~0xFF</code> clears low byte.</td></tr>
<tr><td><code><<</code> shift left</td><td>Multiply by 2 per shift</td><td>Build a single-bit mask: <code>1 << 7</code> = bit 7.</td></tr>
<tr><td><code>>></code> shift right (arithmetic)</td><td>Divide by 2; preserves sign bit</td><td>Sign-aware integer division by powers of 2.</td></tr>
<tr><td><code>>>></code> shift right (logical, JS)</td><td>Divide by 2; fills with 0</td><td>Treating the value as unsigned.</td></tr>
</tbody>
</table>
<h3>Bit width and overflow — the trap that bites every junior dev</h3>
<p>The same number can fit in 8, 16, 32, or 64 bits, with different limits at each width. The four widths you will see most:</p>
<table class="ref-table">
<thead><tr><th>Type</th><th>Bits</th><th>Unsigned range</th><th>Signed range</th></tr></thead>
<tbody>
<tr><td>byte / uint8</td><td>8</td><td>0 to 255</td><td>−128 to 127</td></tr>
<tr><td>short / int16</td><td>16</td><td>0 to 65 535</td><td>−32 768 to 32 767</td></tr>
<tr><td>int / int32</td><td>32</td><td>0 to 4 294 967 295</td><td>−2 147 483 648 to 2 147 483 647</td></tr>
<tr><td>long / int64</td><td>64</td><td>0 to 18.4 × 10¹⁸</td><td>−9.22 × 10¹⁸ to 9.22 × 10¹⁸</td></tr>
</tbody>
</table>
<p>The classic int32 overflow: <code>Math.pow(2, 31) - 1</code> in 32-bit signed wraps to −2 147 483 648 if you add 1. JavaScript number conversions to int32 (<code>x | 0</code>) hit this, and so does every <code>SELECT count(*)</code> on a table with billions of rows in a 32-bit-id schema. Use 64-bit types for anything that can grow.</p>
<h3>Number-base literals across 8 languages</h3>
<table class="ref-table">
<thead><tr><th>Language</th><th>Binary</th><th>Octal</th><th>Hex</th><th>Underscores</th></tr></thead>
<tbody>
<tr><td>JavaScript / TypeScript</td><td><code>0b1101</code></td><td><code>0o755</code></td><td><code>0xDEAD</code></td><td>Yes (<code>1_000_000</code>)</td></tr>
<tr><td>Python 3</td><td><code>0b1101</code></td><td><code>0o755</code></td><td><code>0xDEAD</code></td><td>Yes</td></tr>
<tr><td>Go</td><td><code>0b1101</code></td><td><code>0o755</code></td><td><code>0xDEAD</code></td><td>Yes (Go 1.13+)</td></tr>
<tr><td>Rust</td><td><code>0b1101</code></td><td><code>0o755</code></td><td><code>0xDEAD</code></td><td>Yes</td></tr>
<tr><td>Java 7+</td><td><code>0b1101</code></td><td><code>0755</code> (no o)</td><td><code>0xDEAD</code></td><td>Yes</td></tr>
<tr><td>C / C++14+</td><td><code>0b1101</code></td><td><code>0755</code></td><td><code>0xDEAD</code></td><td>Yes (C++14: <code>1'000'000</code>)</td></tr>
<tr><td>Ruby</td><td><code>0b1101</code></td><td><code>0755</code> or <code>0o755</code></td><td><code>0xDEAD</code></td><td>Yes</td></tr>
<tr><td>SQL (Postgres)</td><td><code>B'1101'</code></td><td>—</td><td><code>x'DEAD'</code></td><td>—</td></tr>
</tbody>
</table>
<p>The bare-leading-zero octal in C, C++, Java, Ruby (<code>0755</code>) is a historical hazard. <code>parseInt("08")</code> in old JavaScript returned 0 because of it; ES5 fixed that, but the lesson is to write <code>0o</code> explicitly.</p>
<h3>Common base-conversion mistakes</h3>
<ul>
<li><strong>Reading hex as decimal.</strong> <code>0x10</code> is <strong>16</strong>, not 10. Browser DevTools' "Memory" panel shows offsets in hex; mismatching it with decimal byte counts is a classic off-by-six bug.</li>
<li><strong>Forgetting that JavaScript bitwise ops truncate to int32.</strong> <code>0xFFFFFFFF | 0</code> is −1, not 4 294 967 295. For 64-bit arithmetic, use <code>BigInt</code>.</li>
<li><strong>Using <code>parseInt(str)</code> without a radix.</strong> Some older runtimes guess the base from a leading <code>0</code> or <code>0x</code>. Always pass the radix: <code>parseInt(str, 10)</code>, <code>parseInt(str, 16)</code>.</li>
<li><strong>Confusing chmod octal with permission bits.</strong> <code>chmod 755</code> = octal 755 = binary <code>111 101 101</code> = rwx r-x r-x. Do <em>not</em> write <code>chmod 0x755</code>.</li>
<li><strong>Mixing endian-ness.</strong> Network protocols are big-endian; x86 / ARM little-endian. When dumping a struct as hex bytes, the order on disk is the reverse of how you'd write the integer.</li>
<li><strong>Treating base-64 like a base.</strong> Base-64 is a binary-to-text encoding, not a positional numeral system. Padding (<code>=</code>) and 6-bit grouping have no analog in base-2/8/10/16.</li>
</ul>
<aside class="article-aside">
<strong>Authoritative references:</strong>
<ul>
<li><a href="https://en.cppreference.com/w/cpp/language/integer_literal" rel="noopener" target="_blank">cppreference — Integer literals (binary, octal, hex)</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#numeric_literals" rel="noopener" target="_blank">MDN — JavaScript numeric literals</a></li>
<li><a href="https://datatracker.ietf.org/doc/html/rfc4648" rel="noopener" target="_blank">RFC 4648 — base16, base32, base64 encodings</a></li>
<li><a href="https://man7.org/linux/man-pages/man1/chmod.1.html" rel="noopener" target="_blank">Linux chmod manpage — octal permission bits</a></li>
</ul>
</aside>
</section>
<!-- FAQ -->
<section class="faq-section">
<h2>Best number base converter for 2026 — what to compare</h2>
<p>Search results for "binary to decimal", "hex converter", "number base converter" return many tools but most fail on real-world numbers: they cap at 32-bit (silently truncating large values), they don't handle two's complement for negative numbers, they only support binary/octal/decimal/hex (skipping base32, base36, base58 for crypto), or they don't display the bit-length / grouped-nibble formatting needed for low-level debugging. Here's how the most-used base converters compare in 2026:</p>
<table class="ref-table">
<thead><tr><th>Tool</th><th>BigInt (no precision loss)</th><th>Bases supported</th><th>Two's complement</th><th>Bit length display</th><th>Cost</th></tr></thead>
<tbody>
<tr><td>FreeDevTool Number Base</td><td>Yes</td><td>2 through 36</td><td>Yes</td><td>Yes (with grouping)</td><td>Free</td></tr>
<tr><td>rapidtables.com/convert/number</td><td>32-bit limit</td><td>Bin/Oct/Dec/Hex</td><td>No</td><td>No</td><td>Free, ad-funded</td></tr>
<tr><td>binaryhexconverter.com</td><td>Limited</td><td>Bin/Oct/Dec/Hex</td><td>No</td><td>No</td><td>Free, ad-heavy</td></tr>
<tr><td>Windows Calculator (Programmer mode)</td><td>64-bit</td><td>Bin/Oct/Dec/Hex</td><td>Yes</td><td>Yes</td><td>Built-in</td></tr>
<tr><td>JavaScript <code>parseInt(str, base)</code></td><td>53-bit float</td><td>2-36</td><td>Manual</td><td>Manual</td><td>Built-in</td></tr>
<tr><td>Python <code>int(str, base)</code></td><td>Arbitrary precision</td><td>2-36</td><td>Manual</td><td>Manual</td><td>Built-in</td></tr>
</tbody>
</table>
<h3>How do I convert binary to decimal (or hex to decimal) online?</h3>
<p>Type your binary number in the binary input field — decimal, octal, and hex update instantly. The converter uses JavaScript BigInt internally so a 200-bit binary number converts without precision loss (unlike <code>parseInt</code> which silently rounds past 53 bits). For binary like <code>11010110</code>: type or paste the digits, see decimal <code>214</code>, hex <code>0xD6</code>, octal <code>0o326</code> instantly. For hex with prefix: type <code>0xDEADBEEF</code> or just <code>DEADBEEF</code> — both parse. The bit-length indicator shows the minimum bits required (8 bits for <code>0xD6</code>, 32 bits for <code>0xDEADBEEF</code>) which matters for fixed-width register debugging.</p>
<h3>What's the difference between binary, octal, decimal, hex, and base64?</h3>
<table class="ref-table">
<thead><tr><th>Base</th><th>Digits used</th><th>Common use</th></tr></thead>
<tbody>
<tr><td>Binary (2)</td><td>0, 1</td><td>Bitwise ops, low-level memory representation</td></tr>
<tr><td>Octal (8)</td><td>0-7</td><td>Unix file permissions (chmod 755)</td></tr>
<tr><td>Decimal (10)</td><td>0-9</td><td>Default human notation</td></tr>
<tr><td>Hexadecimal (16)</td><td>0-9, a-f</td><td>Color codes (#FF0000), memory addresses, byte representation</td></tr>
<tr><td>Base32 (Crockford)</td><td>0-9, a-z minus i, l, o, u</td><td>ULID, AWS S3 ARN, human-typeable IDs</td></tr>
<tr><td>Base36</td><td>0-9, a-z</td><td>Compact alphanumeric IDs, short URL slugs</td></tr>
<tr><td>Base58 (Bitcoin)</td><td>1-9, A-Z, a-z minus 0/O/I/l</td><td>Bitcoin/Monero addresses, short IDs</td></tr>
<tr><td>Base64</td><td>A-Z, a-z, 0-9, +, /</td><td>Binary-to-text encoding (use <a href="/base64-encoder">Base64 Encoder</a>)</td></tr>
</tbody>
</table>
<p>Decision rule: bitwise debugging → binary. Linux file perms → octal. Color/memory/byte → hex. Database short IDs → base36. Crypto / Bitcoin → base58. Binary blob in JSON → base64 (different operation, see <a href="/base64-encoder">Base64 Encoder</a>).</p>
<h3>Number base converter alternative to rapidtables.com — 4 reasons developers switched</h3>
<ol>
<li><strong>BigInt support — no 32-bit truncation.</strong> rapidtables silently truncates numbers above 2^32. This converter handles arbitrary-precision integers (200+ bits) for debugging large hashes or hex memory dumps.</li>
<li><strong>Two's complement for negative numbers.</strong> Type <code>-1</code> and see the two's-complement bit pattern at any bit-width (8/16/32/64) — useful for embedded systems and bit-flag debugging.</li>
<li><strong>Bases 2 through 36, not just 4.</strong> base32 (Crockford), base36 (short IDs), and any custom radix work in addition to binary/octal/decimal/hex.</li>
<li><strong>No ads, no popups.</strong> rapidtables and binaryhexconverter both inject ads. This page is browser-only and ad-free.</li>
</ol>
<p>Pair the number base converter with the <a href="/hex-to-rgb">Hex to RGB Converter</a> for color work, the <a href="/chmod-calculator">Chmod Calculator</a> for octal Unix permissions, the <a href="/byte-converter">Byte Converter</a> for KB/MB/GB conversion, and the <a href="/encoding-tools">Encoding Tools hub</a> for the broader transform toolkit.</p>
<h2>Frequently Asked Questions</h2>
<div class="faq-item open">
<div class="faq-q" onclick="toggleFaq(this)">
How do I convert binary to decimal?
<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="faq-a">
To convert binary to decimal, multiply each bit by 2 raised to the power of its position (starting from 0 on the right) and sum the results. For example, binary <code>1011</code> = (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2&sup0;) = 8 + 0 + 2 + 1 = <strong>11</strong> in decimal. This positional notation principle applies to all numeral systems — the digit value is multiplied by the base raised to its position index.
</div>
</div>
<div class="faq-item">
<div class="faq-q" onclick="toggleFaq(this)">
What is hexadecimal and why is it used in programming?
<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="faq-a">
Hexadecimal (base-16) uses digits <code>0–9</code> and letters <code>A–F</code>. Each hex digit maps to exactly 4 binary bits (a nibble), making it a compact way to represent binary data. For example, <code>0xFF</code> = <code>11111111</code> in binary = <code>255</code> in decimal. Programmers use hex for memory addresses, color codes, byte values, and bitwise operations because it is far more readable than long binary strings while maintaining a direct relationship with the underlying binary system.
</div>
</div>
<div class="faq-item">
<div class="faq-q" onclick="toggleFaq(this)">
How do I convert between octal and binary?
<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="faq-a">
Each octal digit corresponds to exactly 3 binary bits. To convert octal to binary, replace each digit with its 3-bit binary equivalent: 0=<code>000</code>, 1=<code>001</code>, 2=<code>010</code>, 3=<code>011</code>, 4=<code>100</code>, 5=<code>101</code>, 6=<code>110</code>, 7=<code>111</code>. For example, octal <code>357</code> = <code>011 101 111</code> in binary. To go from binary to octal, group binary digits into sets of 3 from the right and convert each group to its octal equivalent.
</div>
</div>
<div class="faq-item">
<div class="faq-q" onclick="toggleFaq(this)">
What bases are commonly used in computer science?
<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="faq-a">
The most common bases are: <strong>Binary (base-2)</strong> — the fundamental language of computers, using 0s and 1s. <strong>Octal (base-8)</strong> — used in Unix file permissions and some legacy systems. <strong>Decimal (base-10)</strong> — the standard human numeral system. <strong>Hexadecimal (base-16)</strong> — widely used for memory addresses, color codes, and representing byte values compactly. Some systems also use base-36 (digits + entire alphabet) for compact ID encoding.
</div>
</div>
<div class="faq-item">
<div class="faq-q" onclick="toggleFaq(this)">
What is the difference between signed and unsigned binary numbers?
<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="faq-a">
<strong>Unsigned</strong> binary numbers represent only non-negative values — an 8-bit unsigned number ranges from 0 to 255. <strong>Signed</strong> binary uses the most significant bit (MSB) as a sign indicator. In two's complement (the most common signed representation), an 8-bit signed number ranges from −128 to 127. The binary value <code>11111111</code> is 255 when unsigned, but −1 in signed two's complement. Understanding this distinction is crucial for low-level programming and bitwise operations in languages like C and Rust.
</div>
</div>
</section>
<!-- Related Tools -->
<section class="related-section">
<h2>Related Tools</h2>
<div class="related-grid">
<a class="related-card" href="hash-generator">
<div class="related-icon">#</div>
<div class="related-card-info">
<div class="related-card-name">Hash Generator</div>
<div class="related-card-desc">Generate MD5, SHA-256, SHA-512 hashes</div>
</div>
</a>
<a class="related-card" href="hex-to-rgb">
<div class="related-icon">&127912;</div>
<div class="related-card-info">
<div class="related-card-name">Hex to RGB</div>
<div class="related-card-desc">Convert hex color codes to RGB and HSL</div>
</div>
</a>
<a class="related-card" href="timestamp-diff">
<div class="related-icon">&9201;</div>
<div class="related-card-info">
<div class="related-card-name">Timestamp Diff Calculator</div>
<div class="related-card-desc">Calculate time differences between timestamps</div>
</div>
</a>
</div>
</section>
<section class="all-tools-section" aria-label="Browse all FreeDevTool developer tools">
<h2>Browse all 50 free developer tools</h2>
<p class="atc-sub">All tools run in your browser, no signup required, nothing sent to a server.</p>
<div class="all-tools-grid">
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">b64</div>
<div class="atc-cat-title"><h3>Encoding & Conversion</h3><span class="atc-cat-count">11 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/base64-encoder">Base64 Encoder / Decoder</a></li>
<li><a href="/base64-image">Image to Base64</a></li>
<li><a href="/byte-converter">Byte Converter (KB / MB / GB)</a></li>
<li><a href="/case-converter">Case Converter</a></li>
<li><a href="/hex-to-rgb">Hex to RGB / HSL</a></li>
<li><a href="/html-entity">HTML Entity Encoder</a></li>
<li><a href="/json-to-csv">JSON to CSV Converter</a></li>
<li><a href="/px-to-rem">PX to REM Converter</a></li>
<li><a href="/string-escape">String Escape / Unescape</a></li>
<li><a href="/url-encoder">URL Encoder / Decoder</a></li>
<li><a href="/yaml-to-json">YAML to JSON Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">{ }</div>
<div class="atc-cat-title"><h3>Formatting & Generators</h3><span class="atc-cat-count">13 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/color-name">Color Name from Hex</a></li>
<li><a href="/color-picker">Color Palette Picker</a></li>
<li><a href="/css-box-shadow">CSS Box Shadow</a></li>
<li><a href="/css-gradient">CSS Gradient Generator</a></li>
<li><a href="/json-formatter">JSON Formatter / Validator</a></li>
<li><a href="/lorem-ipsum">Lorem Ipsum Generator</a></li>
<li><a href="/markdown-preview">Markdown Preview</a></li>
<li><a href="/password-generator">Password Generator</a></li>
<li><a href="/qr-generator">QR Code Generator</a></li>
<li><a href="/sql-formatter">SQL Formatter</a></li>
<li><a href="/uuid-generator">UUID Generator</a></li>
<li><a href="/word-to-markdown">Word to Markdown</a></li>
<li><a href="/xml-formatter">XML Formatter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">JS</div>
<div class="atc-cat-title"><h3>Minifiers & DevOps</h3><span class="atc-cat-count">6 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/chmod-calculator">chmod Calculator</a></li>
<li><a href="/cron-parser">Cron Expression Parser</a></li>
<li><a href="/css-minifier">CSS Minifier</a></li>
<li><a href="/html-minifier">HTML Minifier</a></li>
<li><a href="/js-minifier">JavaScript Minifier</a></li>
<li><a href="/http-status">HTTP Status Codes</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">#</div>
<div class="atc-cat-title"><h3>Security & Hashing</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/hash-generator">Hash Generator (MD5, SHA)</a></li>
<li><a href="/jwt-decoder">JWT Decoder</a></li>
<li><a href="/jwt-generator">JWT Generator</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">.*</div>
<div class="atc-cat-title"><h3>Code & Text</h3><span class="atc-cat-count">8 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/ai-token-counter">AI Token Counter</a></li>
<li><a href="/char-counter">Character & Word Counter</a></li>
<li><a href="/git-cheatsheet">Git Commands Cheatsheet</a></li>
<li><a href="/number-base">Number Base Converter</a></li>
<li><a href="/regex-explainer">Regex Explainer</a></li>
<li><a href="/regex-tester">Regex Tester</a></li>
<li><a href="/text-diff">Text Diff Checker</a></li>
<li><a href="/wcag-contrast">WCAG Contrast Checker</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">IP</div>
<div class="atc-cat-title"><h3>Network & APIs</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/dns-lookup">DNS Lookup</a></li>
<li><a href="/http-request-builder">HTTP Request Builder</a></li>
<li><a href="/ip-lookup">IP Address Lookup</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">⏱</div>
<div class="atc-cat-title"><h3>Time & Dates</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/relative-time">Relative Time Calculator</a></li>
<li><a href="/timestamp-diff">Timestamp Diff</a></li>
<li><a href="/unix-timestamp-converter">Unix Timestamp Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">SEO</div>
<div class="atc-cat-title"><h3>SEO & Meta</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/meta-tag-generator">Meta Tag Generator</a></li>
<li><a href="/og-preview">Open Graph Preview</a></li>
<li><a href="/slug-generator">URL Slug Generator</a></li>
</ul>
</div>
</div>
</section>
</div>
<footer>
<div>© 2026 FreeDevTool — Number Base Converter</div>
<div class="footer-links">
<a href="/all-tools">All Tools</a>
<a href="/about">About</a>
<a href="/privacy">Privacy Policy</a>
<a href="/terms">Terms of Use</a>
</div>
</footer>
<script>
const BASES = {
bin: { radix: 2, id: 'input-bin', err: 'err-bin', field: 'field-bin', chars: /^[01]+$/ },
oct: { radix: 8, id: 'input-oct', err: 'err-oct', field: 'field-oct', chars: /^[0-7]+$/ },
dec: { radix: 10, id: 'input-dec', err: 'err-dec', field: 'field-dec', chars: /^[0-9]+$/ },
hex: { radix: 16, id: 'input-hex', err: 'err-hex', field: 'field-hex', chars: /^[0-9a-fA-F]+$/ }
};
function validCharsForBase(radix) {
const digits = '0123456789abcdefghijklmnopqrstuvwxyz'.slice(0, radix);
return new RegExp('^[' + digits + ']+$', 'i');
}
function bigIntToBase(n, radix) {
if (n === 0n) return '0';
const base = BigInt(radix);
const digits = '0123456789abcdefghijklmnopqrstuvwxyz';
let result = '';
let val = n < 0n ? -n : n;
while (val > 0n) {
result = digits[Number(val % base)] + result;
val = val / base;
}
return (n < 0n ? '-' : '') + result;
}
function parseBigInt(str, radix) {
str = str.trim().toLowerCase();
if (!str) return null;
const base = BigInt(radix);
const digits = '0123456789abcdefghijklmnopqrstuvwxyz';
let result = 0n;
for (let i = 0; i < str.length; i++) {
const d = digits.indexOf(str[i]);
if (d < 0 || d >= radix) return null;
result = result * base + BigInt(d);
}
return result;
}
function clearErrors() {
Object.keys(BASES).forEach(k => {
document.getElementById(BASES[k].err).style.display = 'none';
document.getElementById(BASES[k].id).classList.remove('invalid');
document.getElementById(BASES[k].field).classList.remove('has-error');
});
document.getElementById('err-custom').style.display = 'none';
document.getElementById('input-custom').classList.remove('invalid');
}
function showError(errId, inputId, fieldId, msg) {
const el = document.getElementById(errId);
el.textContent = '\u2717 ' + msg;
el.style.display = 'block';
if (inputId) document.getElementById(inputId).classList.add('invalid');
if (fieldId) document.getElementById(fieldId).classList.add('has-error');
}
function convert(source) {
clearErrors();
let value;
if (source === 'custom') {
const radix = parseInt(document.getElementById('custom-radix').value);
if (isNaN(radix) || radix < 2 || radix > 36) {
showError('err-custom', 'input-custom', null, 'Base must be between 2 and 36');
return;
}
const raw = document.getElementById('input-custom').value.trim();
if (!raw) { clearFields(); return; }
if (!validCharsForBase(radix).test(raw)) {
showError('err-custom', 'input-custom', null, 'Invalid characters for base ' + radix);
return;
}
value = parseBigInt(raw, radix);
if (value === null) {
showError('err-custom', 'input-custom', null, 'Invalid number');
return;
}
} else {
const b = BASES[source];
const raw = document.getElementById(b.id).value.trim();
if (!raw) { clearFields(); return; }
if (!b.chars.test(raw)) {
showError(b.err, b.id, b.field, 'Invalid characters for base ' + b.radix);
return;
}
value = parseBigInt(raw, b.radix);
if (value === null) {
showError(b.err, b.id, b.field, 'Invalid number');
return;
}
}
// Update all fields except source
Object.keys(BASES).forEach(k => {
if (k !== source) {
document.getElementById(BASES[k].id).value = bigIntToBase(value, BASES[k].radix).toUpperCase();
}
});
// Hex field: always uppercase
if (source === 'hex') {
// keep user input as-is
} else {
document.getElementById('input-hex').value = bigIntToBase(value, 16).toUpperCase();
}
// Update custom base
if (source !== 'custom') {
const radix = parseInt(document.getElementById('custom-radix').value);
if (!isNaN(radix) && radix >= 2 && radix <= 36) {
document.getElementById('input-custom').value = bigIntToBase(value, radix);
}
}
updateInfo(value);
updateNibbles(value);
}
function clearFields() {
Object.keys(BASES).forEach(k => {
document.getElementById(BASES[k].id).value = '';
});
document.getElementById('input-custom').value = '';
document.getElementById('info-bits').textContent = '\u2014';
document.getElementById('info-fit').textContent = '\u2014';
document.getElementById('nibble-display').style.display = 'none';
}
function updateInfo(value) {
if (value === null || value === undefined) return;