Base64 encoder and decoder — UTF-8 text, files, and URL-safe output

Use this free Base64 encoder online to turn UTF-8 strings and files into standard or URL-safe Base64 (Base64URL), and decode Base64 back to text with support for whitespace, missing padding, and data URIs (data:...;base64,...). Developers use Base64 for JSON fields, Basic auth construction, email MIME, embedding small assets, and comparing blobs with diffs. Everything runs in your browser. Pair it with the URL encoder and decoder for query strings, the JWT decoder for three-part tokens. Use Encode file in the tool above for images and other binaries when you need a raw Base64 string (for example to build a data: URI manually).

Encode plain text or decode Base64; paste full data URIs when decoding embedded assets.

Decoding accepts standard and URL-safe alphabets, ignores whitespace, and strips data:...;base64, prefixes. This is not encryption—treat decoded content as sensitive only if the original was secret.

What is Base64 and why teams still rely on it

Base64 is a binary-to-text encoding defined in RFC 4648. It maps every three bytes of input to four ASCII characters from a 64-character alphabet, typically A–Z a–z 0–9 + / with = padding at the end when the byte length is not a multiple of three. The result is safe to embed in JSON strings, XML, headers, and URLs (with escaping or a URL-safe alphabet). It does not encrypt data—anyone can reverse it—so treat it as a transport representation, not a secret vault.

Product and platform engineers encounter Base64 when APIs return thumbnails, PDFs, or signatures as string fields; when DevOps stores kubeconfigs or certificates in environment variables; and when front-end developers inline tiny SVG or PNG assets as data URIs for prototypes. For structured API bodies that mix Base64 with JSON, validate and pretty-print with our JSON formatter & validator after you paste samples from logs.

How to use this Base64 tool (step by step)

  1. Encode: Paste UTF-8 text (including emoji and non-Latin scripts) into the box, optionally check URL-safe Base64 if your consumer expects - _ instead of + /, then click Encode UTF-8 → Base64. Enable line wrapping when you want readable 76-character rows for docs or PEM-style display.
  2. Decode: Paste Base64 (with or without line breaks). The tool strips data:...;base64, prefixes, ignores whitespace, accepts URL-safe alphabets, and restores padding when possible. Click Decode Base64 → UTF-8. If the payload is not valid UTF-8 text, you may see replacement characters—use a hex or file workflow for raw binary inspection.
  3. Encode a file: Use Encode file to read a local file and output its Base64 without uploading it. Combine with URL-safe mode when you build tokens or filenames.
  4. Copy sends the current editor contents to the clipboard for curl, Postman, Terraform variables, or tickets. Use Load sample text to try encoding quickly.

UTF-8 vs raw btoa — keywords that explain the difference

Searchers often look for Base64 encode Unicode or btoa UTF-8 because the browser's btoa only accepts code units in the Latin-1 range. Real-world APIs almost always mean "encode the UTF-8 bytes of this string." This page follows that convention so internationalized text and symbols encode the same way server-side libraries do in Node, Go, and Python.

Standard Base64 vs Base64URL in JWTs and APIs

JSON Web Tokens use Base64URL for the header and payload segments: no padding =, and +/ replaced by -_. Toggle URL-safe mode here when you want matching output for tests or documentation. To inspect decoded JSON inside a token without verifying signatures, open the JWT decoder. For checksums and fingerprints of decoded bytes, use the hash generator.

Data URIs, HTML, and performance-minded embedding

A data URI combines a MIME type with inline Base64, for example data:image/svg+xml;base64,.... They are convenient for prototypes and email templates but can bloat HTML and hurt caching for large assets on public sites—prefer URLs and CDNs for production media. When you work on page markup alongside assets, the HTML formatter helps keep templates readable.

Security, privacy, and compliance notes

Because encoding is reversible, never treat Base64 as protection for personal data in logs or URLs. Prefer redaction and access controls. This tool keeps processing client-side, which helps when you handle credentials or pre-production payloads you do not want on a shared service. For public URL safety and crawler behavior, review headers and redirects with our HTTP header checker and redirect chain checker when debugging links that carry encoded parameters.

