Binary, Decimal, Hex & Octal Converter

Type a number in binary, octal, decimal, hexadecimal or any base from 2 to 36, or paste text or Base64, and see every other form at once. Numbers of any size are handled exactly, fractions convert to binary with the precision you choose, and a signed option shows the two’s complement bit pattern at 8, 16, 32 or 64 bits.

One converter for every number base

Choose what you are converting from and to, then type. The result you asked for appears in the highlighted box, and every other representation (binary, octal, decimal, hexadecimal, a custom base, text and Base64) is listed underneath, so you rarely need a second tool. Values of any length are converted exactly: a 300-digit decimal number or a 4,000-bit hex string is no problem, because the converter uses arbitrary-precision integers rather than JavaScript’s 53-bit numbers. Invalid digits are reported with their position, for example a 2 in a binary number or a G in hex.

How positional notation works

Every base works the same way. A number is a row of digits, and each position is worth the base raised to a power, counting from 0 on the right. In decimal (base 10) the number 347 means 3×100 + 4×10 + 7×1. In binary (base 2) the positions are worth 1, 2, 4, 8, 16 and so on, so 1011 means 1×8 + 0×4 + 1×2 + 1×1 = 11. Octal uses powers of 8 and the digits 0–7; hexadecimal uses powers of 16 and needs six extra digits, A–F, for the values 10–15. Bases above 16 simply continue through the alphabet, up to base 36, where Z means 35.

BaseNameDigitsPlace values255 written in it
2Binary0 11, 2, 4, 8, 16…11111111
8Octal0–71, 8, 64, 512…377
10Decimal0–91, 10, 100, 1000…255
16Hexadecimal0–9, A–F1, 16, 256, 4096…FF
36Base 360–9, A–Z1, 36, 1296…73

Worked examples for each conversion

Binary to decimal

Multiply each bit by its place value and add. For 110101: 32 + 16 + 0 + 4 + 0 + 1 = 53. A quicker way for long numbers is doubling: start at 0 and, for each bit from the left, double the total and add the bit (0→1→3→6→13→26→53).

Decimal to binary, octal and hex

Divide repeatedly by the target base and read the remainders from bottom to top. 53 ÷ 2 gives remainders 1, 0, 1, 0, 1, 1, so 53 = 110101. The same method with 8 gives 65, and with 16 gives 35. For 3735928559 ÷ 16 the remainders spell DEADBEEF.

Binary to hex and octal (and back)

No arithmetic is needed. Each hex digit is exactly four bits and each octal digit exactly three, so split the binary number into groups from the right: 1101 0101 is D5 in hex, and 11 010 101 is 325 in octal. To go back, expand each hex digit to four bits (F → 1111, 7 → 0111) or each octal digit to three.

Hex to decimal and octal

Hex 2F is 2×16 + 15 = 47. To reach octal, the easiest route is through binary: 2F = 0010 1111 = 101 111 = 57. Octal to hex works the same way in reverse.

Octal to decimal

Octal 755, the familiar Unix permission, is 7×64 + 5×8 + 5 = 493. Each octal digit is also one permission group: 7 = rwx, 5 = r-x.

Decimal to ASCII

Enter several decimal codes separated by spaces or commas and each one becomes a character: 72 101 108 108 111 reads Hello. Values above 127 are treated as Unicode code points, so 233 is é and 128512 is 😀.

Base64 to binary, hex and octal

Base64 is not a number base in the usual sense; it is a way of writing bytes with 64 printable characters. Choose Base64 as the input and the tool decodes it to bytes and shows each byte in binary, hex and octal: SGVsbG8= is the five bytes 48 65 6C 6C 6F, which is the text “Hello”.

Binary and hex to Base64

Going the other way, a binary string is cut into bytes (eight bits each, padded on the left) and a hex string into pairs of digits, and those bytes are encoded. 48656C6C6F in hex becomes SGVsbG8=. Leading zero bytes are kept, so 0001 in hex encodes as AAE=.

Negative numbers and two’s complement

Computers store signed integers in two’s complement: a negative number −n in a w-bit field is stored as 2w − n. In 8 bits, −5 is 256 − 5 = 251 = 11111011 = FB. The top bit doubles as a sign bit, and adding numbers works the same whether they are signed or not. Choose 8, 16, 32 or 64 bits in Signed to see the stored bit pattern of a negative decimal, or to read a binary or hex pattern such as FFFFFFFE as a signed value (−2 in 32 bits). The tool also shows the unsigned reading and warns when a value does not fit, for example −129 in 8 bits, whose range is −128 to 127. With Signed off, negative numbers are simply written with a minus sign in every base.

