Text to Go Byte Slice Converter

Paste text to get a Go byte slice with each UTF-8 byte written in hexadecimal or decimal.

Paste text or load a UTF-8 file. Spaces and line breaks count as input.
UTF-8 text files up to 10 MB. For spreadsheets, save a copy as CSV or TSV first.

Conversion requires JavaScript.

Transformations (2 enabled)

ArrayCat cleans up and encodes values before grouping duplicates or sorting. It escapes the values for the output format last.

Cleanup
Encoding
Duplicates and ordering
Counting two copies of apple gives 2:apple.
Saved presets

Presets keep your formats and cleanup settings in this browser.

Delete or overwrite the preset to remove any text saved with it.

Worked example

Input text
Café
Go byte slice
[]byte{0x43, 0x61, 0x66, 0xc3, 0xa9}

Café takes five UTF-8 bytes because é takes two. Those last two bytes are 0xc3 and 0xa9, or 195 and 169 in decimal. Choose Byte format to switch between them.

A byte slice literal is handy for test data or a binary example. If your Go code already has the string in a variable called s, []byte(s) gives you its bytes. See the Go language specification.