Hex Encode/Decode (Binary)
100% client-side processing (no server upload). Convert binary files to Hex text (plain, 0xβ¦, C \xHH, or %HH) and decode Hex text back into a file with strict validation, separator handling, and predictable output formatting.
Features
- 100% client-side processing (no server upload).
- Upload and batch-process multiple files via a dropzone (multi-file enabled).
- Two actions: Encode file β Hex text, or Decode Hex text β file.
- Hex output formats: plain (deadbeef), 0x⦠prefix, C escape (\xHH), and percent (%HH).
- Letter case control: lowercase or uppercase hex digits.
- Byte separators for readability: none, space, colon (:), dash (-), underscore (_), comma (,).
- Encode-only wrapping: wrap bytes per line (0 disables wrapping) + selectable line separator (LF or CRLF).
- Encode-only toggles: insert final newline; optional 0x per byte (0xDE 0xAD β¦) for 0x-style output.
- Decode-only parsing controls: accept 0x prefix, accept \xHH escapes, accept %HH encoding, allow separators/whitespace, ignore non-hex characters, and odd-length handling (error or left-pad with 0).
- Strict validation mode to reject malformed input early instead of best-effort parsing.
How to use for hex-binary-encoder
Drop a file or paste Hex text
For encoding, drop one or more binary files into the dropzone. For decoding, paste Hex text into the output editor (or drop a .hex/.txt file containing Hex).
Choose action and run
Select the Action: "Encode file β Hex" or "Decode Hex β file", then click the matching button (Encode/Decode). Configure options as needed: format (plain/0x/\xHH/%HH), case, separators, wrapping + line separator (encode), or accept-toggles + separator handling + odd-length rules (decode).
Copy or download the result
If you encoded, copy the generated Hex text from the editor or download it as a text output. If you decoded, download the reconstructed binary file (the tool strips a .hex suffix when possible and falls back to .bin).
Technical specifications
Execution Model
This tool runs entirely in your browser and does not upload your input to a server.
| Aspect | Detail |
|---|---|
| Runtime | 100% client-side processing (no server upload). |
| Action scope | Encode (binary file β Hex text) and Decode (Hex text β binary file) on the same page. |
| Input | Encode: binary (File/Blob/Uint8Array/ArrayBuffer/TypedArray). Decode: text (Hex string with optional tokens and separators). |
| Output | Encode: text (Hex). Decode: bytes (downloadable binary file). |
| Limits | ~1β2MB chars; ~25000 ms timeout |
| Retention | All processing happens locally in your browser (no upload) |
Mini Example
Small examples to illustrate both actions and common formats.
Encode (binary bytes): 48 65 6c 6c 6f 0a
Output (plain, lower): 48656c6c6f0a
Decode (Hex text): 48 65 6c 6c 6f 0a
Result (file bytes): 48 65 6c 6c 6f 0a
Errors & Edge Cases
Typical failures when converting between Hex text and raw bytes, and how the UI options influence them.
| Symptom | Likely cause | What to check |
|---|---|---|
| Encode says to upload a file | You provided text input to the encode action | This tool encodes binary data. Switch to Decode for Hex text input, or upload a file/bytes for Encode. |
| Decode error: invalid hex / malformed tokens | Input contains non-hex characters or a token style you disabled | Enable "Accept 0x prefix" / "Accept \xHH escapes" / "Accept %HH encoding" as appropriate; decide whether to allow separators/whitespace. |
| Decode fails on separators or whitespace | Separators are present but disallowed (or strict mode rejects them) | Enable "Allow separators/whitespace"; if you want strict parsing, keep "Ignore non-hex characters" off and rely on explicit token acceptance. |
| Odd number of hex digits | Truncated hex stream or missing a nibble | Set "Odd hex digits" to "Error" to fail fast, or "Left-pad with 0" if you intentionally accept odd-length inputs. |
| Unexpected output size or mismatched bytes | Ignoring non-hex characters removed meaningful characters, or strict mode is off and parsing is best-effort | Use "Strict validation" when correctness matters; disable "Ignore non-hex characters" if you expect only well-formed tokens. |
| Output wrapping/newlines are not what you expect (encode) | bytesPerLine, line separator, or final newline settings are enabled | Set "Wrap bytes per line" to 0, choose LF vs CRLF, and toggle "Insert final newline" as needed. |
Command line alternatives
For automation, CI, or sensitive data, prefer local command-line tools. The examples below are canonical and commonly available.
Linux/macOS
Encode a file to plain hex (xxd)
xxd -p -c 256 input.bin > output.hex.txtPrints the file as plain hex (no 0x/\x tokens). Use -c to control line width.
Decode plain hex back to a file (xxd)
xxd -r -p output.hex.txt > restored.binReverse plain-hex back to raw bytes. If your hex text contains separators or prefixes, normalize it first.
Node.js
Encode a file to hex (Node Buffer)
node -e "const fs=require('fs');const b=fs.readFileSync('input.bin');process.stdout.write(b.toString('hex'))" > output.hex.txtOutputs continuous lowercase hex. Add your own formatting if you need separators or line breaks.
Decode plain hex text to a file (Node Buffer)
node -e "const fs=require('fs');const hex=fs.readFileSync('output.hex.txt','utf8').trim();fs.writeFileSync('restored.bin',Buffer.from(hex,'hex'));"Parses only plain hex. Strip 0x/\x/% tokens and separators before decoding.
Use cases
Debugging binary payloads
- Turn a small binary file into readable Hex for bug reports and review
- Compare two binary outputs by converting both to a normalized Hex representation
Interoperability across tools
- Generate 0x-prefixed or separator-delimited Hex to match the expectations of downstream tooling
- Decode Hex dumps that include C-style \xHH tokens or percent-style %HH bytes
CI fixtures and test vectors
- Store small binary fixtures as Hex text for easy diffs in code review
- Use strict validation to fail fast when test inputs are malformed
Teaching bytes and representations
- Show how the same bytes can be represented as plain hex, 0x-prefixed tokens, or \xHH escapes
- Demonstrate why separators and odd-length handling are explicit parsing choices
β Frequently Asked Questions
Is there a public API?
API.Is processing local or remote?
Can I use this for secrets (API keys, credentials, proprietary files)?
Why does decoding fail with "invalid hex" or "malformed input"?
Pro Tips
For stable comparisons, encode with a fixed format (plain), a fixed case, and no separators; then add separators/wrapping only for readability.
When decoding dumps from code or logs, turn on the token accept options you expect (0x, \xHH, %HH) and allow separators/whitespace to avoid manual cleanup.
Use "Strict validation" (and consider disabling "Ignore non-hex characters") when correctness matters more than best-effort recovery.
Keep inputs under ~1β2MB and use local CLI tools for large files or CI pipelines to avoid browser limits/timeouts.
Additional Resources
Other Tools
- CSS Beautifier
- HTML Beautifier
- Javascript Beautifier
- PHP Beautifier
- Color Picker
- Sprite Extractor
- Base32 Binary Encoder
- Base32 Decoder
- Base32 Encoder
- Base58 Binary Encoder
- Base58 Decoder
- Base58 Encoder
- Base62 Binary Encoder
- Base62 Decoder
- Base62 Encoder
- Base64 Binary Encoder
- Base64 Decoder
- Base64 Encoder
- Hex Decoder
- Hex Encoder
- Csharp Formatter
- Csv Formatter
- Dockerfile Formatter
- Elm Formatter
- ENV Formatter
- Go Formatter
- Graphql Formatter
- Hcl Formatter
- INI Formatter
- JSON Formatter
- Latex Formatter
- Markdown Formatter
- Objectivec Formatter
- Php Formatter
- Proto Formatter
- Python Formatter
- Ruby Formatter
- Rust Formatter
- Scala Formatter
- Shell Script Formatter
- SQL Formatter
- SVG Formatter
- Swift Formatter
- TOML Formatter
- Typescript Formatter
- XML Formatter
- YAML Formatter
- Yarn Formatter
- CSS Minifier
- Html Minifier
- Javascript Minifier
- JSON Minifier
- XML Minifier
- Http Headers Viewer
- PDF To Text
- Regex Tester
- Serp Rank Checker
- Whois Lookup