Bitmask Generator
Generate bitmasks by selecting bit positions visually.
Bit width:
Click bits to toggle them in the mask:
Decimal
Hex
0xBinary
Quick Masks
Code Examples
// Create mask for bits 4-7 (4 bits starting at position 4)
const mask = 0xF0; // 11110000
// Extract bits using AND
const value = 0xAB;
const extracted = (value & mask) >> 4; // 0xA
// Set bits using OR
const result = value | 0x0F; // 0xAFFrequently Asked Questions
What is a bitmask?
A bitmask is a pattern of bits used to select or modify specific bits in a value. Common uses: extracting fields, setting flags, permissions (read/write/execute).
How do I create a bitmask?
For a mask of N bits starting at position P: mask = ((1 << N) - 1) << P. For example, 0xFF masks the lowest 8 bits, 0xFF00 masks bits 8-15.