Base64 to File Converter

Converter

Convert any file to a Base64 data URL for embedding in HTML, CSS, JSON or email, and decode Base64 strings back into downloadable original files — all processed locally in your browser.

About Base64 to File Converter

Embedding an image in CSS, sending an attachment as a data URI, or carrying a small file inside JSON all require encoding a binary file as Base64 text. This tool encodes files (images, PDFs, fonts, and more) into Base64 strings locally in your browser, and decodes Base64 back into a downloadable file, optionally producing a data URI with the MIME type. Files never leave the browser or reach a server, so even sensitive documents are safe.

This encoding inflates size by about a third, a cost to recognise before use. It represents arbitrary binary data with a limited set of printable characters, so every three bytes need four characters and line breaks plus padding add further overhead. For large transfers, weigh direct binary transport instead of defaulting to converting everything into this text form.

Inline data and plain encoded text are different artefacts and the wrong one burdens the consumer. The inline form with a type prefix drops straight into markup or styles and is parsed by the browser, suiting small icons, while plain text holds only characters and requires the recipient to know the type. Offer inline for display and plain text for further processing.

Large files must not be read into memory at once, a hard engineering limitation. Conversion processes data in groups, and loading a whole file then converting exhausts resources at hundreds of megabytes, whereas chunked processing with block sizes that are a multiple of the group size yields correct output at flat memory. Prefer a streaming implementation for large files.

Tolerance of whitespace and line breaks differs across implementations, another practical problem. Some output wraps at a fixed length for readability while some parsers error on a line break, and a lenient parser ignoring all whitespace accepts input others reject. Agree on whitespace handling between systems rather than relying on one side default.

The encoding offers no confidentiality, and treating it as encryption is a dangerous misconception. Anyone can restore the content, so encrypt sensitive material before encoding and keep the two steps distinct. It also cannot verify integrity, so data truncated in transit may decode to a leading fragment instead of failing.

Finally, type information is easily lost and must travel separately. The encoding carries bytes only, not what file they came from, leaving the recipient with data of unknown purpose. State the filename and type at delivery or use a typed inline form, and before inlining large assets as text, confirm it is worth giving up caching and compression.

How It Works Internally

The only difference from encoding text is the input form: a file is read as bytes with no charset interpretation, so binary files encode losslessly, while text is first encoded to bytes through a charset. That is also why decoding the result and writing it back yields a file identical byte for byte to the original.

InputA 3 KB binary file
OutputAbout 4 KB after encoding (four thirds of the original); decoding and writing back gives a byte-identical file

Measured on This Page

Data URL exactThe PNG yields data:image/png;base64,… with a payload identical to base64.b64encode (73 bytes)
Large fileThe 204,800-byte binary payload also matches exactly, with no truncation or inserted line breaks
MIME from the fileimage/png and application/octet-stream come out right; the type comes from the browser's File.type, not from the extension
Size format1023 bytes shows 1023 B and 1024 bytes shows 1.0 KB (binary 1024, not 1000)
Payload onlyA separate button copies the payload without the data: prefix, with its length shown
Decode path (measured 2026-11-03)A 1×1 PNG data URI previews and downloads correctly; raw Base64 infers the type from the output file extension; stray characters surface a Base64-invalid message

The size cost is obvious: base64 turns every 3 bytes into 4 characters, +33%, so a 204 KB file becomes roughly 273 KB of text. That suits inlining a small icon or two, not transferring files — if you must send a large file over a text channel, compress before encoding. When inlining in CSS or HTML also remember that SVG can be embedded as URL-encoded plain text instead of base64, which trades size for readability very differently.

How this was measured: Files with known bytes were generated with PIL and openpyxl (a 73-byte 2x2 PNG and a 204,800-byte binary), injected into the page as a File object on the input with a change event, and the emitted data URL compared character by character against Python base64.b64encode; the size formatter was probed at 1023 and 1024 bytes. · Measured 2026-10-30

How to Use

  1. Open "Base64 to File Converter"
  2. Encode: drop a file or click the dashed box
  3. Encode: check the name, MIME type and size, then copy Base64 or the Data URL
  4. Decode: switch to Base64 → file and paste the Base64 or data URI
  5. Decode: set the output file name with an extension, preview, then download

Use Cases

  • Inline icons — Encode a small icon as a data URI to drop into CSS and save an HTTP request.
  • Email attachments — Convert a file to Base64 to embed in an email or an API JSON field.
  • Restore files — Decode a Base64 string from an API and download it as the original image or PDF.
  • Inline configs — Encode a certificate or font to embed in config and ship with the program.
  • Quick inspection — Decode an unknown Base64 blob, preview the result and check its size and type.
  • Favicon generation — Encode a small PNG or SVG as a Base64 data URI to embed inline in HTML for a zero-request favicon.
  • API response inspection — Decode a Base64 file from an API response to verify the returned image, PDF, or binary matches expectations.

FAQ

Does Base64 make files bigger?

Yes. Base64 uses 4 characters per 3 bytes, growing size by about 33%. In return you can move binary safely through text-only channels — best for small files, not large ones.

How does a data URI differ from raw Base64?

A data URI prepends data:type;base64, so browsers render it directly; raw Base64 is just the encoded string and needs the type communicated separately.

How large a file can it handle?

Encoding happens in browser memory, so a few MB is fine, but tens of MB can get slow or stutter. Use a CLI tool for large files.

How do I know the file type when decoding?

If the source is a data URI with a MIME type, the tool uses it and previews the result; for raw Base64 it infers the type from the extension of the output file name you enter (.png, .pdf), so complete the name before downloading.

Can line breaks or spaces break decoding?

Standard Base64 is sometimes line-wrapped. The tool usually ignores whitespace before decoding, but a truncated string or non-Base64 characters will fail.

The tab freezes when converting a large file?

Base64 runs in memory and a few tens of MB can cost multiples in RAM while blocking the main thread. Above ~20MB split the file or use the command line (base64). The browser route suits config files and small images, not bulk conversion.

The Base64 contains / and + — will it break in a URL?

Yes. Standard Base64 includes + / = which URL parsers treat specially. Use the Base64URL variant (- instead of +, _ instead of /, no = padding) for URLs and filenames. The variants decode differently — mixing them yields corrupt data.

The checksum changed after conversion — is the file corrupted?

Base64 is lossless and reversible: decoded bytes match the original exactly, checksums included. A mismatch means the transport mangled the text — line wrapping, a stripped trailing newline, or a charset change. Verify the text integrity before blaming the tool.