AMI line code
Encode a bit stream to Alternate Mark Inversion line code, or decode it back.
AMI line code
Alternate Mark Inversion (AMI) is a bipolar line code once common on telecom trunks such as T1 and E1 links: every 0 bit stays at zero voltage, and every 1 bit produces a pulse whose polarity flips each time, so two consecutive 1s are never the same sign. This tool encodes text, hex or raw bytes into that three-symbol notation (0, + and -) and decodes it back, entirely in your browser.
Pick a direction with the Encode/Decode switch, which also moves the current output back into the input so you can check a round trip matches. When encoding, the input format option reads the pasted text as UTF-8 text, hex digits, or a list of decimal byte values from 0 to 255. When decoding, the output format option controls how the recovered bytes are written back out. Wrap long lines at a fixed character count for readable rows, or set it to 0 for one long line.
Decoding validates as it goes: a character outside 0, + and - is reported with its exact position, and so is a genuine AMI violation — two marks in a row with the same polarity, exactly the error this line code is designed to let a receiver catch. When a decoded bit count doesn't land on a whole byte, the padding option pads the short end with zero bits or drops the leftover bits; the same choice handles an odd hex digit count on the way in.
Everything runs locally in your browser — nothing you paste here is uploaded anywhere, which matters if the bytes you're inspecting come from a private protocol capture. Copy the result, download it as a .txt file, or send it straight back into the input.