Skip to content
100% local

Binary bit positions

List the positions of a number’s set bits, or build a number back from a list of positions.

Input
Output

Binary bit positions

Paste a number and this tool lists every position where a bit is set, counting from 0 at the least significant bit. 42 becomes "1, 3, 5" because 42 is 32 + 8 + 2 — bits 5, 3 and 1 turned on. Flip the direction and it runs the other way: give it a list of positions and it builds the number those bits describe. That's useful for reading permission masks, feature-flag bitfields, register values from a datasheet, or anywhere "which bits are on" matters more than the raw number.

Input format sets how the pasted number is read — decimal, hexadecimal, binary or octal, each with its usual prefix (0x, 0b, 0o) accepted and optional. Output format is the same choice for the number the tool builds back from positions. Positions are always plain, comma- or space-separated decimal indices ("1, 3, 5" or "1 3 5" both work), since an index isn't a value in a base.

Batch mode converts a whole list at once, one entry per line, instead of treating the entire input as a single record. Each line converts independently: one the tool can't parse — wrong digits for the selected base, a negative number, a position that isn't a whole number — is left as typed and marked, while every other line still converts. Results land one per line, so any single one is easy to copy on its own. Outside batch mode the same problem is reported as one calm error explaining what to fix.

Everything runs locally in your browser — the numbers and bit patterns you convert are never uploaded anywhere. Copy the result, download it as a .txt file, or send it straight back into the input to flip the direction and check your work.

FAQ

Which bit is position 0?
Position 0 is the least significant bit — the rightmost bit, worth 1. Position 1 is worth 2, position 2 is worth 4, and so on, doubling each time.
What number formats are supported?
Decimal, hexadecimal, binary and octal, each independently selectable for the input and the output. A matching literal prefix (0x, 0b, 0o) is accepted and stripped automatically.
What happens to a line that isn’t valid in batch mode?
It is left unchanged in the output and marked, and the tally reports how many lines were invalid. Every other line still converts normally.
Is there a limit on how large a number or bit position can be?
Yes, both are capped well above any realistic use — tens of thousands of digits for a number, and a million for a bit position — purely to keep the tool from freezing on a pasted mistake.
Is my data uploaded anywhere?
No. Every conversion runs entirely in your browser using JavaScript — nothing you paste in is sent to a server.