Skip to main content
Byte Array Tools

Byte Array Formatter

Convert a byte array from one programming language to another - C, C++, Java, Kotlin, C#, Python, JavaScript, Go, Rust, PHP or JSON - with decimal, hex or binary values.

Paste an array written for one language and get the same bytes declared correctly for another - including the (byte) casts Java needs.

Paste an array from one language and get it in another - C, C++, Java, Kotlin, C#, Python, JavaScript, Go, Rust, PHP or JSON.

Java and Kotlin bytes are signed, so values above 127 need a cast or a negative number - the formatter adds them for you.

What Is the Byte Array Formatter?

It converts a byte array written for one programming language into the same bytes for another. Paste a C unsigned char array, a Java byte[] with casts, Python bytes([...]), a JavaScript Uint8Array, a Go []byte, a Rust array or plain numbers, and get it back as C, C++, Java, Kotlin, C#, Python, JavaScript, Go, Rust, PHP or JSON.

When to Use It

  • Porting test vectors, lookup tables or protocol constants from one codebase to another.
  • Moving a firmware asset from C to Rust, or a crypto test vector from Java to Python.
  • Tidying a long array into a fixed number of values per line.

How to Use It

  1. Paste the array, including the declaration if you have it - the variable name is reused.
  2. Pick the target language, decimal or hex values, and values per line.
  3. Copy the result.

Example

The C line unsigned char gif_header[] = {0x47, 0x49, 0x46, 0x38, 0x39, 0x61}; converted to Rust in hex becomes let gif_header: [u8; 6] = [0x47, 0x49, 0x46, 0x38, 0x39, 0x61]; - the six bytes that spell GIF89a.

Understanding the Output

Java and Kotlin bytes are signed (-128 to 127). In hex output the formatter writes (byte) 0xC8 in Java and 0xC8.toByte() in Kotlin; in decimal output it writes -56. Other languages use unsigned bytes and need no casts.

Limitations

Only the numbers are converted - comments, other variables and non-byte arrays (such as int[] with values over 255) are not. The tool cannot guess an ambiguous list such as 12 34; set the input format when it matters. To create an array from a file, use File to Byte Array.

Frequently Asked Questions

Input can be an array from C, C++, Java, Kotlin, C#, Python, JavaScript, Go, Rust or PHP, or plain numbers. Output can be any of these, a plain list or a JSON array.

Their byte type is signed (-128 to 127). Hex values above 0x7F need a (byte) cast in Java or .toByte() in Kotlin; in decimal, the formatter writes negative numbers. All other supported languages use unsigned bytes.

Yes. When you paste a declaration such as unsigned char header[] = {...}, the name header is reused. You can change it in the Variable name field, and it will not be overwritten afterwards.
Share this tool: