Base Converter

Enter a Number and Select Bases to Convert Instantly

Result:

Converted value will appear here

Calculation steps:

Step-by-step conversion will be shown here

About the Base Converter

This free, browser-based Base Converter lets you convert numbers between any two bases from 2 to 36. It supports all common number bases, including binary (2), octal (8), decimal (10), and hexadecimal (16), along with other bases. Every result comes with the working laid out step by step, so you can check homework or follow the method as you learn it.

Contents [hideshow]

What is a Number Base?

A number base, also called a radix, is how many different digits a number system has before it runs out and has to start a new column. We count in base 10, most likely because we have ten fingers, so we get ten digits: 0 to 9. After 9 there is no single digit left, so we write 10, meaning one ten and no ones.

Every other base works the same way. It just runs out sooner or later. Binary (base 2) runs out after 1, so two is written 10. Hexadecimal (base 16) gets all the way to fifteen before it needs a second column. That is why the same digits can stand for different amounts: 101 is five in binary, ten in base 3, and a hundred and one in decimal. Before you convert anything, make sure you know which base it is in.

How Place Value Works

In any base, each column is worth the base times the column to its right. In decimal the columns are 1, 10, 100, and 1,000. In binary they are 1, 2, 4, 8, and 16. In hexadecimal they are 1, 16, 256, and 4,096. So 4,072 is really shorthand for:

4,072 = (4 × 1,000) + (0 × 100) + (7 × 10) + (2 × 1)

Textbooks write the columns as powers of the base, counting from 0 on the right, so 10⁰ = 1, 10¹ = 10, and 10² = 100. To make the base clear, they add it as a small number after the value, as in 101₂ for binary and 101₁₀ for decimal. The leftmost digit is the most significant digit, and the rightmost is the least significant. In binary these are called the most and least significant bits (MSB and LSB).

Bases from 2 to 36

The converter handles every base from 2 to 36. Here is the number 500 written in the ones you are most likely to come across:

Base Name Digits Used 500 in This Base
2Binary0–1111110100
3Ternary0–2200112
4Quaternary0–313310
5Quinary0–44000
6Senary0–52152
7Septenary0–61313
8Octal0–7764
10Decimal0–9500
12Duodecimal0–9, A, B358
16Hexadecimal0–9, A–F1F4
20Vigesimal0–9, A–J150
32Base 320–9, A–VFK
36Base 360–9, A–ZDW

Some of these have a life outside computing. Base 12 lives on in dozens, inches in a foot, and the hours on a clock face, and supporters of base 12 often write ten and eleven as ↊ and ↋ instead of A and B. The Maya counted in base 20, and you can still hear it in French, where 80 is quatre-vingts, or 'four twenties'. Base 60 from ancient Mesopotamia is why an hour has 60 minutes. It needs 60 digit symbols, more than 0 to 9 and A to Z can supply.

Digit Values Above 9

Bases above 10 need more than ten digits, so they borrow letters. A is 10, B is 11, and so on up to Z, which is 35. Base 36 is the biggest base that fits into 0 to 9 plus A to Z, which is why most tools, this one included, stop there. Letters are not case-sensitive, so ff and FF are the same number.

Letter Value Letter Value Letter Value
A10J19S28
B11K20T29
C12L21U30
D13M22V31
E14N23W32
F15O24X33
G16P25Y34
H17Q26Z35
I18R27

How to Use the Syntax Toolbox Base Converter?

  1. Under 'From:', pick the base your number is written in. Binary, octal, decimal, and hexadecimal sit at the top, and the rest are under 'Extended Alphanumeric Bases'.
  2. Under 'To:', pick the base you want. The arrow button between the two swaps them.
Pick the base you have and the base you want
  1. Type your number. A minus sign and a decimal point are fine, and so are spaces or underscores between digits. You can also paste values with a 0b, 0o, or 0x prefix, as long as the prefix matches the 'From' base.

Long results are easier to read with 'Group digits' switched on. Binary splits into blocks of four, hexadecimal into pairs, and decimal into thousands. The spaces are for display only, so the copy buttons always give you the plain number.

