FIELD Bit Packing Tool

Binary Bitfield Calculator

Encode multiple named fields into one packed binary or hexadecimal bitfield, or decode a packed value into individual fields with custom widths, bit ranges, offsets and masks.

Encode Decode Bit Masks Bit Ranges Binary Hex
Binary Bitfield Encoder & Decoder MSB → LSB
Fields are ordered from most-significant to least-significant.
Used as the main packed result format and for decode input.
Field Definition — First Row = Most Significant Field
Bitfield Result
Packed Binary
Packed Hex
Decimal
Total Width
Field Count
MSB Field
LSB Field
Operation
Bitfield Analysis
Field Breakdown
Field Width Bit Range Offset Binary Hex Decimal Mask
Define fields and calculate to view the bitfield breakdown.

What Is a Binary Bitfield?

A bitfield is a group of smaller values packed into specific bit positions inside a larger binary word. Each field occupies a defined number of bits and normally represents a flag, status code, mode, counter, identifier or other compact numeric value.

Bitfields are common in hardware registers, embedded systems, network protocols, file formats and binary data structures because several small values can share one integer efficiently.

Bitfield Encoding

Encoding combines multiple fields into one packed value. The calculator places the first field at the most-significant side and subsequent fields immediately after it.

Fields:

Mode = 5, width = 3 bits
Enable = 1, width = 1 bit
Count = 2, width = 4 bits

Binary:
101 | 1 | 0010

Packed:
10110010

Hex:
B2

Bitfield Decoding

Decoding performs the reverse process. You provide a packed binary or hexadecimal value and define how many bits belong to each field.

Packed:
10110010

Field widths:
3 | 1 | 4

Decoded:
101 = 5
1 = 1
0010 = 2

MSB-to-LSB Field Ordering

This calculator treats the first field definition as the most-significant field and the final field as the least-significant field.

Fields:
A = 3 bits
B = 2 bits
C = 3 bits

Packed layout:
AAA BB CCC

Bit positions:
7 … 5 | 4 … 3 | 2 … 0

Bit Offset and Bit Range

The offset of a field is the number of bits between its least-significant bit and bit position 0 of the complete packed value.

For example, in an 8-bit layout with fields of widths 3, 1 and 4, the field ranges are:

Field Width Bit Range Offset
Mode 3 7:5 5
Enable 1 4 4
Count 4 3:0 0

What Is a Bitfield Mask?

A bit mask contains ones at the positions occupied by a field and zeros elsewhere. It can be used with bitwise operations to isolate or update a field.

8-bit field:
bits 3:0

Binary mask:
00001111

Hex mask:
0F

A field occupying bits 7:5 would instead use the binary mask 11100000.

Field Value Limits

An unsigned field of width n can represent values from zero through 2 raised to n minus one.

Width Unsigned Range Binary Maximum
1 bit 0 to 1 1
2 bits 0 to 3 11
3 bits 0 to 7 111
4 bits 0 to 15 1111
8 bits 0 to 255 11111111
16 bits 0 to 65535 16 ones

Bitfield Example: Hardware Register

A simple 8-bit control register might divide its bits as follows:

Field Bits Purpose
MODE 7:6 Operating mode
ENABLE 5 Enable flag
CHANNEL 4:2 Channel number
STATUS 1:0 Status code

Packing these values into one byte makes the register compact while still allowing every field to be extracted independently.

Where Bitfields Are Used

Hardware Registers

Individual control and status fields are commonly packed into processor and peripheral registers.

Network Protocols

Protocol headers frequently assign exact bit ranges to flags, lengths, types and control values.

Embedded Systems

Bitfields reduce storage and allow several configuration values to fit inside a small integer.

Binary File Formats

Packed metadata fields can store multiple attributes without allocating a full byte to every property.

Important Bitfield Notes

Important: field order in this calculator is most significant to least significant.

Every field uses an unsigned value.

The entered value must fit within its specified field width.

For an n-bit unsigned field, the maximum valid value is 2^n – 1.

The total width is the sum of all field widths.

Binary decoding requires the packed input width to match the total defined field width.

Hexadecimal input is left-padded with zeros when necessary to match the field layout.

Bit numbering uses bit 0 as the least-significant bit of the entire packed value.

Binary Bitfield Calculator FAQs

What is a binary bitfield?
A binary bitfield is a packed value divided into smaller fields that occupy specific bit positions.
What does the encoder do?
The encoder converts multiple field values into one combined binary and hexadecimal bitfield.
What does the decoder do?
The decoder separates a packed binary or hexadecimal value into fields according to their specified widths.
Which field is most significant?
The first field in the calculator is the most-significant field. The last field is the least-significant field.
What is a field width?
Field width is the number of bits allocated to that field.
What is a bit offset?
The offset is the number of bit positions between the field’s least-significant bit and bit 0 of the complete packed value.
What is a field mask?
A field mask contains ones at the bit positions occupied by the field and zeros elsewhere.
Can field values be entered in hexadecimal?
Yes. Each encoder field can use decimal, binary or hexadecimal input.
Can I decode a hexadecimal packed value?
Yes. Select Hexadecimal as the packed value format and enter the packed data.
What happens if a field value is too large?
The calculator rejects values that cannot fit inside the field’s configured number of bits.
Are bitfields signed or unsigned?
This calculator interprets every individual field as an unsigned value.
How are bit positions numbered?
Bit 0 is the least-significant bit of the packed value, and bit numbers increase toward the most-significant side.
Scroll to Top