EncodingFreeNo uploadNo sign-up

Base64 Encode

Encode text or any file to Base64 in one step, with URL-safe and data URI options.

Text
Base64

Runs in your browser. Your data is never sent to a server.

How to use the Base64 Encode

  1. Type text or add a file

    Type or paste text, or switch to File and drop any file, such as an image, PDF or font.

  2. Pick the variant

    Standard Base64, URL-safe Base64 for links and tokens, 76-character lines for email, or a full data URI.

  3. Copy the result

    The Base64 updates as you type. Copy it or download it as a text file.

Why use this tool

Base64 encoding is how binary data and special characters get through systems that only accept plain text: HTTP headers, JSON fields, environment variables, YAML secrets and email bodies. Every 3 bytes become 4 characters from a 64-letter alphabet.

This encoder treats text as UTF-8, so non-English characters and emoji encode correctly, unlike the browser’s btoa(), which fails on them. Switch to URL-safe output when the value goes into a URL or a token, and use the data URI option to embed a file straight into HTML or CSS.

Frequently asked questions

How do I encode text to Base64?

Type or paste the text. The Base64 version appears immediately and you can copy it with one click.

What is URL-safe Base64?

A variant that replaces + and / with - and _ and usually drops the = padding, so the value can be used in URLs and filenames without escaping. JWTs use it.

Why does btoa() fail with “Invalid character”?

btoa() only accepts Latin-1 characters. Encode the text as UTF-8 bytes first, which is what this tool does, or in code: btoa(String.fromCharCode(...new TextEncoder().encode(text))).

Can I encode a file to Base64?

Yes. Switch to File and drop any file. You get the raw Base64 or a data URI, ready to paste into HTML, CSS or JSON.

Are my files uploaded to a server?

No. formatmath converts files with code that runs inside your browser. Your files are never uploaded, stored or seen by us.

Is it free?

Yes. There is no watermark and no daily limit. An account is optional and only keeps a history of your conversions.

Latest guides and news

We made this tooFree fee and profit calculators for Etsy, eBay and Amazon sellers.fee-math.com →