0xFFFFFFFF in binary, with Group digits switched on
  1. Read the result, then look at 'Calculation steps' underneath for the full working.
  2. Scroll down to see the same value in binary, octal, decimal, duodecimal, hexadecimal, base 32, and base 36.
Calculation steps for 5.6875 in binary
  1. For whole numbers, the 'Two's Complement and Bits' box shows how many bits the value needs and its bit pattern at 8, 16, 32, 64, or 128 bits.
−5 as an 8-bit two's complement pattern

How to Convert Between Any Two Bases

Any conversion can be done in two steps. Turn the number into decimal, then turn that decimal into the base you want. If one of the bases is already 10, you only need one of the steps.

Any Base to Decimal

Multiply each digit by its place value and add everything up. Take 2C9 in hexadecimal. C is 12, and the place values from the right are 1, 16, and 256:

2C9₁₆ = (2 × 256) + (12 × 16) + (9 × 1)

= 512 + 192 + 9 = 713

It works just as well for a base you rarely see. In base 3 the place values are 1, 3, 9, and 27:

1201₃ = (1 × 27) + (2 × 9) + (0 × 3) + (1 × 1)

= 27 + 18 + 0 + 1 = 46

As a formula, a number with digits dₙ … d₁ d₀ in base b is worth dₙ × bⁿ + … + d₁ × b¹ + d₀ × b⁰.

Decimal to Any Base

To go the other way, use repeated division. Divide by the new base and write down the remainder, then divide the quotient again. Stop when the quotient reaches 0 and read the remainders from the bottom up. Here is 713 in octal:

Division Quotient Remainder
713 ÷ 8891
89 ÷ 8111
11 ÷ 813
1 ÷ 801

Reading upward gives 713₁₀ = 1311₈. The first remainder you find is the last digit of the answer, and reading them in the wrong order is a common slip. A remainder of 10 or more turns into a letter, so 11 in base 16 is written B.

Between Two Bases When Neither is Decimal

Use decimal as a stopover. To turn 1201₃ into base 7, first expand it to 46 as shown above. Then divide by 7: 46 ÷ 7 = 6 remainder 4, and 6 ÷ 7 = 0 remainder 6. Reading upward, 1201₃ = 64₇. If you pick two non-decimal bases in the converter, the calculation steps show both halves one after the other.

The Shortcut for Binary, Octal, and Hexadecimal

When both bases are powers of 2, you can skip decimal altogether. One octal digit is always exactly 3 bits (2³ = 8), and one hex digit is exactly 4 bits (2⁴ = 16). Group the binary digits from the right and swap each group for a single digit:

101110101100₂

Groups of 4: 1011 1010 1100 → B A C → BAC₁₆

Groups of 3: 101 110 101 100 → 5 6 5 4 → 5654₈

If the leftmost group comes up short, pad it with zeros, so 11 becomes 0011. To get from hex to octal, write each hex digit as 4 bits and regroup in threes: 7C₁₆ is 0111 1100, which regroups as 001 111 100, or 174₈. That is why programmers use hex so much: each hex digit stands for exactly four bits, so a binary number shrinks to a quarter of its length.

Worked Examples for Common Conversions

Each of these everyday conversions uses the steps above.

Decimal to Binary

To convert 89, keep dividing by 2: 89 → 44 r1, 44 → 22 r0, 22 → 11 r0, 11 → 5 r1, 5 → 2 r1, 2 → 1 r0, and 1 → 0 r1. The remainders from the bottom up give 89₁₀ = 1011001₂.

For small numbers there is a faster way. Find the powers of 2 that add up to your number (89 = 64 + 16 + 8 + 1), then write a 1 under each of those place values and a 0 under the rest.

Binary to Decimal

Take 1110011. The place values from the left are 64, 32, 16, 8, 4, 2, and 1. Add up the ones that sit under a 1: 64 + 32 + 16 + 2 + 1 = 115.

Decimal to Hexadecimal

Start with 3,000: 3,000 ÷ 16 = 187 r8, then 187 ÷ 16 = 11 r11, then 11 ÷ 16 = 0 r11. Both 11s become B, so reading upward gives 3,000₁₀ = BB8₁₆.

Hexadecimal to Decimal