WidthSigned range−1 is stored as
8-bit−128 to 127FF
16-bit−32,768 to 32,767FFFF
32-bit−2,147,483,648 to 2,147,483,647FFFFFFFF
64-bitabout ±9.22 × 1018FFFFFFFFFFFFFFFF

Fractions: decimal to binary

For the part after the point, multiply by the target base and take the whole-number part as the next digit. 0.625 × 2 = 1.25 (digit 1), 0.25 × 2 = 0.5 (digit 0), 0.5 × 2 = 1.0 (digit 1), so 10.625 = 1010.101. Many decimal fractions never end in binary: 0.1 becomes 0.000110011001100… repeating forever, which is why 0.1 + 0.2 is not exactly 0.3 in most programming languages. Set Fraction digits to choose where to stop; a trailing … tells you the result was cut off. Fractional binary, octal and hex inputs convert back to exact decimals.

Grouping, case and multiple values

Long binary numbers are easier to read in groups: choose nibbles (four bits, one hex digit) or bytes (eight bits). Hex can be shown in upper or lower case. Spaces and commas in the input are treated automatically: in decimal they separate several values, while in binary and hex they are assumed to be digit grouping inside one number. Change Spaces and commas to override that. Links such as ?mode=binary-to-decimal or ?mode=decimal-to-ascii open the converter with that pair already chosen.

Conversion table 0–255

The first 16 values are worth memorizing; the full byte range is in the expandable table below.

