Base64 Encoder / Decoder
Encode and decode Base64 strings online. Supports text and hex input with URL-safe Base64 option for Ethereum development.
Examples
About Base64 Encoding
- Base64 encodes binary data into ASCII text using 64 characters (A-Z, a-z, 0-9, +, /)
- URL-safe variant replaces + with - and / with _ (RFC 4648)
- Common uses: encoding ABI data, JWT tokens, data URIs, API payloads
- Encoded output is ~33% larger than the original binary data
How to Use This Base64 Encoder / Decoder
This free online Base64 tool lets you encode and decode data in both standard and URL-safe Base64 formats. It supports text and hex input modes for maximum flexibility.
- Select your input mode — choose between text (UTF-8) or hex input depending on your data format.
- Enter or paste your data into the input field. For hex input, you can include or omit the 0x prefix.
- Click Encode to convert your input to Base64, or click Decode to convert Base64 back to its original form.
- Toggle URL-safe mode if you need Base64 output that is safe for URLs and filenames.
- Copy the result for use in your code, APIs, or on-chain metadata.
All encoding and decoding happens locally in your browser. No data leaves your machine.
Common Use Cases
- On-chain NFT metadata — Encode JSON metadata and SVG images as Base64 data URIs for fully on-chain NFTs.
- JWT token inspection — Decode Base64 segments of JWT tokens to inspect claims and payloads.
- API data encoding — Encode binary data or complex objects for safe transmission in HTTP headers, query parameters, or JSON payloads.
- Smart contract bytecode — Convert between hex bytecode and Base64 for storage or display in different contexts.
- Data URI creation — Generate data URIs for embedding images, fonts, or other assets directly in HTML or contract metadata.
Related Tools
UTF-8 / Hex / Bytes Converter
Convert between UTF-8 text, hex strings, and byte arrays for encoding Ethereum data.
JWT Decoder
Decode and inspect JSON Web Tokens to view header, payload, and signature claims.
URL Encoder / Decoder
Encode and decode URL components for safe transmission in query strings and API requests.
Frequently Asked Questions
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /). It converts every 3 bytes of input into 4 ASCII characters, making binary data safe for transmission through text-based protocols like HTTP, email, and JSON. The output is approximately 33% larger than the input.
What is URL-safe Base64?
URL-safe Base64 replaces the + and / characters with - and _ respectively, and typically omits the = padding. This variant is safe for use in URLs and filenames without percent-encoding. It is commonly used in JWTs (JSON Web Tokens), data URIs, and API parameters where standard Base64 characters would cause issues.
How is Base64 used in NFTs and on-chain data?
On-chain NFTs use Base64 to encode metadata and SVG images directly in the token URI. The tokenURI returns a data URI like 'data:application/json;base64,...' containing the Base64-encoded JSON metadata, which itself may contain Base64-encoded SVG or image data. This enables fully on-chain NFTs without external storage.
What is the difference between Base64 and hex encoding?
Base64 uses 64 characters and is more space-efficient, producing output that is 33% larger than the input. Hex encoding uses only 16 characters (0-9, A-F) and doubles the size of the input. Ethereum primarily uses hex encoding for addresses, hashes, and calldata, while Base64 is more common for metadata, images, and web APIs.
Can I encode binary files with Base64?
Yes. Base64 can encode any binary data including images, PDFs, and compiled bytecode. However, be aware that Base64 increases the data size by approximately 33%. For on-chain storage, this overhead translates directly to higher gas costs, so it is important to minimize data before Base64 encoding.
Related Tools & Guides
Try Also
RLP Encoder / Decoder
Encode and decode Recursive Length Prefix (RLP) data. The serialization format used by Ethereum transactions and blocks.
Bytes32 / String Converter
Convert between bytes32 hex, UTF-8 strings, numbers, and addresses. Visualize padding for Solidity bytes32 values.
Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal online. Supports arbitrarily large numbers with BigInt.