🧑‍💻

File to Base64

🔒 In your browser

Convert any file to Base64 or a data URI — in your browser.

🔒 The file is read locally with the FileReader API — it never leaves your device.

💾You might also need Base64 to File

🔒 Files stay on your device: conversion happens entirely in your browser using the FileReader API — your file is never uploaded to any server, unlike many other online converters.

About the File to Base64

Sometimes you need a file as text — to inline it in JSON, a config file or as a data URI. This free file-to-Base64 converter turns any file (PDF, image, font, anything) into a Base64 string or a ready-to-use data URI, entirely in your browser.

Your file is read locally with the FileReader API and is never uploaded to a server — unlike many online converters.

How to convert a file to Base64

  • Choose any file from your device.
  • Copy the Base64 string, or the full data URI with the correct MIME type prefix.
  • Paste it into JSON, CSS, HTML or your code.

What a data URI is for

A data URI embeds a file's contents directly in a string like data:application/pdf;base64,… so it can be used inline — in JSON, in CSS, or in code — without a separate file on disk. This tool reads any file in your browser and gives you both the raw Base64 and the ready-to-paste data URI. The file is read locally with the FileReader API and never uploaded.

Frequently asked questions

How do I convert a file to Base64?

Select the file and the tool reads it in your browser and outputs its Base64 encoding, plus a data URI you can paste directly into code or markup.

Is my file uploaded to a server?

No. The file is read locally in your browser with the FileReader API and never leaves your device.

What's a data URI?

A data URI embeds the file's contents directly in a string like data:application/pdf;base64,... so it can be used inline without a separate file.

Is my file uploaded to convert it?

No. The file is read locally in your browser with the FileReader API and never leaves your device — unlike many online converters that upload it to a server.

Related searches

file to base64encode file to base64data uripdf to base64base64 encode filefile base64 online

Related Developer tools

🔗 Embed this tool on your website — free

Copy this and paste it into your page's HTML. The tool runs in the visitor's browser, just like here. Change height to fit, or add the optional auto-resize snippet below. Add ?theme=dark to the URL for dark mode.

<iframe src="https://toolhq.dev/embed/file-to-base64/" title="File to Base64 — ToolsHub" width="100%" height="520" style="border:1px solid #e5e7eb;border-radius:12px;max-width:680px" loading="lazy"></iframe>
Optional: auto-resize the iframe height

Add this once on the same page so the iframe grows to fit the tool:

<script>
addEventListener("message", function (e) {
  if (e.data && e.data.type === "toolshub:resize") {
    document.querySelectorAll('iframe[src*="/embed/"]').forEach(function (f) {
      if (f.contentWindow === e.source) f.style.height = e.data.height + "px";
    });
  }
});
</script>