In 1F4, F is 15, so: (1 × 256) + (15 × 16) + (4 × 1) = 256 + 240 + 4 = 500.

Decimal to Octal

Dividing 493 by 8 gives 61 r5, then 61 ÷ 8 = 7 r5, then 7 ÷ 8 = 0 r7. The answer is 755₈, which may look familiar if you have ever run chmod 755 on a Linux server.

Octal to Decimal

The place values for a three-digit octal number are 64, 8, and 1, so 644 works out as (6 × 64) + (4 × 8) + (4 × 1) = 384 + 32 + 4 = 420.

Hexadecimal to Binary

Swap each hex digit for its 4 bits. For A7, A is 1010 and 7 is 0111, so A7₁₆ = 10100111₂. Binary to hex is the same thing backwards: split into fours from the right and swap each group for a digit.

Converting Fractions to Another Base

Digits after the point follow the same rule, except the place values keep shrinking. In binary they are ½, ¼, ⅛, and so on (2⁻¹, 2⁻², 2⁻³). So 0.1011₂ = 0.5 + 0 + 0.125 + 0.0625 = 0.6875.

To go from decimal to another base, split the number at the point and convert the whole part by division as usual. For the fractional part, multiply by the new base. The whole-number part of the answer is your next digit, and you carry on multiplying whatever is left:

Multiplication Product Digit
0.6875 × 21.3751
0.375 × 20.750
0.75 × 21.51
0.5 × 211

This time you read the digits from the top down, so 0.6875₁₀ = 0.1011₂. Put the two halves together and 5.6875 becomes 101.1011₂.

Why Some Fractions Never End

0.1 has a single digit after the point in decimal, but in binary it is 0.000110011001100… with 0011 repeating forever. It is the same thing that happens to 1/3 in decimal. A fraction only ends in a base if every prime factor of its denominator is also a factor of the base. Ten is 2 × 5, and binary only has the 2, so most tenths can't end in binary. On the other hand, 1/3 is a tidy 0.1 in base 3.

It is also why 0.1 + 0.2 gives 0.30000000000000004 in JavaScript and plenty of other languages. The computer stores the nearest binary fraction it can fit, and the small errors show up when you add them. The converter gets around this by working with exact fractions. When a result never ends, it rounds to 20 digits after the point and shows the repeating part in brackets in the note under the result.

Negative Numbers and Two's Complement

On paper, a negative number simply keeps its minus sign, so −46 is −1201₃. The converter does the same. A computer, though, has no minus sign to store. Instead it uses two's complement inside a fixed number of bits. Here is −5 in 8 bits:

  1. Write 5 in 8 bits: 00000101.
  2. Flip every bit: 11111010.
  3. Add 1: 11111011, which is FB in hex.

The leading bit now works as the sign. With 8 bits you can hold −128 to 127 as signed numbers, or 0 to 255 if every bit counts toward the value. The bits themselves don't say which one you meant, and that is where a lot of bugs come from. FF is 255 to one program and −1 to another. FFFFFFFF is 4,294,967,295 as an unsigned 32-bit number and −1 as a signed one.

Width Unsigned Range Signed Range
8-bit0 to 255−128 to 127
16-bit0 to 65,535−32,768 to 32,767
32-bit0 to 4,294,967,295−2,147,483,648 to 2,147,483,647
64-bit0 to 18,446,744,073,709,551,615−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Type a whole number into the converter and the 'Two's Complement and Bits' box shows its pattern at the width you choose, along with how that pattern reads as signed and unsigned. Try FFFFFFFF in base 16 at 32-bit to see both answers side by side.

Base Conversion Tables

Decimal, Binary, Octal, and Hex from 0 to 16

Binary is padded to four digits here so the columns line up. Once the 4-bit column sticks in your head, binary to hex becomes almost instant.

Decimal Binary Octal Hexadecimal
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010

Values Worth Knowing

These come up again and again in computing. Most are either a power of 2 or one less than a power of 2. The second kind, such as 255 or 65,535, is the largest number that a set number of bits can hold.

Decimal Binary Octal Hexadecimal
100110010014464
12711111111777F
1281000000020080
25511111111377FF
256100000000400100
1,000111110100017503E8
1,024100000000002000400
4,0961000000000000100001000
65,5351111111111111111177777FFFF
4,294,967,2951111111111111111111111111111111137777777777FFFFFFFF

