logo
GeekFormat

Base64-Hex Converter

Hex Input
0 characters

Online bi-directional Base64 and hexadecimal (Hex) converter that transforms Hex byte sequences to Base64 encoding and decodes Base64 back to Hex strings. Automatically detects and handles space-separated and newline-delimited Hex input, strips 0x prefixes, and supports selecting lowercase or uppercase Hex output when converting Base64 to Hex. Live conversion begins immediately after input with instant error reporting (invalid characters, odd-length Hex). One-click copy, download as txt file, and automatic content swap when toggling conversion direction. All processing runs locally in your browser via JavaScript — no data uploaded — making it suitable for packet capture analysis, network protocol debugging, binary log transcoding, and API parameter handling.

Related

Use Cases

  • Convert hexadecimal binary data from packet capture tools like Wireshark, Charles, and Fiddler to Base64 for API debugging
  • Decode Base64-encoded binary data returned by APIs to Hex for byte-by-byte protocol field analysis
  • Convert encryption keys, signatures, and hash values between Hex and Base64 representations
  • Quickly switch between packet-captured Hex format and API Base64 parameter format during network protocol development and debugging
  • Binary log analysis: convert hex dump content in logs to Base64 for issue reproduction, or reverse the conversion
  • Handle encoding challenges in CTF competitions and security research by switching rapidly between Hex and Base64
  • Convert Hex-represented binary data to Base64 per API documentation for inclusion in JSON request bodies during development
  • Convert Hex examples in third-party API documentation to actual usable Base64 parameter values during integration
  • Convert Hex-format binary file fragments to Base64 for use in data URIs or embedded configuration files
  • Verify Base64 encoding/decoding correctness by converting back to Hex and comparing against the original byte sequence
  • Visually observe the correspondence between Hex and Base64 encoding schemes when learning encoding principles
  • Perform temporary transcoding during mobile debugging without needing to open a computer

Features

  • Bi-directional conversion: supports both Hex to Base64 and Base64 to Hex in a single tool
  • Smart input processing: automatically strips spaces, newlines, and 0x prefixes from Hex; supports continuous Hex and space-delimited formats (e.g. 48 65 6C 6C 6F)
  • Hex case selection: choose lowercase (a-f) or uppercase (A-F) hexadecimal output when converting Base64 to Hex for different scenario requirements
  • Live conversion: 300ms debounce auto-triggers conversion after input stops — no button click needed, results appear instantly
  • Clear error messages: descriptive error prompts for invalid hexadecimal characters and odd-length Hex strings make troubleshooting straightforward
  • Intelligent direction toggle: when switching conversion direction, the current output automatically becomes the new input for easy bi-directional verification
  • One-click copy: copy output to clipboard with one click for direct use in API parameters or documentation
  • Result download: download conversion results as a txt file for easy saving and sharing
  • One-click clear: quickly clear all input and output to start a fresh conversion
  • Character counter: real-time character count display in input and output areas for quick data length estimation
  • Monospace font: hexadecimal and Base64 content rendered in monospace font for a developer-friendly reading experience
  • Resizable panels: drag the middle divider on desktop to adjust input/output panel width ratio
  • Mobile-friendly: responsive design with tab-based input/output switching on phones, touch-optimized
  • Pure local browser processing: all conversions run locally in your browser via JavaScript — no servers involved, data stays secure

How to Use

  1. Select the conversion direction: Hex→Base64 or Base64→Hex. When you need uppercase Hex output, select "Uppercase" in Base64→Hex mode.
  2. Paste the Hex string or Base64 string to convert into the left input box (supports space-delimited and 0x-prefixed Hex).
  3. The tool automatically converts in real time after input; results appear immediately on the right. Errors are displayed with red prompts.
  4. Click the copy button to copy results, or click the download button to save as a txt file. Toggling direction automatically carries over results for continued conversion.

FAQ

What input formats are supported?

Hex input supports: ① continuous hexadecimal strings (e.g. 48656C6C6F); ② space-separated bytes (e.g. 48 65 6C 6C 6F); ③ 0x-prefixed format (e.g. 0x48 0x65); ④ multi-line Hex with newline separators. The tool automatically strips whitespace and prefixes before conversion. Base64 input automatically ignores whitespace characters.

Can I convert Base64 back to hexadecimal?

