Skip to content
Base64 kodēšana / dekodēšana
Tools

Base64 kodēšana / dekodēšana

Konvertē tekstu un failus uz Base64 un atpakaļ ar vienu klikšķi.

0 bytes
0 bytes

Files & images

Runs entirely in your browser. Nothing is uploaded.

A complete Base64 toolkit that never leaves your browser

Base64 turns binary data into plain ASCII text so it can travel safely through systems built for text — email bodies, JSON payloads, URLs, HTML, and CSS. This tool encodes and decodes Base64 for both text and files, and unlike most popular Base64 websites it runs entirely on your device. Nothing you paste or drop is ever uploaded, which matters when the data is an access token, an API key, or anything else you'd rather not hand to a third-party server.

It is built to handle the cases simpler tools get wrong: full Unicode (including emoji and non-Latin scripts), URL-safe Base64URL, MIME and PEM line wrapping, and decoding text that was originally encoded in a non-UTF-8 character set.

Decode anything — with charset control and a forgiving parser

Pasted Base64 is often messy: it picks up line breaks from email wrapping, loses its trailing = padding in a terminal, or arrives as a full data: URI. The decoder cleans all of that up automatically — stripping whitespace, accepting URL-safe characters, restoring padding, and unwrapping data URIs — and if something is genuinely invalid it points to the exact character and position instead of failing silently.

Because Base64 stores raw bytes with no character-set label, decoded text can look garbled when it didn't originate as UTF-8. The Decode as selector lets you reinterpret the same bytes as UTF-16, Latin-1, Windows-1252, ASCII, Shift_JIS, or GBK. Switch to the Hex view to inspect the raw bytes directly when you're debugging binary payloads.

Files and images, with preview and ready-to-paste snippets

Drop a file, click to browse, or simply paste an image from your clipboard. Images preview inline, and the tool detects the file type from its magic bytes — so a decoded blob is correctly recognized as PNG, JPEG, GIF, WebP, PDF, and more, and downloaded with the right extension.

For embedding assets, encode an image and copy a ready-made data URI, a CSS background-image rule, an <img> tag, or a favicon <link> — no need to assemble the string by hand. This is exactly what developers need when inlining favicons, email logos, or icon sprites into a single-file page.

Why this beats other free Base64 tools

Many free Base64 tools — including ones from popular sites like base64decode.org and base64encode.org — process your input server-side. That means your JWT tokens, API keys, and private file contents are transmitted to a remote server you don't control. UtiloKit's Base64 tool runs 100% in JavaScript in your browser. You can even disconnect from the internet after the page loads and it still works perfectly.

CyberChef is excellent but has a steep learning curve for simple encoding tasks. base64.guru handles text well but uploads files to their servers. TinyWow imposes daily limits on free users. UtiloKit offers MIME line-wrapping for email compatibility, PEM formatting for certificates, charset-aware decoding for international text, URL-safe Base64URL support for JWT and OAuth tokens, and file type detection for decoded binaries — all free, all unlimited, all private.

Works on iPhone, Android and any device — no app needed

This Base64 encoder and decoder is fully responsive and works on every device with a modern browser. On iPhone and Android, you can paste text directly from your clipboard, pick files from the Files app or camera roll, and download the encoded or decoded result — all without installing anything. The interface is optimised for small screens at 375px width and up.

Because the tool runs entirely offline once loaded (no server calls, no dependencies), it keeps working in situations where web-based tools from base64decode.org or CyberChef might struggle — inside a VPN, in airplane mode after loading, or on a device with restricted network access. Developers on mobile can decode JWT payloads, engineers on iOS can inspect data URIs, and anyone can embed images in CSS without a desktop machine.

How Base64 encoding works: the step-by-step algorithm

Base64 works by grouping input bytes into three-byte chunks and converting each chunk into four printable characters. First, the raw bytes are laid out as a continuous bitstream. Every 6 bits of that stream maps to an index into the 64-character alphabet: uppercase A–Z (indices 0–25), lowercase a–z (26–51), digits 0–9 (52–61), + (62), and / (63). Because 6 bits can represent 64 values and 8 bits represent 256, encoding three 8-bit bytes (24 bits) always yields exactly four 6-bit groups (also 24 bits) — and four printable characters. This fixed 3-to-4 conversion ratio is why Base64 output is always approximately 33% larger than the input.