Where Base Conversion is Used

  • Schoolwork and exams: Number systems are part of most computer science courses, from school boards to university papers and exams like GATE. Questions usually ask for conversions by hand, so the calculation steps show every line of working for you to check against yours.
  • Web colors: A hex color such as #1E90FF is three bytes. 1E is 30 red, 90 is 144 green, and FF is 255 blue, which makes it rgb(30, 144, 255).
  • File permissions: In chmod 640, each octal digit is three bits for read, write, and execute. 6 is 110 (read and write), 4 is 100 (read only), and 0 is 000 (no access).
  • Networking: An IPv4 address is four bytes written in decimal. 192.168.1.10 is 11000000.10101000.00000001.00001010 in binary. A subnet mask of 255.255.255.0 is 24 ones followed by 8 zeros, which is why it is written /24.
  • Memory and debugging: Memory addresses, error codes, register values, and MAC addresses are shown in hex because two hex digits make exactly one byte.
  • Text encoding: Every character has a number behind it. In Unicode, é is U+00E9, which is 233 in decimal and 11101001 in binary.
  • Short IDs: Base 36 packs numbers into fewer characters and doesn't care about letter case, so it turns up in short links and reference codes. One million needs seven digits in decimal but only four in base 36.

Common Base Conversion Mistakes

  • Reading remainders top to bottom: With repeated division, the first remainder is the last digit. Fraction digits are the opposite and read from the top.
  • Using a digit the base doesn't have: There is no 8 or 9 in octal and no 2 in binary. The converter flags these as soon as you type them.
  • Writing big remainders as two digits: A remainder of 12 in base 16 is C, not 12. Writing it as 12 adds a digit and throws off the whole answer.
  • Guessing the base: 10 is ten in decimal, two in binary, and sixteen in hex. If a number arrives without a label, check where it came from first.
  • Grouping bits from the wrong end: For the hex shortcut, group from the right. 11010 is 1 1010, which is 1A, not 1101 0.
  • Worrying about leading zeros: 00101 and 101 are the same number. Zeros only matter in fixed-width fields such as a byte, where 0F and F0 are very different.
  • Mixing up signed and unsigned: FF can mean 255 or −1. Check whether the source uses two's complement before you trust the decimal value.

Base Conversion in Excel and Google Sheets

Both programs have conversion functions built in, and they behave the same way in each:

What You Want Formula Result
Decimal to binary=DEC2BIN(89)1011001
Binary to decimal=BIN2DEC("1110011")115
Decimal to hex=DEC2HEX(3000)BB8
Hex to decimal=HEX2DEC("1F4")500
Decimal to octal=DEC2OCT(493)755
Decimal to any base=BASE(713, 8)1311
Same, padded to 8 digits=BASE(89, 2, 8)01011001
Any base to decimal=DECIMAL("1201", 3)46

The older functions have tight limits. DEC2BIN only accepts −512 to 511, because it works in 10-bit two's complement, which is also why =DEC2BIN(-5) returns 1111111011 instead of −101. DEC2OCT and DEC2HEX go further, to 30 and 40 bits. For anything else, use BASE and DECIMAL, which cover every base from 2 to 36. BASE takes whole numbers from 0 up to 2⁵³ and quietly drops anything after the decimal point, so fractions still need the converter.

Base Conversion in JavaScript and Python

In code you will rarely do this by hand, since both languages have it built in. In JavaScript, parseInt reads a number in any base from 2 to 36 and toString writes one:

JavaScript
// From another base to a number
parseInt('2C9', 16);   // 713
parseInt('1201', 3);   // 46

// From a number to another base (2 to 36)
(713).toString(8);     // '1311'
(89).toString(2);      // '1011001'
(3000).toString(16).toUpperCase(); // 'BB8'

// Prefixed literals
0x1F4;                 // 500
0b1110011;             // 115
0o755;                 // 493

// Pad to a fixed width
(89).toString(2).padStart(8, '0'); // '01011001'

// Past 2^53, use BigInt so no digits are lost
BigInt('0xFFFFFFFFFFFFFFFF');      // 18446744073709551615n