DecHexBinaryDecHexBinary
000000881000
110001991001
22001010A1010
33001111B1011
44010012C1100
55010113D1101
66011014E1110
77011115F1111
Show the full 0–255 conversion table (decimal, hex, octal, binary, ASCII)
DecHexOctBinaryASCII
00000000000000NUL
10100100000001
20200200000010
30300300000011
40400400000100
50500500000101
60600600000110
70700700000111
80801000001000
90901100001001TAB
100A01200001010LF
110B01300001011
120C01400001100
130D01500001101CR
140E01600001110
150F01700001111
161002000010000
171102100010001
181202200010010
191302300010011
201402400010100
211502500010101
221602600010110
231702700010111
241803000011000
251903100011001
261A03200011010
271B03300011011
281C03400011100
291D03500011101
301E03600011110
311F03700011111
322004000100000space
332104100100001!
342204200100010"
352304300100011#
362404400100100$
372504500100101%
382604600100110&
392704700100111'
402805000101000(
412905100101001)
422A05200101010*
432B05300101011+
442C05400101100,
452D05500101101-
462E05600101110.
472F05700101111/
4830060001100000
4931061001100011
5032062001100102
5133063001100113
5234064001101004
5335065001101015
5436066001101106
5537067001101117
5638070001110008
5739071001110019
583A07200111010:
593B07300111011;
603C07400111100<
613D07500111101=
623E07600111110>
633F07700111111?
644010001000000@
654110101000001A
664210201000010B
674310301000011C
684410401000100D
694510501000101E
704610601000110F
714710701000111G
724811001001000H
734911101001001I
744A11201001010J
754B11301001011K
764C11401001100L
774D11501001101M
784E11601001110N
794F11701001111O
805012001010000P
815112101010001Q
825212201010010R
835312301010011S
845412401010100T
855512501010101U
865612601010110V
875712701010111W
885813001011000X
895913101011001Y
905A13201011010Z
915B13301011011[
925C13401011100\
935D13501011101]
945E13601011110^
955F13701011111_
966014001100000`
976114101100001a
986214201100010b
996314301100011c
1006414401100100d
1016514501100101e
1026614601100110f
1036714701100111g
1046815001101000h
1056915101101001i
1066A15201101010j
1076B15301101011k
1086C15401101100l
1096D15501101101m
1106E15601101110n
1116F15701101111o
1127016001110000p
1137116101110001q
1147216201110010r
1157316301110011s
1167416401110100t
1177516501110101u
1187616601110110v
1197716701110111w
1207817001111000x
1217917101111001y
1227A17201111010z
1237B17301111011{
1247C17401111100|
1257D17501111101}
1267E17601111110~
1277F17701111111DEL
1288020010000000·
1298120110000001·
1308220210000010·
1318320310000011·
1328420410000100·
1338520510000101·
1348620610000110·
1358720710000111·
1368821010001000·
1378921110001001·
1388A21210001010·
1398B21310001011·
1408C21410001100·
1418D21510001101·
1428E21610001110·
1438F21710001111·
1449022010010000·
1459122110010001·
1469222210010010·
1479322310010011·
1489422410010100·
1499522510010101·
1509622610010110·
1519722710010111·
1529823010011000·
1539923110011001·
1549A23210011010·
1559B23310011011·
1569C23410011100·
1579D23510011101·
1589E23610011110·
1599F23710011111·
160A024010100000·
161A124110100001·
162A224210100010·
163A324310100011·
164A424410100100·
165A524510100101·
166A624610100110·
167A724710100111·
168A825010101000·
169A925110101001·
170AA25210101010·
171AB25310101011·
172AC25410101100·
173AD25510101101·
174AE25610101110·
175AF25710101111·
176B026010110000·
177B126110110001·
178B226210110010·
179B326310110011·
180B426410110100·
181B526510110101·
182B626610110110·
183B726710110111·
184B827010111000·
185B927110111001·
186BA27210111010·
187BB27310111011·
188BC27410111100·
189BD27510111101·
190BE27610111110·
191BF27710111111·
192C030011000000·
193C130111000001·
194C230211000010·
195C330311000011·
196C430411000100·
197C530511000101·
198C630611000110·
199C730711000111·
200C831011001000·
201C931111001001·
202CA31211001010·
203CB31311001011·
204CC31411001100·
205CD31511001101·
206CE31611001110·
207CF31711001111·
208D032011010000·
209D132111010001·
210D232211010010·
211D332311010011·
212D432411010100·
213D532511010101·
214D632611010110·
215D732711010111·
216D833011011000·
217D933111011001·
218DA33211011010·
219DB33311011011·
220DC33411011100·
221DD33511011101·
222DE33611011110·
223DF33711011111·
224E034011100000·
225E134111100001·
226E234211100010·
227E334311100011·
228E434411100100·
229E534511100101·
230E634611100110·
231E734711100111·
232E835011101000·
233E935111101001·
234EA35211101010·
235EB35311101011·
236EC35411101100·
237ED35511101101·
238EE35611101110·
239EF35711101111·
240F036011110000·
241F136111110001·
242F236211110010·
243F336311110011·
244F436411110100·
245F536511110101·
246F636611110110·
247F736711110111·
248F837011111000·
249F937111111001·
250FA37211111010·
251FB37311111011·
252FC37411111100·
253FD37511111101·
254FE37611111110·
255FF37711111111·

Frequently asked questions

How do I convert binary to decimal?

Multiply each bit by its place value (1, 2, 4, 8 and so on from the right) and add the results. For example 1011 is 8 + 0 + 2 + 1 = 11. Choose Binary to Decimal above and the converter does it instantly, for numbers of any length.

How do I convert decimal to hexadecimal?

Divide the number by 16 repeatedly and write the remainders from last to first, using A to F for 10 to 15. For example 255 is FF and 3735928559 is DEADBEEF.

Can the converter handle very large numbers?

Yes. It uses arbitrary-precision integers, so numbers with hundreds or thousands of digits convert exactly without rounding.

How are negative numbers converted to binary?

With Signed off, a minus sign is kept, so -10 is -1010. With Signed set to 8, 16, 32 or 64 bits, the two’s complement pattern is shown, so -5 in 8 bits is 11111011 (FB).

Can I convert decimal codes to ASCII text?

Yes. Choose Decimal to Text and enter codes separated by spaces or commas, for example 72 101 108 108 111 gives Hello. Values above 127 are treated as Unicode code points.

How do I convert Base64 to hex or binary?

Choose Base64 as the input. The text is decoded to bytes and each byte is shown in hex, binary, octal and decimal, along with the decoded text.

Why does 0.1 become a long repeating binary number?

Because 1/10 cannot be written exactly with powers of two, just as 1/3 cannot be written exactly in decimal. The converter stops after the number of fraction digits you choose and marks the cut with an ellipsis.