Yes. Click the direction toggle button to select "Base64 → Hex" to decode Base64 into a hexadecimal string. You can also choose whether to output lowercase or uppercase Hex.

Why does it say "Hex string length must be even"?

Because two hexadecimal characters represent one byte (00-FF), a valid Hex string must always have an even length. If you see this error, check whether you typed an extra character, missed one, or truncated the input during copy-paste.

Why does it say "Contains invalid hexadecimal characters"?

Hexadecimal only allows the 16 characters 0-9 and a-f/A-F. Any other character (such as g-z, special symbols) will trigger an error. Check whether you accidentally copied non-Hex content or pasted Base64 into the Hex input field.

Will switching conversion direction lose my content?

No. When you click the direction toggle, the tool automatically uses the current output as the new direction's input. You can conveniently convert results back for verification without manual copy-paste.

Can Hex input with 0x prefixes be handled?

Yes. The tool automatically detects and strips leading 0x prefixes — whether the entire string starts with 0x or each byte is individually prefixed (e.g. 0x48 0x65), it will be processed correctly.

Can conversion results be used directly in API requests?

Yes. The Base64 output is standard RFC 4648 encoded plain text that can be placed directly into JSON fields, HTTP request bodies, URL parameters (note URL encoding), or headers. The Hex output is a plain hexadecimal string that can be used directly for binary protocol descriptions, key representation, and similar scenarios.

Why convert between Hex and Base64?

Packet capture tools (such as Wireshark, Charles), protocol analyzers, and binary logs typically display byte streams in hexadecimal for convenient byte-by-byte inspection. However, APIs, JSON, and text configuration files usually require Base64 encoding to transmit binary data (since Base64 uses only text-safe characters). Hex→Base64 converts packet-captured binary data into text format usable by APIs; Base64→Hex restores Base64-encoded data into byte-by-byte readable hexadecimal for debugging and analysis.

Can large files or long Hex strings be converted?

Content up to tens of KB converts locally without issues — browsers process it very quickly. Due to the textarea input limitation, for extremely large content (several MB+) we recommend using specialized tools. For everyday development packet capture debugging and API parameter processing, this tool is fully sufficient.

Will converted data be uploaded to a server?

No. All encoding and decoding runs entirely locally in your browser via JavaScript. Your Hex or Base64 content is never sent over the network to any server. Data is lost when you close the page, so sensitive keys and packet capture data can be processed safely.

Is uppercase hexadecimal output supported?

Yes. In Base64 to Hex mode, toggle the "lowercase"/"uppercase" button to choose between a-f and A-F output. Some protocols, specifications, or documents require uppercase Hex.

Does it work on mobile phones?

Yes. The tool uses responsive design — on phones, input and output are displayed in separate tabs, panels adapt to the mobile screen, and touch interactions are friendly. You can quickly convert on the go during field debugging.

How do I save conversion results?

Two methods: ① Click the copy button to copy directly to the clipboard and paste wherever needed; ② Click the download button (download arrow icon) to save the result as a txt file locally.

What are Hex and Base64 exactly?

Hexadecimal (Hex) is a way of representing binary data using 16 characters: 0-9 and A-F. Each byte is represented by two characters (00-FF), making it suitable for human byte-by-byte reading of binary content. Base64 is an encoding scheme that uses 64 printable characters (A-Z, a-z, 0-9, +, /) to represent binary data, primarily used for safely transmitting binary data over text-based protocols (such as JSON, HTTP, Email). Encoded size increases by approximately 33% compared to raw binary.

How is this tool different from a plain Base64 encoder/decoder?

Regular Base64 encode/decode converts between text strings and Base64, while this tool works with raw byte sequences. Hex itself is the hexadecimal representation of bytes, so Hex↔Base64 conversion is pure byte-level transcoding without text encoding (UTF-8/GBK, etc.) concerns. It is designed for processing true binary data, encryption keys, protocol packets, and similar use cases.

About Hexadecimal and Base64 Encoding

In computer and network development, we frequently need to convert between different binary representation formats. Hexadecimal (Hex) and Base64 are the two most common textual representations for binary data, each with its own use cases: Hex is convenient for human byte-by-byte reading and debugging, while Base64 is suitable for transmitting binary data over text-based protocols. Developers regularly need to convert between the two.