Watch out for one thing: parseInt stops at the first character it can't read instead of throwing an error, so parseInt('19', 8) returns 1. If the value comes from a user, validate it first. Python's int() also reads bases 2 to 36, but it only has built-in output for binary, octal, and hex, so other bases need a short function:

Python
# From another base to an integer
int('2C9', 16)      # 713
int('1201', 3)      # 46
int('0xff', 0)      # 255 (base 0 reads the prefix)

# To binary, octal, and hex
bin(89)             # '0b1011001'
oct(493)            # '0o755'
hex(3000)           # '0xbb8'
format(89, '08b')   # '01011001'

# There is no built-in for other bases, so write one
def to_base(n, base):
    digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    if n == 0:
        return '0'
    sign = '-' if n < 0 else ''
    n = abs(n)
    out = ''
    while n:
        n, r = divmod(n, base)
        out = digits[r] + out
    return sign + out

to_base(713, 8)     # '1311'
to_base(46, 7)      # '64'

Python integers have no size limit, so both int() and the function above stay exact however long the number gets. In JavaScript you get the same guarantee by switching to BigInt once a value passes 2⁵³.

Frequently Asked Questions

To convert it manually, divide the decimal number by 2 repeatedly, write down each remainder (0 or 1), and stop when the quotient reaches 0. Then read the remainders from the last one to the first. For example, 156 ÷ 2 gives remainders 0, 0, 1, 1, 1, 0, 0, 1, so reading them bottom to top gives 156 = 10011100 in binary. You can use the same repeated-division method for any target base.

Multiply each binary digit by 2 raised to the power of its position, counting from 0 on the right, then add the results. For example, 101101 = (1 × 2⁵) + (0 × 2⁴) + (1 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰) = 32 + 0 + 8 + 4 + 0 + 1 = 45. A quick shortcut is to add only the place values that sit under a 1.

Replace each hex letter with its value (A = 10, B = 11, C = 12, D = 13, E = 14, F = 15), multiply each digit by 16 raised to its position from the right, starting at 0, and add the results. For example, 2AF = (2 × 16²) + (10 × 16¹) + (15 × 16⁰) = 512 + 160 + 15 = 687.

Divide the number by 16 repeatedly, note each remainder, and read the remainders from last to first, writing 10 to 15 as A to F. For example, 2024 ÷ 16 = 126 remainder 8, 126 ÷ 16 = 7 remainder 14 (E), and 7 ÷ 16 = 0 remainder 7. Reading upwards gives 2024 = 7E8 in hexadecimal.

To convert decimal to octal, divide the value by 8 repeatedly and read the remainders from last to first. For example, 100 ÷ 8 = 12 remainder 4, 12 ÷ 8 = 1 remainder 4, and 1 ÷ 8 = 0 remainder 1, so 100 = 144 in octal. To convert back, multiply each digit by 8 raised to its position from the right: 144 = (1 × 64) + (4 × 8) + (4 × 1) = 100. Octal is still used for Unix file permissions, where chmod 755 means rwxr-xr-x.

Split the binary number into groups from the right, 4 bits per group for hexadecimal or 3 bits for octal, padding the leftmost group with zeros. Then convert each group on its own. For example, 11010110 splits into 1101 0110, which is D and 6, so the result is D6. In groups of three, 011 010 110 gives 3, 2, 6, so the octal value is 326. To go the other way, replace each hex digit with 4 bits, or each octal digit with 3 bits: 3F = 0011 1111 = 111111. This works because 16 = 2⁴ and 8 = 2³.

Convert the number to decimal first using place values, then convert that decimal result to the target base by repeated division. For example, to turn 1234 in base 5 into base 7: (1 × 125) + (2 × 25) + (3 × 5) + 4 = 194, and 194 ÷ 7 gives remainders 5, 6, 3, so the answer is 365 in base 7. The Syntax Toolbox Base Converter features a calculation steps panel which shows both stages for any base-to-base conversion.

A number base, or radix, is the number of distinct digits a positional number system uses, and each position is worth the base raised to a higher power. Decimal (base 10) uses 0 to 9 with place values of 1, 10, 100, and so on. Binary (base 2) uses only 0 and 1 with place values of 1, 2, 4, 8. Therefore, '10' means ten in decimal, two in binary, and sixteen in hexadecimal.

