Developer Tools
Bitmask Calculator
Decode a value into its set bits and named flags, or encode flags into a combined value. Binary, hex, octal, decimal, and 8 to 64 bit widths. No signup.
Plain numbered bits with their decimal weights. Good for any unlabeled bitmask.
Value to decode
Type a value in any base. A 0b, 0o, or 0x prefix is detected automatically.
Bit layout
Most significant bit on the left. Set bits are highlighted.
Decoded value
Decimal
26
Hex
0x1A
Octal
0o32
Binary
0001 1010
Set bits
3 (1, 3, 4)
Weights (2^n)
2 + 8 + 16
Flags set (3)
- bit 12Bit 1Weight 2
- bit 38Bit 3Weight 8
- bit 416Bit 4Weight 16
How bit flags combine
- Each flag owns one bit, so its value is a power of two: 1, 2, 4, 8, 16, and so on. That guarantees every combination maps to a unique sum.
- To combine flags you bitwise OR them together, which is the same as adding their weights because no two flags share a bit. For example READ (4) OR WRITE (2) is 6.
- To test whether a flag is present you bitwise AND the value with the flag and check the result is non-zero. Decoding here does that for every bit at once.
- To clear a flag you AND with its complement; to toggle one you XOR with it, which is what the encode checkboxes above do.
How to use
- Choose Decode a value to break a number into flags, or Encode from flags to build a number from options.
- Pick a flag set (Unix permissions, open() flags, a regex options enum, or generic numbered bits) and a bit width. The width adapts to the chosen set.
- In decode mode, select the input base and type the value (a 0b, 0o, or 0x prefix is detected automatically). In encode mode, tick the flags or bits you want.
- Read the bit layout grid and the value in binary, hex, octal, and decimal, plus the list of set bits with their weights and names.
- Use Copy on any row or Copy summary for the full breakdown. Everything runs in your browser.
About this tool
Bitmask Calculator answers the two questions a generic bitwise calculator does not: given a packed integer, which bits are set and what do they mean, and given a set of options, what single number combines them. The bitwise calculator operates on two operands; this tool operates on one value and a list of named flags, which is the job you actually have when an API, a struct, a permission mode, or a [Flags] enum hands you an opaque number. Decode mode takes a value in binary, octal, decimal, or hex (the base is auto-detected from a 0b, 0o, or 0x prefix) and reports the exact set bit positions, their decimal weights as powers of two, and the named flag each one maps to. Encode mode flips the work around: tick the flags or individual bits you want and the combined value is shown live in all four bases, so you can read off the integer to pass back. A bit layout grid renders the value most-significant bit first with byte boundaries marked and set bits highlighted, so a 32-bit or 64-bit mask is readable at a glance. The value is held as a BigInt, so widths up to 64 bits stay exact where a plain JavaScript number would lose precision past 53 bits. Built-in flag sets cover Unix file permission mode bits (the 12 bits behind chmod, including setuid, setgid, and the sticky bit), common POSIX open() flags, a regular-expression options enum, and a generic numbered bit set for any unlabeled mask, and the bit width adapts to whichever set you choose. The tool also explains the arithmetic: flags are powers of two so combining them with OR is the same as summing their weights, testing a flag is an AND, clearing one is an AND with the complement, and toggling one is an XOR. Everything runs in your browser with BigInt math, so the values and flags you work with are never uploaded.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
Bitwise Calculator
Bit-by-bit AND, OR, XOR, NOT, shift, and rotate over two operands at any width.
Open tool
ConverterNumber Base Converter
Binary, octal, decimal, hex, and custom-base conversion with two's complement.
Open tool
DeveloperChmod Calculator
Convert chmod values between octal, symbolic (rwxr-xr-x), and clickable owner, group, and other checkboxes.
Open tool
ConverterBinary Translator
Bidirectional text and binary translation with UTF-8 byte breakdown.
Open tool
DeveloperTwo's Complement Calculator
Signed and unsigned integer to binary, hex, and octal at every common bit width.
Open tool