Hexadecimal represents data using 16 characters (0-9 and A-F), where each byte corresponds to two hexadecimal characters (00 to FF). One byte equals exactly two hex digits. This representation is highly intuitive — two characters per byte makes alignment and inspection straightforward. That is why packet capture tools (Wireshark, Charles), hex editors, debuggers, and protocol documentation all use Hex to display binary data, allowing developers to easily locate byte offsets and field values.

Base64 is an encoding scheme that represents arbitrary binary data using 64 printable ASCII characters (A-Z, a-z, 0-9, +, /, plus = as padding). Its primary purpose is to allow binary data to be safely transmitted over protocols that only handle text — for example, raw binary bytes cannot be placed directly in JSON, HTTP header values cannot contain non-printable characters, and email bodies cannot carry raw attachments. Encoding binary into Base64 text solves this problem at the cost of approximately 33% size increase (every 3 bytes encodes to 4 characters).

Why not just use Hex to transmit binary in APIs? You can, but Base64 is more efficient: Hex uses 2 characters per byte for an encoding efficiency of 50% (1 byte → 2 characters); Base64 uses 4 characters per 3 bytes for an efficiency of 75%. So the same binary data is shorter in Base64, making it more commonly used for text transmission. However, Hex is more intuitive for manual reading and analysis, which is why packet capture debugging uses Hex while API transmission uses Base64 — making conversion between the two a common developer need.

This tool performs pure byte-level transcoding without any text encoding (UTF-8, GBK, etc.) assumptions: the Hex string is parsed directly to a byte array, and the byte array is encoded directly to Base64; in reverse, Base64 is decoded directly to a byte array, and the byte array is output directly as a Hex string. This is important — ordinary "string Base64 encoding" involves text encoding conversion, but Hex↔Base64 is a conversion between pure byte representations with deterministic, unique results and no garbled text issues.

The tool supports flexible input formats to accommodate real-world usage: Wireshark's default Hex output is space-delimited per byte, Hex in many documentation includes 0x prefixes, and copy-paste often introduces newlines. Automatic stripping of whitespace and 0x prefixes eliminates manual cleanup — just paste and convert — significantly improving debugging efficiency.

Case selection is another practical feature: different standards and systems have different Hex case preferences — Unix tools and many open source projects favor lowercase (a-f), while Windows and certain enterprise standards favor uppercase (A-F), and cryptography sometimes requires uppercase. The tool provides a case toggle when converting Base64 to Hex, eliminating manual case conversion.

Pure local processing guarantees both security and speed: encoding conversion is essentially simple mathematical arithmetic that requires no server-side computation. Running locally in the browser via JavaScript is extremely fast (microseconds), and sensitive data (keys, signatures, undisclosed protocol data) never leaves your computer — no network transmission leakage risk exists. It works normally even in air-gapped, offline environments.

术语表

Hexadecimal (Hex)
A base-16 numeral system using 0-9 and A-F (a-f) to represent values. Two hexadecimal characters exactly represent one byte (00-FF). It is the most intuitive textual representation of binary data and is widely used in debugging, packet capture, and protocol documentation.
Base64
A binary encoding scheme based on 64 printable ASCII characters that encodes 3 bytes of binary into 4 text characters. Used for safely transmitting binary data in text-based protocols such as JSON, HTTP, and Email. Encoded size increases by approximately 1/3.
Byte
The basic unit of computer data. 1 byte = 8 bits, representing values from 0-255. In Hex it is represented by two characters. It is the fundamental unit of network protocols and binary data.
RFC 4648
The official standard document for Base64 encoding, defining encoding rules for standard Base64 and URL-safe Base64. This tool uses standard Base64 encoding.
0x Prefix
A common prefix in programming to denote hexadecimal numbers (e.g. 0x1A represents decimal 26). Hex in many documents and code includes 0x prefixes, which the tool automatically detects and strips.
Wireshark
The most popular network packet capture and analysis tool. It displays network packet content in hexadecimal+ASCII by default and is a commonly used tool for developers debugging network protocols. Its Hex output is a common input source for this tool.
Binary Transcoding
Conversion between different binary data representation formats (Hex, Base64, Base32, Base58, etc.) without altering the original data itself — only the representation changes.
Monospace Font
A font in which every character has the same width, suitable for displaying code, hexadecimal data, tables, and other content requiring high alignment. The tool uses the system monospace font by default for encoding content.
Debounce
A common frontend performance optimization technique that waits for input to stop for 300ms before executing conversion, avoiding computation on every keystroke and improving smoothness during large input.
Encoding Efficiency
The ratio of raw data length to encoded length. Hex encoding efficiency is 50% (1 byte → 2 characters), Base64 encoding efficiency is 75% (3 bytes → 4 characters). Base64 saves approximately 25% text length compared to Hex.
Padding Character (=)
The = sign at the end of standard Base64 encoding is used for padding to make the encoded length a multiple of 4. Padding characters are ignored during decoding and are part of standard Base64.
Local Processing
All computation is performed in the user's browser via JavaScript. Data is not uploaded to any server, making it both fast and secure — suitable for processing sensitive data.