255 in decimal is 11111111 in binary, 377 in octal, and FF in hexadecimal. It is the largest value an 8-bit byte can hold, because 2⁸ − 1 = 255, which is why it appears so often in computing, for example as the maximum value of each channel in an RGB color such as #FFFFFF.

Split the six-digit code into three pairs for red, green, and blue, then convert each pair from hexadecimal to decimal. For example, #FF8800 gives FF = 255, 88 = (8 × 16) + 8 = 136, and 00 = 0, so it is RGB (255, 136, 0). A three-digit code doubles each digit, so #F80 is the same as #FF8800. To go from RGB to hex, convert each value from base 10 to base 16 and pad it to two digits, so 10 becomes 0A. Enter one pair at a time in the converter, with base 16 as the 'From' base and base 10 as the 'To' base.

Hexadecimal needs 16 single-character digits, but there are only ten numerals, so the letters A to F stand for the values 10 to 15. The same rule extends to every base above 10. For example, base 12 adds A and B, base 20 runs up to J, and base 36 uses all 26 letters, with Z worth 35. As letters are not case-sensitive, 'ff' and 'FF' are the same value.

Base 36 is the largest base that can be written using only the ten digits 0 to 9 plus the 26 letters A to Z, one character per digit. Higher bases need extra symbols or case-sensitive letters, as in Base62 and Base64. Base 36 is popular for short, case-insensitive IDs, for example 1,000,000 in decimal is just LFLS in base 36. Many programming languages, including JavaScript, also accept radix values from 2 to 36.

Because they serve different purposes. The Syntax Toolbox Base Converter writes the number itself in base 32 using the digits 0 to 9 and A to V, the same alphabet as 'base32hex' in RFC 4648. Standard Base32 encoding (RFC 4648) instead converts bytes of data using A to Z and 2 to 7, so its output will not match. For example, 1,000,000 is UGI0 as a base 32 number.

Yes, all three work. Negative numbers: Place a minus sign (-) before the number in the converter, such as -1010. The negative sign carries over to the converted result unchanged. Fractions: Use a decimal point to enter fractional values. The whole-number part is converted by repeated division, while the fractional part is converted by repeated multiplication. The whole-number part of each product becomes the next digit in the result. For example, converting 23.4 to binary gives 10111.011001100110… The fractional digits repeat indefinitely because the multiplication process eventually returns to the same value. Fractions that never end in the target base are rounded to 20 digits after the decimal point. Prefixes: The converter accepts 0b for binary, 0o for octal, and 0x for hexadecimal, as long as the prefix matches the base selected under 'From'. So 0xFF works when 'From' is base 16. In base 16 itself, 0b is read as ordinary digits, because B is a valid hex digit. Spaces and underscores between digits are ignored too, so FFFF_FFFF is fine. Negative-number representation: The minus sign is used as a standard negative sign, not as two's complement. For the two's complement pattern, use the 'Two's Complement and Bits' box under the results, which shows the value at 8, 16, 32, 64, or 128 bits.

That's because many calculators store numbers as 64-bit floating point values, which are only exact up to 2⁵³ (9,007,199,254,740,992). Beyond that, digits are silently rounded. For example, a floating point converter turns 9,007,199,254,740,993 into hex 20000000000000, but the correct answer is 20000000000001. However, the Syntax Toolbox Base Converter uses arbitrary-precision integer (BigInt) arithmetic, so every digit stays exact for inputs up to 100 digits.

Yes. The Base Converter is free to use, requires no sign-up, and shows the result as you type values for any two bases from 2 to 36. All calculations run directly in your browser, so the numbers you enter are never uploaded or stored. Results use exact arithmetic, including for negative numbers and fractions, and come with step-by-step working for reference plus a table of binary, octal, decimal, duodecimal, hexadecimal, base 32, and base 36 values you can copy in one click.

We Value Your Opinion

Does this tool meet your expectations? Your feedback helps us improve

By submitting, you agree to our Terms of Use & Privacy Policy

Find Syntax Toolbox useful? Support us