Convert Any Decimal Number to Binary in One Click
Type a decimal number (base 10) and instantly get its binary equivalent (base 1s and 0s). The result also shows the value in octal and hexadecimal – handy when you need all bases at once. Everything runs in your browser, so your numbers are never uploaded or stored anywhere.
How to Use the Decimal to Binary Converter
- Type your decimal number into the input field above.
- The tool instantly shows the binary output – no button press needed.
- Copy the binary result with one click.
- Need the reverse? Swap the direction to binary to decimal in the same tool.
Worked Example: Decimal 45 → Binary
Let's convert 45 to binary step by step. The method is to divide by 2 repeatedly and read the remainders from bottom to top.
| Step | Division | Quotient | Remainder (bit) |
|---|---|---|---|
| 1 | 45 ÷ 2 | 22 | 1 (LSB) |
| 2 | 22 ÷ 2 | 11 | 0 |
| 3 | 11 ÷ 2 | 5 | 1 |
| 4 | 5 ÷ 2 | 2 | 1 |
| 5 | 2 ÷ 2 | 1 | 0 |
| 6 | 1 ÷ 2 | 0 | 1 (MSB) |
Reading the remainders from bottom to top gives: 101101. So 45 in decimal = 101101 in binary. The tool gives you that result the moment you finish typing.
Quick Reference: Common Decimal to Binary Values
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 8 | 1000 | 8 | 10 |
| 10 | 1010 | A | 12 |
| 16 | 10000 | 10 | 20 |
| 45 | 101101 | 2D | 55 |
| 128 | 10000000 | 80 | 200 |
| 255 | 11111111 | FF | 377 |
How to Convert Decimal to Binary in Code
Sometimes you need this in a script rather than a one-off lookup. Here are minimal, copy-pasteable snippets for the two most common languages.
Python
# Python 3 – built-in bin() returns a string like '0b101101'
decimal_number = 45
binary_string = bin(decimal_number) # '0b101101'
clean_binary = bin(decimal_number)[2:] # '101101' (strip the '0b' prefix)
print(clean_binary)
JavaScript
// JavaScript – Number.prototype.toString(base)
const decimal = 45;
const binary = decimal.toString(2); // '101101'
console.log(binary);
Both snippets convert 45 to 101101. Python's bin() and JavaScript's .toString(2) both handle large integers correctly.
How It Works Under the Hood
Binary (base 2) uses only the digits 0 and 1. Each position in a binary number represents a power of 2 – the rightmost bit is 2⁰ (1), the next is 2¹ (2), then 2² (4), and so on.
Converting decimal to binary means repeatedly dividing by 2 and recording the remainders, exactly as shown in the worked example above. The tool performs this in your browser using JavaScript's native integer arithmetic, so large numbers up to the limits of JavaScript's BigInt are handled accurately without any server round-trip. You can read more about positional numeral systems in the MDN docs on Number.toString().
When to Use This Tool – and When Not To
- Use it for: reading bitfields, checking permission flags (like Unix
chmodvalues), understanding IP subnet masks, studying computer science basics, or debugging hardware registers. - Use it for negative numbers carefully: this tool converts the magnitude. Negative binary representations (two's complement) depend on the bit width – for example, -1 in 8-bit two's complement is
11111111. For signed conversions, you'll want a dedicated two's complement calculator. - Don't use it for floating-point: decimal fractions like 3.14 have a separate IEEE 754 binary representation. This tool handles integers only.
- For hex conversions: the tool simultaneously shows the hexadecimal value, saving you a second lookup when you need both.
The tool also converts in the other direction – just flip the input to binary to decimal – and handles very large integers that would overflow a standard 32-bit integer.
Your Data Stays Private
This converter runs entirely in your browser. No number you type is ever sent to a server or logged. Close the tab and it's gone.
Ready to convert? Enter your number in the tool above and the binary result appears instantly. If you work with JSON data day-to-day, you might also find the JSON Beautifier – Format, Validate & Minify JSON Online or the JSON Validator – Check & Fix JSON Errors Online (Free) useful for your workflow.