Developer Utilities

File to Base64

All tools

Choose a file and copy its contents as Base64, with or without the data URL prefix.

How it works

Four simple steps

1

Choose a file

Use the file picker; any type works, from PNG to PDF to fonts.

2

Set the prefix

Keep Include data URL prefix on for src attributes, off for raw Base64.

3

Check the details

The status line confirms the file name and size in bytes.

4

Copy the result

Copy the string or download it as file.b64.txt.

File to Base64

About File to Base64

You want a 2 KB SVG icon inline in a stylesheet so the page makes one fewer request, or a test fixture needs a small PDF embedded in a JSON body. Running base64 in a terminal is easy on Linux and awkward on Windows. This tool reads the file and hands you the string.

Select a file with the picker. The browser's FileReader reads it as a data URL, and by default you get the full form, for example data:image/png;base64,iVBOR..., with the MIME type the browser detected. Untick Include data URL prefix to keep only the Base64 payload, which is what most JSON APIs and environment variables expect. The status line shows the file name and size in bytes, and the result can be copied or downloaded as a text file.

Mind the overhead: Base64 is about 33 percent larger than the original, and a big inline image delays rendering and bloats HTML. It suits small icons, fonts in test fixtures and short attachments, not photos. For pictures, the image to Base64 tool is tuned for that job, and encoding plain text is simpler when you only have a string.

The file is read from disk by your browser and converted in memory. It is not uploaded, so a contract PDF or private key file stays on your machine. Very large files can make the tab sluggish, because the whole result sits in one text box.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

Use the data URL when the value goes straight into an img src, a CSS url() or an HTML email. Use the raw Base64 for JSON fields, API payloads and environment variables, where the receiving code adds its own context.

The MIME type comes from the browser, which infers it from the file extension. Unknown or missing extensions fall back to a generic binary type. Edit the prefix by hand if the receiving side needs a specific type.

There is no fixed cap, but the whole encoded string is held in the page. Files of a few megabytes are fine; hundreds of megabytes will strain the tab, and the output would be impractical to paste anywhere anyway.

View more FAQs

Related tools

View all

Cron Calendar

Explain cron expressions and preview the next run times in any timezone.

Open

CSV to SQL

Infer column types and generate CREATE TABLE + INSERT statements from CSV.

Open

SQL Query Builder

Build SELECT queries visually and reverse-parse SQL into a structure tree.

Open

Log Pattern Miner

Cluster log lines into templates, surface anomalies, and mask PII locally.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools