8→10 Line Coding Utility

8b/10b Encoder & Decoder

Use this 8b/10b Encoder & Decoder to encode hexadecimal data bytes, D.x.y data symbols and legal K control symbols into 10-bit code groups. Decode received 10-bit symbols while checking running disparity, invalid code groups and control-character status.

✓ Running Disparity ✓ D.x.y Symbols ✓ K Control Codes ✓ Code Errors ✓ Disparity Errors
8/10
Encode / Decode 8b/10b
● Ready
Running disparity is tracked from one symbol to the next.
Hex mode accepts values such as BC, 00 FF or 0x12 0x34. Symbol mode accepts D31.1, K28.5 and sequences such as K28.5 D0.0 D31.1.
Enter 10-bit binary code groups separated by spaces, or paste one continuous binary stream whose length is a multiple of 10.
Important: 8b/10b is stateful. The same D.x.y or K.x.y symbol can have different 10-bit representations depending on the running disparity entering that symbol. Decoder validation therefore uses both the received 10-bit code group and the expected running-disparity state.
8b/10b Result Encoded
Encoded 10-Bit Code Groups
Symbols
Input RD
Final RD
Encoded Bits
Data Symbols
Control Symbols
Code Errors
Disparity Errors
# Symbol Byte RD In 6b 4b 10b Code RD Out Status
Encoding / Decoding Breakdown -
10-Bit Output
-

What Is 8b/10b Encoding?

8b/10b is a line-coding system that converts each eight-bit input symbol into a ten-bit transmission code group. The additional encoded bits provide useful signal properties such as controlled disparity, sufficient transitions for clock recovery and special control symbols that cannot simply be treated as ordinary payload bytes.

The classic IBM implementation divides each byte into a five-bit portion and a three-bit portion. These are encoded through 5b/6b and 3b/4b coding tables, producing the final ten-bit code group.

A correct encoder cannot simply use a fixed lookup from each byte to one ten-bit value because the selected code group also depends on the current running disparity.

8b/10b D.x.y Symbol Notation

An ordinary data symbol is conventionally written as D.x.y. The five least significant input bits determine x, from 0 through 31, and the three most significant input bits determine y, from 0 through 7.

For byte: 0x3F = 00111111 binary the low five bits are: 11111 = 31 and the upper three bits are: 001 = 1 so the symbol is: D31.1

5b/6b and 3b/4b Encoding

The lower five data bits are transformed into a six-bit sub-block. The upper three bits are transformed into a four-bit sub-block.

5 input bits → 6 encoded bits 3 input bits → 4 encoded bits 6 + 4 = 10 transmitted bits

Running disparity is evaluated during this process because the first sub-block can change the disparity state used to choose the second sub-block.

What Is Running Disparity?

Disparity is the difference between the number of transmitted ones and zeros. 8b/10b tracks a running state commonly represented as RD− or RD+.

RD−

The encoder is in the negative running-disparity state before the next code selection.

RD+

The encoder is in the positive running-disparity state before the next code selection.

When a sub-block has non-zero disparity, its selected version normally drives the running state toward the opposite sign. Balanced sub-blocks leave the state unchanged.

8b/10b Encoding Example: D31.1

D31.1 is a useful test of the encoder.

With initial RD−: D31.1 → 101011 1001 Complete 10-bit code: 1010111001

With initial RD+, the 5b/6b portion changes:

D31.1 → 010100 1001

This illustrates why running disparity must be part of an 8b/10b encoder.

8b/10b K Control Symbols

8b/10b reserves several legal control characters known as K symbols. They are not ordinary data bytes even though each can be associated with an eight-bit value.

This calculator accepts the standard control set:

Control Group Legal Symbols
K28.y K28.0 through K28.7
Additional .7 controls K23.7, K27.7, K29.7, K30.7

K28.5 8b/10b Encoding

K28.5 is one of the best-known 8b/10b control characters and is commonly used as a comma-related synchronization symbol by protocols built on 8b/10b.

For RD−: K28.5 = 001111 1010 = 0011111010 For RD+: K28.5 = 110000 0101 = 1100000101

The decoder recognizes both forms and checks whether the selected one is legal for the running disparity entering that code group.

What Is an 8b/10b Disparity Error?

A received ten-bit pattern may be a legitimate 8b/10b code group but still be wrong for the receiver’s current running disparity.

That situation is different from receiving a pattern that is not a legal 8b/10b symbol at all.

Code Error

The received 10-bit value does not correspond to a legal generated data or control symbol.

Disparity Error

The 10-bit value is recognizable, but it is not the legal version for the expected incoming RD state.

Why the Decoder Tracks Running Disparity

Suppose a code group is valid only when entering the symbol with RD+. If the receiver is currently in RD− and receives that RD+ form, simply looking up the ten bits would identify the underlying symbol but miss an important line-code violation.

This decoder therefore builds both the legal code map and the expected-RD map. It can report a recognizable symbol as a disparity error rather than treating every recognizable ten-bit pattern as valid.

8b/10b Expansion Ratio

Eight application bits become ten transmitted bits:

10 / 8 = 1.25

The physical encoded bit count is therefore 25% larger than the original eight-bit symbol count before considering any higher-level protocol framing.

Why 8b/10b Uses Alternative Encodings

Many symbols have different legal code groups for negative and positive running disparity. These choices allow the transmitter to keep the long-term difference between ones and zeros bounded instead of allowing a large DC imbalance to accumulate.

Some balanced sub-blocks use the same pattern for both running states, while others have special alternate representations selected for run-length and coding constraints.

Special Alternate .7 Encoding

The three-bit value 7 has primary and alternate 3b/4b representations in specific circumstances. Correct handling of those alternatives helps prevent undesirable long runs and is one reason a simple independent lookup of the 5b and 3b fields is not sufficient for a complete encoder.

The JavaScript implementation on this page applies the standard alternate D.x.A7 conditions and uses the appropriate alternate code for legal K.x.7 control symbols.

Bit Order Used by This Calculator

The calculator displays the conventional 8b/10b code-group notation:

abcdei fghj

The six-bit 5b/6b group is shown first, followed by the four-bit 3b/4b group. This is the representation commonly used in published 8b/10b tables.

If you are comparing the result with a logic analyzer, serializer or PHY register, verify how that device displays transmission bit order. Some tools show serialized bits visually in the opposite screen direction.

Encoding Multiple 8b/10b Symbols

When several bytes are encoded, running disparity is not reset for each byte. The RD output from one symbol becomes the RD input to the next symbol.

Symbol 1: RD input → encode → RD output Symbol 2: previous RD output → encode → new RD output

This is why the tool supports complete sequences rather than calculating every byte independently.

Hexadecimal to 8b/10b Encoding

Hex mode interprets every two hexadecimal digits as one ordinary eight-bit data symbol. For each byte, the tool derives x from the low five bits and y from the upper three bits.

Hex byte = 0xBC Binary = 10111100 x = 11100₂ = 28 y = 101₂ = 5 Data symbol = D28.5

Note that ordinary hexadecimal input always means a D data character. If you specifically require the control character having the same underlying byte value, enter the appropriate K.x.y notation in Symbol mode.

D Symbol vs K Symbol

A byte value alone is not sufficient to say that a character is a K control character. The transmitter must intentionally request a legal K code.

0xBC as ordinary data → D28.5 K28.5 → control character

Their 8b/10b code groups are not generally interchangeable, so this calculator keeps the two cases explicit.

Invalid K Codes

Only the defined K symbol set can be encoded. For example, a user cannot arbitrarily request K1.2 simply because x and y fall within the numerical D.x.y ranges.

When an illegal K symbol is entered, the encoder rejects it instead of silently treating it as ordinary data.

Common 8b/10b Encoding Mistakes

Ignoring Running Disparity

Many source symbols have different code groups for RD− and RD+.

Resetting RD Every Byte

Running disparity must normally continue across the complete encoded stream.

Treating Every Byte as a K Code

Only a specific set of K.x.y control symbols is legal.

Ignoring .7 Alternatives

Some y=7 data symbols require alternate 3b/4b code groups.

Confusing Code and Disparity Errors

A known 10-bit pattern can still violate the expected running disparity.

Reversing Display Bit Order

Serializer and analyzer displays may visually order code-group bits differently.

8b/10b Encoder & Decoder FAQs

What does 8b/10b mean?
It means each eight-bit input symbol is mapped to a ten-bit transmission code group.
What is running disparity in 8b/10b?
Running disparity tracks the balance of transmitted ones and zeros and helps the encoder choose the appropriate alternate code group.
What does D31.1 mean?
D identifies an ordinary data symbol, 31 identifies the low five-bit value and 1 identifies the upper three-bit value.
What is D31.1 with RD−?
The conventional code group is 101011 1001, or 1010111001.
What is K28.5?
K28.5 is a legal 8b/10b control symbol widely used for synchronization and comma-related functions in protocols using 8b/10b.
What is K28.5 with RD−?
It is 0011111010 in the conventional abcdei-fghj representation.
What is K28.5 with RD+?
It is 1100000101.
How many K control symbols are legal?
The standard set contains K28.0 through K28.7 plus K23.7, K27.7, K29.7 and K30.7.
What is an 8b/10b code error?
A code error occurs when a received ten-bit pattern is not a legal generated 8b/10b data or control code group.
What is an 8b/10b disparity error?
It occurs when a recognizable ten-bit symbol is received in a form that is inconsistent with the receiver’s expected running disparity.
Does running disparity reset for every byte?
Normally no. The RD output of one symbol becomes the RD input of the following symbol.
Does 8b/10b add overhead?
Yes. Eight source bits become ten line-code bits, producing a 25% increase in encoded bit count.
Can every byte be encoded as data?
Yes. All 256 eight-bit values have D data-symbol encodings.
Can every x.y value be used as a K symbol?
No. Only the defined control-symbol set is legal.
Why does one byte sometimes have two 10-bit codes?
Alternative code groups allow the encoder to control running disparity and other line-code properties.
What are 5b/6b and 3b/4b?
They are the two sub-encoders used by the classic 8b/10b scheme. Five source bits become six encoded bits and three source bits become four encoded bits.
Can this decoder identify K characters?
Yes. Legal received control groups are identified as K.x.y rather than being reported as ordinary D data symbols.
Can I decode a continuous stream?
Yes. Paste a continuous binary sequence whose length is a multiple of ten. Running disparity is tracked across every code group.

Encode and Decode 8b/10b With Running Disparity

Enter hexadecimal data, D.x.y symbols or legal K control characters to generate 10-bit code groups, or decode received groups while tracking RD state and detecting invalid or disparity-inconsistent symbols.

Scroll to Top