A worked example makes the algorithm concrete. Encoding the word Man starts with its ASCII values: M = 77, a = 97, n = 110. In binary those are 01001101 01100001 01101110. Laid end-to-end as 24 bits and split into four 6-bit groups: 010011 (19 → T), 010110 (22 → W), 000101 (5 → F), 101110 (46 → u) — producing the Base64 string TWFu. When the total input length is not a multiple of 3, the final group is padded with zero bits to reach a full 6-bit boundary, and one or two = padding characters are appended to signal that the last encoded group was short. One = means the last input group had 2 bytes; two == means it had only 1 byte.

Decoding reverses the process exactly: each character is looked up in the alphabet to recover its 6-bit index, the four groups are concatenated into 24 bits, and those bits are split back into three bytes. Padding characters are discarded. Because the mapping is a simple lookup table with no key and no state, decoding is instantaneous — there is no secret to discover and no computation to brute-force. This is why Base64 provides zero confidentiality and must never be confused with encryption.

Why Base64 was invented: SMTP, MIME, and the 7-bit ASCII problem

The need for Base64 is rooted in decisions made when the internet was young. SMTP, the email protocol, was designed in the early 1980s for 7-bit ASCII text. Mail servers passed messages through relay nodes that stripped the 8th bit of every byte — a practice inherited from telegraph networks. Binary files, images, and any non-English text that used byte values above 127 were silently corrupted in transit. Sending a photo or a program executable by email was simply impossible with raw bytes.

MIME (Multipurpose Internet Mail Extensions), standardised in RFC 2045 in 1992, solved this by defining a set of content-transfer encodings that made binary data safe for ASCII-only infrastructure. Base64 was specified as MIME's encoding for arbitrary binary because it converts every byte into characters from the safe 7-bit ASCII range, surviving every mail relay that strips the high bit. The same underlying problem — a text-oriented channel that cannot reliably carry arbitrary bytes — appears repeatedly across the web stack: HTTP headers cannot contain raw bytes, cookies are restricted to a subset of ASCII, JSON and XML are text formats where NUL bytes or unescaped binary would break parsing, and HTML attributes cannot contain angle brackets or quotes unescaped. Base64 is the universal answer to all of these constraints because it transforms any binary sequence into a string that any text-oriented system can store and forward without modification.

Today SMTP is mostly 8-bit clean and many email servers support the 8BITMIME extension, but Base64 encoding of attachments persists because the MIME standard is deeply embedded in every mail client and server ever written. The encoding that fixed 1980s email is now woven into JWTs, data URIs, SSH keys, TLS certificates, HTTP Basic Auth, and dozens of other modern standards — all because the same 7-bit safety requirement keeps resurfacing in new contexts.

Base64 variants: standard, URL-safe, MIME, and padding-free

There is no single Base64 — there are several closely related variants that differ in two characters of their alphabet and in how they handle line breaks and padding. Standard Base64 (RFC 4648 §4) uses + and / as the 62nd and 63rd characters and requires = padding. This is the variant used by MIME email attachments, PEM certificates, and most general-purpose encoding libraries. The + and / characters are the source of friction everywhere else.

URL-safe Base64 (RFC 4648 §5, also called Base64url) replaces + with - and / with _. This matters because + means a space in URL query strings and / is the path separator — a standard Base64 string embedded in a URL would be misinterpreted or require percent-encoding, making it longer and harder to read. Base64url is the variant mandated by the JWT specification (RFC 7519), OAuth 2.0 PKCE, and any context where the encoded string appears in a URL, filename, or HTTP header. JWT additionally drops the trailing = padding entirely, because the length of a JWT segment can be inferred from the overall structure, and padding characters in URLs must otherwise be percent-encoded as %3D.

MIME Base64 (RFC 2045) is standard Base64 with a mandatory line break every 76 characters, using CRLF (\r\n). This was required to keep email lines within the traditional 76-character width imposed by early mail systems. PEM (the format used for X.509 certificates and SSH keys) uses the same 64-character line length with headers like -----BEGIN CERTIFICATE-----. When interoperating between systems, the variant matters: a URL-safe string fed to a standard decoder will fail on the - and _ characters, and a MIME-wrapped string fed to a decoder that doesn't strip newlines will fail on the line breaks. A robust decoder — like the one in this tool — normalises all variants automatically.

Where Base64 appears in practice — and why it is not encryption

Base64 is embedded in more places than most developers realise. JWT (JSON Web Tokens) encode both their header and payload as Base64url — paste any JWT into a decoder and you can read the claims (user ID, roles, expiry) in plain text immediately. The signature prevents tampering, but the payload is not encrypted; anyone who intercepts a JWT can read everything in it. HTTP Basic Authentication encodes username:password as Base64 and sends it in the Authorization header — over plain HTTP this is completely insecure because the password is trivially recoverable. Basic Auth is only safe over HTTPS, where TLS encrypts the entire request including the header.

Data URIs (src="data:image/png;base64,...") embed file contents directly into HTML or CSS, eliminating an HTTP round-trip for small assets. Favicons, inline SVG icons, and small UI sprites are common candidates. SSH public keys in ~/.ssh/authorized_keys are Base64-encoded DER structures. X.509 certificates in PEM format are Base64 with header and footer lines. Email attachments have been Base64-encoded since MIME was invented. Storing binary blobs in JSON or XML — common in REST APIs that exchange file content — uses Base64 because neither format has a native binary type.

The most important misconception about Base64 is that it provides any form of security. It does not. Base64 is a reversible encoding with a public, fixed algorithm and no key — decoding is a lookup table operation that any programmer can implement in ten lines. Obfuscating a password or API key by Base64-encoding it offers exactly zero protection; automated scanners routinely decode Base64 strings in source code and configuration files as part of credential-harvesting attacks. If data needs to be confidential, encrypt it with AES or a similar cipher before (optionally) encoding the ciphertext as Base64 for transport. The encryption provides the security; Base64 only provides safe ASCII transport.

Frequently asked questions

What is Base64 and what is it used for?

Base64 is an encoding scheme that represents binary data — files, images, or any bytes — using only 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It's used to move binary safely through text-only channels: embedding images in HTML, CSS, or email, storing binary inside JSON or XML, encoding JWT header and payload segments, and passing values in query strings. It solves the problem of systems that strip, alter or corrupt raw bytes by converting everything to plain ASCII text that survives transport unmodified.

Is Base64 encryption — is it secure?

No. Base64 is encoding, not encryption or hashing — it uses no key and anyone can decode it instantly with any Base64 decoder, including this one. It provides zero confidentiality and should never be used to protect passwords, API keys, or private data. Base64 is a transport encoding, not a security measure. If you need to protect sensitive data, encrypt it first (AES, RSA, etc.) and only then optionally Base64-encode the ciphertext for safe transport — but the encryption is doing the protecting, not the encoding.

Is this Base64 encoder and decoder free?

Yes, completely free with no sign-up required and no limits on text length or file size. TinyWow restricts free users to a handful of daily conversions, Smallpdf caps you at 2 tasks per day, and many sites require accounts to unlock full features. UtiloKit's Base64 tool has no daily limits, no account requirement, and no paywalls — it's free for every encoding and decoding operation you'll ever need. No email address, no credit card, nothing.

Is it safe to encode sensitive data here?

Yes. Everything is processed in your browser — text, files, and images are never uploaded to a server — so even sensitive content like tokens or credentials stays on your device. Many popular Base64 sites upload your input to their servers; this one never does. You can verify this by encoding while offline: it still works.

Why does Base64 end with one or two = signs?

The = characters are padding. Base64 encodes input in 3-byte groups that each become 4 characters; when the final group is short, = signs pad the output to a length that's a multiple of 4. One = means the last group had 2 bytes, two = signs mean it had 1 byte. The padding carries no data, so this tool restores any missing = automatically when decoding.

Which characters are allowed in Base64?

Standard Base64 uses A–Z, a–z, 0–9, plus the symbols + and /, with = for padding — 65 characters in total. Anything else (spaces, line breaks, other punctuation) is not part of the alphabet. The URL-safe variant swaps + and / for - and _. This decoder still tolerates whitespace, newlines, and URL-safe characters and tells you the exact position of any character it can't accept.

What are the disadvantages of Base64?

Base64 makes data roughly 33% larger because every 3 bytes become 4 characters — that overhead adds up quickly in HTTP responses, HTML files, or CSS bundles where payload size affects performance. It's not human-readable, which makes code reviews and debugging harder when Base64 strings appear in source. It provides no error detection or checksumming, so a single corrupted character silently produces wrong output. And it offers zero confidentiality — anyone who sees the string can decode it in seconds. It's the right choice for moving binary through text-only channels, but it's not compression and it's not security. For large payloads, use binary transfers with proper Content-Type headers instead.

