100% local processing — your files and data never leave this browser. No uploads, no server storage.

OnboxTools

Free · Browser-only · No upload

Base64 encode text online

Convert strings to Base64 with full Unicode support

Base64 encode online — paste any UTF-8 text and get a Base64 string safe for JSON fields, config files, and API payloads. Built for developers who need a fast base64 converter without installing desktop utilities.

Encoding runs entirely in your browser with native TextEncoder — nothing uploads. Use our Base64 Decoder to convert Base64 strings back to readable text.

Need the reverse conversion?

Base64 Decoder
Plain text
Base64 output
URL-safeOff
Size change

More Text Utilities

🔓
Base64 Decoder
🧬
Base64 Encoder
🔡
Case Converter
Cron Generator
🎨
CSS Minifier
📐
CSS Unminifier
📆
Date Format Converter
📅
Date to Unix
🔎
Find and Replace
🛡️
HTML Escape
📰
HTML Minifier
↩️
HTML to Markdown
🔓
HTML Unescape
📄
HTML Unminifier
📋
Markdown Preview
🔄
Markdown to HTML
🎲
Random Number
🔤
Random String
🔍
Regex Tester
🧹
Remove All Whitespace
↩️
Reverse Text
✂️
Split String
⚖️
Text Compare
🔁
Text Repeater
📖
Text Viewer
🌍
Time Zone Converter
🕐
Unix Time to Date
🔗
URL Encoder
🔤
UTF-8 Decoder
🌐
UTF-8 Encoder
📊
Word Counter

Browse by category

Base64 encoding (conceptual)

Input bytes are grouped in threes (24 bits), split into four 6-bit indices, and mapped to A–Z, a–z, 0–9, +, and /. Padding = appears when the input length is not a multiple of three.

bytes = new TextEncoder().encode(text); encoded = btoa(String.fromCharCode(...bytes))

Encoding example

The UTF-8 string Hello encodes to SGVsbG8=. The greeting Hello, 世界 👋 produces a longer Base64 string because emoji and CJK characters use multiple UTF-8 bytes each.

A five-character ASCII word might become roughly seven characters of Base64 plus padding — plan for the ~33% size overhead when embedding in JSON or HTML.

Complete guide to Base64 encoding text online

What Base64 encoding does

Base64 represents binary data as ASCII text using sixty-four safe characters plus optional padding. It is not encryption — anyone can reverse it — so treat Base64 as transport encoding for text channels that dislike raw bytes.

When you base64 encode text online, UTF-8 bytes become a compact alphabet of A–Z, a–z, 0–9, +, and /. That output fits JSON string fields, email bodies, and query parameters that would break on unescaped binary.

This base64 converter uses TextEncoder before btoa(), matching what Node.js Buffer.from(str, 'utf8').toString('base64') and Python base64.b64encode produce for the same input.

Encoded output grows roughly 33% compared to the original bytes. Small snippets encode instantly; very large pasted files may feel sluggish — use dedicated image or PDF tools for big binaries.

How to convert text to Base64 online

Type or paste text into the input panel. The Base64 output updates live as you edit. The string Hello encodes to SGVsbG8=; emoji and accented letters produce longer strings because they use more UTF-8 bytes.

Enable URL-safe mode when your consumer expects Base64URL — JWT segments and query strings often swap +/ for -_ and strip padding. Standard APIs and most email attachments use the default alphabet.

Copy the result with one click or download as a .txt file. For round-trip verification, paste the output into our Base64 Decoder and confirm the original text returns unchanged.

Import small .txt, .json, or .env files when you need to encode a file snippet without retyping. Clear the fields when finished on shared machines.

Base64 encode in JavaScript and other languages

Browser base64 encode javascript patterns often call btoa() directly, which fails on Unicode outside Latin-1. The correct pattern encodes UTF-8 bytes first — the same approach this tool uses internally.

In Node.js: Buffer.from(text, 'utf8').toString('base64'). In Python: base64.b64encode(text.encode('utf-8')).decode('ascii'). Compare your app's output against this encoder when debugging charset mismatches.

Base64 encode js snippets in Stack Overflow answers sometimes omit UTF-8 handling. If your manual encode differs from this page for non-ASCII text, the bug is usually missing TextEncoder or encodeURIComponent wrapping.

Do not confuse Base64 with hex or URL percent-encoding. UTF-8 Encoder shows raw byte values; URL Encoder handles %XX sequences for addresses.

When to use a Base64 converter

API payloads: embed short text blobs in JSON when binary transport is awkward. Encode here, paste into your request body, and confirm the server decodes with the same UTF-8 assumption.

Config and env files: some deployment systems expect Base64-wrapped secrets or certificates. Encode the plaintext snippet, then paste into your config manager — never treat Base64 as hiding secrets from attackers.

Data URIs and inline assets: prefix encoded image bytes with data:image/png;base64, for HTML or CSS. For full image or PDF files, use our Image to Base64 tool instead of pasting megabytes into a textarea.

Test fixtures: store expected Base64 strings in unit tests so CI asserts exact wire format, not just rendered glyphs.

URL-safe Base64 and common pitfalls

URL-safe Base64 replaces + with - and / with _ and may omit trailing = padding. Enable the checkbox when encoding for JWT-style consumers or query strings that reject standard characters.

Double-encoding happens when teams encode twice by habit. If the output still looks like Base64 after one pass, decode once on the Base64 Decoder page before re-encoding.

Do not Base64 passwords or API keys to hide them from users. Base64 is reversible encoding, not protection. Use proper secret management and environment variables.

Line breaks in email-style Base64 are cosmetic whitespace — this tool strips them on decode. When encoding for RFC 2045 consumers, you may need manual line wrapping for very long strings.

Privacy and related tools

TextEncoder and btoa run locally in your browser. Tokens, customer data, and internal error messages never upload to a server. Clear the textarea when finished on shared computers.

Pair with our Base64 Decoder for reverse conversion. Use Image to Base64 when you need file bytes and data URIs for <img> tags. Use Base64 to Image when you receive image payloads from APIs.

JWT middle segments are Base64URL JSON — encode or decode text here for inspection, but verify signatures in trusted libraries, not by eye alone.

Detailed guide

Encoding for a JSON API field

Paste your plaintext, copy the Base64 output, and insert it into the JSON string field your API documents. Confirm the server decodes with UTF-8, not Latin-1.

If the API expects URL-safe Base64, enable the checkbox before copying — mismatched alphabets are a common integration failure.

Matching base64 encode javascript output

Compare this tool's output against Buffer or btoa-with-UTF-8 patterns in your codebase. Mismatches on emoji usually mean the app skipped TextEncoder.

Store the encoder output in a test assertion so regressions surface in CI before production deploys.

Common questions

Base64 Encoder FAQ

How do I base64 encode online?

Paste your text into the input panel. The Base64 output updates automatically. Copy or download the result — no button click required.

Is this a base64 converter for text only?

Yes. This page encodes plain UTF-8 text. For images or PDF files, use our Image to Base64 tool which reads file bytes directly.

Does base64 encode support Unicode and emoji?

Yes. Text is encoded as UTF-8 bytes before Base64, so emoji, accents, and CJK characters round-trip correctly when decoded with the same UTF-8 assumption.

What is the difference between standard and URL-safe Base64?

URL-safe Base64 uses - and _ instead of + and / and often omits padding. Enable the checkbox when encoding for JWTs or query strings.

Is Base64 encryption?

No. It is reversible encoding. Anyone with the string can decode it.

How do I decode the output?

Open our Base64 Decoder, paste the Base64 string, and read the recovered text.

Does the Base64 Encoder send my input to a server?

Yes. Everything runs in your browser. Your input is not uploaded, logged, or stored on our servers.

Do I need an account?

No account or sign-up is required. Open the page and start using the tool immediately.