Hex vs Base64 Encoding Feature Comparison

Comparison of the two binary representation formats:

FeatureHexadecimal (Hex)Base64
Character Set0-9, A-F (16 characters)A-Z,a-z,0-9,+,/,= (65 characters)
Encoding Efficiency50% (1 byte → 2 characters)75% (3 bytes → 4 characters)
ReadabilityHigh (two characters per byte, easy byte-by-byte analysis)Low (not intuitive, hard to read directly)
Typical UsesPacket capture analysis, hex editors, protocol docs, key representationJSON/HTTP/Email binary transmission, Data URIs, API parameters
Case SensitivityNot sensitive (a-f and A-F are equivalent)Sensitive (A and a are different encodings)
Example ("Hello")48656C6C6FSGVsbG8=

Common Binary Data Encoding Reference

Representations of the text "Hello" under different encodings:

Encoding FormatEncoded ResultCharacter Length
Raw TextHello5 bytes
Hex (Lowercase)48656c6c6f10 characters
Hex (Uppercase)48656C6C6F10 characters
Standard Base64SGVsbG8=8 characters (incl. 1 padding)

Common Error Troubleshooting Table

Reference when conversion errors occur:

Error MessagePossible CauseSolution
Contains invalid hexadecimal charactersLetters outside g-z/G-Z or special symbols appear in HexCheck for accidentally pasted Base64 or other text; remove invalid characters
Hex string length must be evenHex character count is odd; one digit missing or extraCheck the beginning and end of input to confirm no truncation
(Base64 decode error)Base64 string is corrupted, has wrong length, or contains invalid charactersCheck that Base64 is complete and has correct padding =

Privacy & Security

All encoding and decoding in this Base64-Hex converter runs entirely locally in your browser via JavaScript. The Hex strings and Base64 content you enter are never uploaded to any server, nor are they recorded, cached, or stored. Input, conversion, copying, and downloading all occur within local browser memory. All temporary data is automatically cleared when you close or refresh the page. Sensitive encryption keys, packet capture data, and internal protocol data can be processed safely with zero leakage risk.

Authoritative References

Troubleshooting

What should I do if pasting Hex shows invalid characters?

Check whether the input contains letters outside g-z/G-Z, Chinese punctuation, or special symbols. Hex copied from Wireshark sometimes includes ASCII sidebar content — copy only the hexadecimal portion. Also confirm the conversion direction is Hex→Base64 and that you are not pasting Base64 into the Hex input field.

What causes the odd Hex length error?

Two Hex characters represent one byte, so valid Hex must be even-length. Common causes: ① the last digit was missed during copy; ② a leading 0x was counted as content, making length minus 2 odd; ③ extra spaces in the middle caused parsing errors — confirm every byte has exactly two characters.

What should I do if Base64 decoding fails?

Check: ① whether Base64 is complete and not truncated; ② whether it contains invalid characters (Base64 only allows A-Z, a-z, 0-9, +, /, =); ③ whether the trailing padding = count is correct (0, 1, or 2); ④ whether it is URL-safe Base64 (using - and _ instead of + and /) — URL-safe Base64 is not currently supported by this tool.

Why is my converted Base64 different from others'?

For text string Base64, different encodings (UTF-8, GBK) produce different results. However, this tool performs pure byte-level Hex↔Base64 transcoding — as long as the Hex is identical, the Base64 output must be identical. If results differ, check: ① whether the Hex is exactly the same (spaces don't matter, and 0x doesn't matter); ② case does not affect Hex parsing; ③ whether invisible special characters are mixed into the Hex.