JSON Fmt

Base64 and URL encoder

Encode or decode Base64 (UTF-8 safe) and URL-encode or decode text, in the browser, with a note on what each encoding is for.

Type or paste text, choose the operation and press Run.

What Base64 is

Base64 writes any sequence of bytes using 64 printable characters (A to Z, a to z, 0 to 9, plus and slash), three bytes becoming four characters, with equals signs padding the end to a multiple of four. It exists so that binary data (an image, a key, a compressed blob) can travel through places that only accept text: email bodies, JSON strings, HTTP headers, data URLs. It makes data about a third larger and hides nothing; the Authorization header of HTTP Basic authentication is Base64 of user:password, readable by anyone who sees it.

Worked example

Rasoi is five bytes: 0x52 0x61 0x73 0x6F 0x69. Base64 turns them into UmFzb2k=: eight characters for five bytes, the trailing = marking that the last group held only two bytes. Decoding UmFzb2k= gives Rasoi back. Text with non-ASCII characters (Hindi, Urdu, emoji) is first written as UTF-8 bytes, then encoded; this page does that step for you, which the browser's bare btoa function does not.

Standard and URL-safe Base64

The characters + and / have meanings inside URLs, and = often does too, so a second alphabet replaces them with - and _ and drops the padding. JSON Web Tokens, many API keys and most things that end up in a query string use this URL-safe form. The decoder here accepts either alphabet and missing padding; the encoder writes the one you choose.

URL encoding

URL encoding (percent-encoding) replaces characters that are not allowed in a URL, or that would be read as URL syntax, with a percent sign and two hex digits: a space becomes %20, an ampersand %26, a Devanagari letter becomes three or four percent-escaped UTF-8 bytes. The encoder here is the component form (encodeURIComponent), which also escapes / ? & = #, so it is the right one for a single query value. Do not run it over a whole URL, or the slashes and the question mark will be escaped too.

Form submissions encode a space as + rather than %20; if you are decoding a query string from a form, replace + with a space first, or the decoder will hand you plus signs.

Decoding errors

A Base64 string that fails to decode usually has a stray character (a newline or a space in the middle is fine; a quote or a comma is not), or was cut short. The decoder reports the problem rather than guessing. Decoded bytes that are not valid UTF-8 (a binary file, say) are shown as a byte count, since printing them as text would be garbage.

Updated 2026-09-16. Base64 is an encoding, not encryption; anyone can decode it. Nothing you paste leaves this page.