Related developer tools

Explore the full code and developer tools catalog. Highlights:

  • JSON Formatter & ValidatorFormat, validate, minify, and explore JSON in a collapsible tree—fix payloads before they hit production.
  • JSON to CSV ConverterTurn JSON arrays into downloadable CSV with automatic column detection for spreadsheets and BI tools.
  • JSON to YAML ConverterConvert JSON to readable YAML for configs and Kubernetes—copy or download the result.
  • CSV to JSON ConverterPaste or upload CSV and get structured JSON with header-aware typing for APIs and apps.
  • YAML to JSON ConverterParse YAML to valid JSON with clear errors—ideal for CI configs and cloud templates.
  • XML Formatter & ValidatorBeautify and validate XML with structure insight and actionable parse errors.
  • Regex Tester & DebuggerTest patterns live with highlights, capture groups, and flags—debug regex without leaving the browser.
  • SQL FormatterPretty-print SQL with indentation and keyword casing for readable queries and code review.
  • HTML Formatter & MinifierBeautify or minify HTML and compare raw markup with a quick rendered preview.
  • CSS Formatter & MinifierFormat messy stylesheets or minify CSS for faster loads—keep design tokens consistent.
  • JavaScript Formatter & MinifierPretty-print or minify JavaScript for debugging locally and shipping smaller bundles.
  • HTML to Markdown ConverterConvert HTML snippets to Markdown for docs, CMS migrations, and README cleanup.
  • Markdown to HTML ConverterTurn Markdown into HTML with a live preview—handy for emails, blogs, and static pages.
  • Code Diff CheckerCompare two code blocks side by side with clear add/remove highlighting for reviews.

Frequently asked questions

What is Base64 and when do developers use it?
Base64 encodes binary data as ASCII text using 64 safe characters (A–Z, a–z, 0–9, +, /, with padding =). It is common in JSON APIs, email MIME parts, embedding small assets as data URIs, storing blobs in databases or env vars, and debugging authentication headers. It is encoding, not encryption—anyone can decode it.
Is my text or file uploaded to your servers?
No. Encoding and decoding run entirely in your browser with the Web Crypto–friendly APIs available in modern tabs (TextEncoder, FileReader, btoa/atob). Nothing is sent to our backend unless you navigate away or use another feature that explicitly calls an API.
Why does btoa fail on Unicode or emoji in some tools?
JavaScript’s btoa treats strings as Latin-1 code units. Characters outside that range throw. This tool encodes UTF-8 bytes to Base64 first, so international text, symbols, and emoji work the same way most APIs expect (UTF-8 payload, then Base64).
What is URL-safe Base64 and when should I use it?
URL-safe variants (often called Base64URL) replace + with - and / with _ and may omit padding = so strings fit cleanly in query parameters, JWT segments, and filenames without extra escaping. Use standard Base64 when an API spec explicitly requires RFC 4648 default alphabet and padding.
How do I decode a data:image/...;base64,... string?
Paste the full data URI into the decoder. The tool strips the prefix and decodes the payload. For images you will see binary-looking UTF-8 replacement characters in the text area—use the file or hex workflow in your editor if you need raw bytes; for text assets the result should read normally.
Can Base64 be used for security or secrets?
Base64 obscures content slightly but provides no confidentiality. Do not rely on it to protect passwords or tokens. For secrets use proper encryption, key management, and transport security (HTTPS). Pair conceptual learning with our hash generator for checksums and the JWT decoder for structured tokens—not for verifying signatures in production.
Why is the encoded output longer than the input?
Base64 expands binary data by roughly 4/3 because each group of three bytes becomes four ASCII characters. Padding may add one or two = characters at the end. That expansion is expected and why you gzip or compress before encoding when size matters.
Which related tools pair with Base64 on this site?
Use the URL encoder and decoder for percent-encoding query strings, the JWT decoder when payloads are three Base64URL segments, the JSON formatter for pretty-printing API bodies that contain Base64 fields, and Encode file on this page when you need Base64 from local images or other files without uploading them to a server.