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.
More Byte Array Tools
View all 17Java 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
- Paste the array, including the declaration if you have it - the variable name is reused.
- Pick the target language, decimal or hex values, and values per line.
- 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
Explore More Tools
Keep going with related categories and our most used tools.