Git internals

Git pkt-line encoder

Encode a text payload or Git protocol control packet.

Your inputs

Start with an example

Your inputs stay in your browser.

Your result

Example result

How it works

Prefix data with four hexadecimal digits counting the prefix plus UTF-8 payload bytes. Control packets use 0000, 0001 or 0002.

hello followed by LF is 6 payload bytes and encodes with length prefix 000a.

Limits

Data mode requires nonempty text. This is not a complete Git exchange. Binary non-UTF-8 payloads are excluded.