Skip to content
100% local

AMI line code

Encode a bit stream to Alternate Mark Inversion line code, or decode it back.

Input
Output

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.

FAQ

What does the AMI encoding actually look like?
Each 0 bit becomes the symbol 0. Each 1 bit becomes + or -, alternating every time a 1 appears, so "01001000" becomes "0+00-000".
Why does decoding sometimes report a "violation" instead of just decoding?
Valid AMI never repeats the same mark polarity twice in a row — that's what lets a receiver detect a single corrupted bit. Two consecutive '+' or two consecutive '-' symbols mean the signal isn't valid AMI, so the tool reports it rather than silently decoding a broken stream.
What happens if the decoded bits don't add up to a whole number of bytes?
Turn on "Keep padding" to pad the short end with zero bits, or turn it off to drop the incomplete trailing bits instead. The same setting also decides how an odd hex digit count is handled when encoding.
Can I decode a value I encoded with line wrapping turned on?
Yes. Whitespace and line breaks in the AMI input are ignored before decoding, so wrapped output — or output pasted from a Windows file with CRLF line endings — decodes the same as one long line.
Is my data uploaded anywhere?
No. Encoding and decoding both run entirely in your browser — nothing you type or paste is sent to a server.