Is Base64 the same as UTF-8?

No — they solve completely different problems. UTF-8 is a character encoding that converts human-readable text (letters, emoji, symbols) into bytes. Base64 then takes any bytes — including UTF-8 bytes — and converts them into plain ASCII characters safe for text-only transport. The two layer together: to Base64-encode a Unicode string you first convert it to UTF-8 bytes, then encode those bytes as Base64. Skipping the UTF-8 step is the most common bug in naive Base64 tools — they operate on JavaScript's internal UTF-16 representation instead, producing garbled output for anything outside basic ASCII. This tool always converts Unicode text to UTF-8 first, so emoji and every non-Latin script encodes and decodes correctly.

Is Base64 a programming or coding language?

No. Base64 is a data-encoding scheme, not a programming or markup language — there is nothing to run, compile or interpret. It is simply a reversible algorithm that converts arbitrary binary data into a fixed set of 64 printable ASCII characters and back. You use it as a transformation step inside programs written in any language (JavaScript, Python, Go, Java, etc.) but Base64 itself is not a language. Think of it like hexadecimal notation — a representation format, not a language.

What is Base64URL and when should I use it?

Base64URL is a URL- and filename-safe variant that replaces the + character with - and the / character with _, and it drops the = padding characters entirely. This matters because standard + and / have special meaning in URLs — they'd be misinterpreted or percent-encoded by browsers and servers. Use Base64URL for JWT header and payload segments, OAuth tokens, query-string parameters, and file names where you want a safe, readable string. Toggle URL-safe mode in this tool and it encodes and decodes both standard Base64 and URL-safe Base64URL automatically, handling padding either way.

Can I convert files and images to Base64?

Yes. Drop or paste any file or image to get its Base64 string or data URI, with an inline preview for image types. The tool generates ready-to-paste snippets for CSS background-image rules, HTML img src attributes, and favicon link tags, so you don't have to construct the data URI string by hand. In Decode mode it reads the MIME type from the data URI prefix or detects the file type from the raw bytes (magic bytes), previews images inline, and lets you download the original file with the correct extension restored. Works with PNG, JPG, SVG, WebP, GIF, PDF, and more.

Does it handle Unicode and emoji correctly?

Yes. Encoding is Unicode-safe using UTF-8, so accented characters, Arabic, Chinese, Japanese, Korean, and emoji all round-trip correctly without corruption. This is the most common failure in naive Base64 tools: they operate on JavaScript's internal UTF-16 string representation instead of first converting to proper UTF-8 bytes, producing garbled output for anything outside basic ASCII. This tool converts to UTF-8 first, so every character encodes and decodes accurately regardless of script or language.

My decoded text looks garbled — can I fix it?

Yes. Base64 carries no charset information, so text that was originally encoded in a non-UTF-8 charset can look garbled when decoded as UTF-8. Use the 'Decode as' selector to reinterpret the same bytes as UTF-16 (both big-endian and little-endian), Latin-1 (ISO-8859-1), Windows-1252, ASCII, Shift_JIS (Japanese), or GBK (Simplified Chinese) until the text reads correctly. This matters most for Base64 strings that originated in older systems, email clients, or East Asian software that defaults to a regional encoding rather than UTF-8.

Why won't my Base64 decode — it says invalid?

Start with the most common causes: extra whitespace or newlines (this decoder strips them automatically), URL-safe characters like - and _ instead of + and / (also handled automatically), and missing = padding at the end (restored automatically). If the string still fails, you likely have a character outside the Base64 alphabet — a space, a percent sign, a Unicode character, or a stray HTML entity. The decoder tells you exactly which character is invalid and its position in the string so you can locate and fix it. Copy the raw string again from the source, because copy-paste sometimes introduces invisible Unicode characters or smart quotes that look correct but aren't Base64.

How does this compare to other Base64 tools like TinyWow or it-tools?

TinyWow and Smallpdf are primarily PDF/image tools that upload files to their servers. it-tools.tech's Base64 tool is solid but is a self-hosted app. The key difference here is that encoding and decoding happen entirely in your browser — your data is never transmitted anywhere. Plus, this tool handles charset selection, MIME line-wrapping, file preview, and URL-safe Base64 in one place, without any account requirement.