Free Base64 Encoder and Decoder Online
This free base64 encoder decoder lets you encode any text string to Base64 or decode any Base64 string back to plain text, instantly in your browser. Use it to inspect JWT tokens, generate HTTP Basic Auth headers, create data URIs, and debug encoded API responses. No signup, no upload, runs entirely client-side.
How to use the Base64 encoder and decoder online
- Paste any plain text into the input field and click Encode to get its Base64 representation.
- Paste a Base64 string into the input field and click Decode to convert it back to readable text.
- The result appears instantly and can be copied to the clipboard with one click.
- The tool handles both standard Base64 (using + and /) and URL-safe Base64 (using - and _).
- Nothing leaves your browser. All encoding and decoding runs locally with no server requests.
Base64 decode: reading JWT tokens, auth headers, and API responses
The base64 decoder converts any Base64 string back to its original text. The most common developer use case is inspecting JWT (JSON Web Token) payloads during debugging. A JWT has three parts separated by dots: header.payload.signature. The header and payload are both Base64 URL-encoded JSON objects. Paste just the payload section (the middle part, between the two dots) into the decoder to read the claims, expiry, and user data without needing a JWT library.
HTTP Basic Authentication headers also use Base64 encoding. The Authorization header value "Basic dXNlcm5hbWU6cGFzc3dvcmQ=" contains the Base64 encoding of "username:password". Decoding it reveals the credentials in plain text, which is why Basic Auth should only be used over HTTPS. When reviewing request logs or API documentation, this decode base64 to string tool makes it fast to inspect any encoded value without opening a code editor. For URL percent-encoding rather than Base64, the URL encoder and decoder handles that separately.
Base64 encode image and data URIs
Base64 encode image data produces a data URI that can be embedded directly in HTML or CSS without a separate file request. The format is data:[mime-type];base64,[encoded-data]. For small SVG icons and inline images this reduces HTTP requests, which matters for performance in single-file exports, email HTML templates, and CSS sprite alternatives. In an HTML img tag: <img src="data:image/png;base64,iVBO..." />. In CSS: background-image: url("data:image/svg+xml;base64,...").
The base64 decode image direction is useful when extracting an embedded image from an HTML file or CSS stylesheet. Copy the Base64 string after the comma in the data URI, decode it to verify the content, or save the decoded bytes as the original image file. Note that Base64 encoding increases data size by approximately 33 percent compared to the raw binary, so embedding large images as Base64 increases page weight significantly and is not recommended for production use beyond small icons.
JavaScript base64 encode and decode
Every modern browser and Node.js environment includes built-in Base64 support. In a browser context, btoa() encodes a string to Base64 and atob() decodes it. For example: btoa("hello world") returns "aGVsbG8gd29ybGQ=". Both functions operate on Latin-1 encoded strings. For Unicode text, convert to UTF-8 bytes first using TextEncoder before encoding.
In Node.js, the Buffer class handles Base64 encoding natively: Buffer.from("hello").toString("base64") to encode and Buffer.from(str, "base64").toString("utf8") to decode. Node.js also supports URL-safe Base64 via the base64url encoding option in newer versions. For cryptographic operations that produce Base64 output, the SHA hash generator outputs results in both HEX and Base64 format for comparison.
Python and PHP base64 encode
Python includes the base64 module in the standard library. To encode a string: import base64; base64.b64encode(b"hello") returns b"aGVsbG8=". For a plain string instead of bytes, call .encode("utf-8") first. To decode: base64.b64decode("aGVsbG8=").decode("utf-8"). For URL-safe variant: base64.urlsafe_b64encode() and base64.urlsafe_b64decode().
In PHP, the functions are base64_encode() and base64_decode(). For example: base64_encode("hello") returns "aGVsbG8=". PHP base64 encode is commonly used when generating SMTP AUTH credentials, encoding binary data for storage in a text column, and building data URIs for dynamic image generation. The second parameter of base64_decode() accepts a boolean strict mode flag that returns false if the input contains invalid characters.
Linux base64 encode and PowerShell base64 decode
On Linux and macOS, the base64 command is included with GNU coreutils. To encode a string from the terminal: echo -n "hello" | base64. The -n flag is critical: without it, echo adds a newline character that becomes part of the encoded output. To decode: echo "aGVsbG8=" | base64 --decode. To encode a file: base64 file.txt. On macOS the decode flag is -D (uppercase) rather than --decode.
In Windows PowerShell, Base64 encoding and decoding uses the .NET Convert class. To encode: [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("hello")). To decode: [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("aGVsbG8=")). PowerShell base64 decode is also used for the -EncodedCommand flag, which accepts a UTF-16 LE Base64-encoded command string. To decode a PowerShell encoded command use UTF-16 LE rather than UTF-8: [Text.Encoding]::Unicode.GetString([Convert]::FromBase64String($encoded)).
How Base64 encoding works
Base64 converts binary data by grouping every three bytes (24 bits) into four 6-bit values. Each 6-bit value maps to one of 64 printable ASCII characters: uppercase A-Z (0-25), lowercase a-z (26-51), digits 0-9 (52-61), plus (62), and slash (63). If the input length is not a multiple of three, the output is padded with one or two = signs to make the total length a multiple of four characters. This is why Base64 strings always end with 0, 1, or 2 equal signs.
URL-safe Base64 replaces + with - and / with _ to avoid conflict with URL reserved characters. The padding = character is sometimes omitted in URL contexts. This variant is used in JWTs, OAuth 2.0 tokens, and many web API authentication schemes. Base64 is not encryption and provides no security. For generating secure random values, the password generator uses crypto.getRandomValues() which is cryptographically secure. For protecting actual data, the text encryptor provides passphrase-based encryption rather than mere encoding.
Frequently asked questions
Base64 encoding is a method of converting binary or text data into a string of 64 printable ASCII characters: A-Z, a-z, 0-9, plus (+), and slash (/). It was designed to safely transmit binary data over systems that were built to handle only plain text, such as email protocols and HTTP headers. The name Base64 comes from the fact that each encoded character represents 6 bits of data, giving 2^6 = 64 possible values. Every 3 bytes of input data become 4 Base64 characters, increasing size by about 33 percent.
Use this page. Paste your text or Base64 string into the input field, select Encode or Decode, and the result appears instantly. Everything runs in your browser using the built-in atob() and btoa() APIs. Nothing is sent to any server. You can encode any plain text string to Base64 or decode any valid Base64 string back to readable text without installing any software or creating an account.
In a browser, use btoa() to encode and atob() to decode. For example: btoa("hello world") returns "aGVsbG8gd29ybGQ=". To decode: atob("aGVsbG8gd29ybGQ=") returns "hello world". For Node.js, use Buffer: Buffer.from("hello world").toString("base64") to encode and Buffer.from("aGVsbG8gd29ybGQ=", "base64").toString("utf8") to decode. For URL-safe Base64 in Node.js, replace + with - and / with _ in the encoded output and strip any = padding characters.
Python's standard library includes the base64 module. To encode: import base64; base64.b64encode(b"hello world") returns b"aGVsbG8gd29ybGQ=". To decode: base64.b64decode("aGVsbG8gd29ybGQ=") returns b"hello world". For URL-safe Base64 use base64.urlsafe_b64encode() and base64.urlsafe_b64decode(). To encode a string (not bytes), call .encode("utf-8") first: base64.b64encode("hello".encode("utf-8")).
Linux includes the base64 command built into coreutils. To encode: echo -n "hello world" | base64 returns "aGVsbG8gd29ybGQ=". The -n flag prevents echo from adding a newline, which would otherwise be included in the encoded output. To decode: echo "aGVsbG8gd29ybGQ=" | base64 --decode returns "hello world". To encode a file: base64 filename.txt. To decode a file: base64 --decode encoded.txt > output.txt. On macOS the flag is -D instead of --decode.
In PowerShell, use the Convert class from .NET. To decode: [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("aGVsbG8gd29ybGQ=")) returns "hello world". To encode: [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("hello world")) returns "aGVsbG8gd29ybGQ=". PowerShell also uses Base64-encoded commands for the -EncodedCommand flag, which accepts a UTF-16 LE encoded string rather than UTF-8.
Encoding an image to Base64 creates a data URI you can embed directly in HTML or CSS without a separate HTTP request. The format is: data:[mime-type];base64,[encoded-data]. For example: data:image/png;base64,iVBORw0KGgo.... In HTML: <img src="data:image/png;base64,..." />. In CSS: background-image: url("data:image/svg+xml;base64,..."). This is useful for small icons and SVGs in single-file deployments but increases HTML size by 33 percent, so it is not recommended for large images.
No. Base64 is an encoding scheme, not encryption. It converts data to a different representation but applies no secret key and provides no security or confidentiality. Anyone who sees a Base64 string can decode it instantly. Do not use Base64 to hide or protect sensitive data. If you need to protect a value, use real encryption with a secret key. Base64 is used for safe transmission of binary data over text-based protocols, not for security.
Related articles

How to Check Monitor Refresh Rate: Step-by-Step Guide
Learn how to check your monitor refresh rate on Windows and Mac, fix 144Hz running at 60Hz, and verify your actual rate with an online test tool.
8 min read
Fake Data for Testing: A Developer's Guide to Synthetic Data
Learn why developers use fake identity data for testing, what a generator produces, how it differs from anonymized data, and how to use it correctly.
9 min readDead Pixel Test: How to Find and Fix Screen Issues
Learn how to run a dead pixel test, identify dead vs stuck vs hot pixels, fix stuck pixels with our free tool, and know when to file a warranty claim.
9 min read