โšกSwiftKit
โ† All Toolsโ˜• Support
โ‡„Developer & Data

Base64 & URL Encoder / Decoder

Convert strings between raw text, Base64, and URL-encoded formats client-side. Safe for sensitive tokens.

0 chars
0 chars
๐Ÿ”’ Client-Side Processing: All transformations use browser window.btoa / atob / encodeURIComponent.No data sent over wire

Base64 examples: how text becomes Base64

Base64 uses 64 safe characters (A to Z, a to z, 0 to 9, + and /) to write out any data. Every 3 bytes of input become 4 characters of output, and = signs pad the end. Here are real results from the encoder.

Man
Base64: TWFu

Why: 3 bytes become exactly 4 characters, so no padding

Ma
Base64: TWE=

Why: 2 bytes leave a gap, filled with one =

M
Base64: TQ==

Why: 1 byte leaves a bigger gap, filled with two =

Hello, World!
Base64: SGVsbG8sIFdvcmxkIQ==

Why: 13 characters become 20

cafรฉ
Base64: Y2Fmw6k=

Why: รฉ takes two bytes in UTF-8, so 5 bytes become 8 characters

๐Ÿ˜€
Base64: 8J+YgA==

Why: One emoji is four bytes

URL-safe variant. Standard Base64 uses + and /, which have special meanings in web addresses. The URL-safe form swaps them for - and _ and drops the padding. For the text >>>??? the standard output is Pj4+Pz8/ and the URL-safe output is Pj4-Pz8_. Tick the URL-safe box when encoding, and decoding recognises either form.

Decoding examples, including messy input

Pasted Base64 is often not perfectly clean. The decoder copes with the common problems and tells you what it changed.

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
Result: {"alg":"HS256","typ":"JWT"}

What happened: The header of a JSON Web Token (the part before the first dot)

SGVsbG8
Result: Hello

What happened: The missing = padding is added, and the tool says so

data:text/plain;base64,SGVsbG8=
Result: Hello

What happened: The data: prefix is removed, and the tool says so

Pj4-Pz8_
Result: >>>???

What happened: URL-safe Base64 (- and _) is recognised automatically

/9j/4AAQ
Result: ff d8 ff e0 00 10

What happened: These bytes are not text (they begin a JPEG image), so they are shown as hex

not base64!!
Result: Error: '!' is not a Base64 character (character 10)

What happened: Errors name the character and its position

Decoding a JSON Web Token shows you what it carries, but it does not check that the token is genuine, because that needs the secret key. A token's contents are only encoded, not hidden, so treat tokens as private and do not paste a live one into any site you do not trust. Here, nothing leaves your browser.

URL (percent) encoding: what changes and why

Web addresses can only contain a limited set of characters. Anything else is written as a percent sign followed by the character's byte value in hex. The URL tab leaves letters, digits and - _ . ! ~ * ' ( ) alone and escapes the rest:

Space
Becomes: %20

Why it matters: Not + (see the notes below)

&
Becomes: %26

Why it matters: Otherwise it would start a new parameter

=
Becomes: %3D

Why it matters: Otherwise it would split a name from a value

?
Becomes: %3F

Why it matters: Otherwise it would start the query string

/
Becomes: %2F

Why it matters: Otherwise it would add a path segment

@
Becomes: %40

Why it matters: As in an email address

+
Becomes: %2B

Why it matters: Otherwise a form decoder may read it as a space

%
Becomes: %25

Why it matters: The escape character itself

รฉ
Becomes: %C3%A9

Why it matters: Letters outside A to Z use their UTF-8 bytes

โ‚ฌ
Becomes: %E2%82%AC

Why it matters: Three bytes

๐Ÿ˜€
Becomes: %F0%9F%98%80

Why it matters: Four bytes

Related: format and check a JSON payload with the JSON formatter, generate random identifiers with the UUID generator, or read a number in another base with the number base converter.

Knowledge Base

Frequently Asked Questions

What is Base64 encoding used for?โ–ผ

Base64 turns bytes into plain text characters so they can travel safely through systems that only handle text, such as JSON, email, data URLs and HTTP headers. It is an encoding, not encryption: anyone can decode it.

What is URL-safe Base64?โ–ผ

It swaps + and / for - and _ and usually drops the = padding, so the result is safe in web addresses and filenames. JSON Web Tokens use this form. Tick the URL-safe option when encoding; decoding accepts both forms automatically.

Why does my decoded Base64 show hex numbers instead of text?โ–ผ

If the decoded bytes are not valid UTF-8 text, such as an image or a compressed file, they are shown as hex instead of as unreadable symbols.

Does it cope with a data: prefix, line breaks or missing padding?โ–ผ

Yes. A leading data:...;base64, prefix, spaces and line breaks are ignored and missing = padding is added. A note tells you what was adjusted.

What is the difference between URL encoding and Base64?โ–ผ

URL (percent) encoding escapes only the characters that are unsafe in a web address, for example a space becomes %20. Base64 re-writes the whole input in a different alphabet and makes it about a third larger.

Does it support emoji and non-English text?โ–ผ

Yes. Text is converted as UTF-8, so accents, emoji and other scripts round-trip correctly.

Why does Base64 end with one or two = signs?โ–ผ

Base64 turns every 3 bytes into 4 characters. If the input is not a multiple of 3 bytes, the end is padded with = so the length is a multiple of 4. One byte left over gives two = signs, and two bytes left over gives one. URL-safe Base64 often leaves the padding off, and this tool adds it back when decoding.

How much bigger does Base64 make my data?โ–ผ

About a third bigger, because 3 bytes become 4 characters. For example 300 characters of plain English text become 400 Base64 characters. That is the price of making binary data safe to put in text-only places.

Should I encode a whole web address or just part of it?โ–ผ

Usually just the part that varies, such as a search term or a value in the query string. This tool uses encodeURIComponent, which also encodes the characters that structure a URL, so the whole address https://example.com/a b becomes https%3A%2F%2Fexample.com%2Fa%20b. That is correct when the address is itself a value inside another URL, and wrong when you want a working link.

Why does a + stay a + when I decode a URL?โ–ผ

Percent-decoding changes only %XX codes. In the older form-submission format a + stands for a space, but in a normal URL a + is just a plus sign, so the tool keeps it. If you are decoding form data and need the spaces, replace each + with a space first.

Is Base64 safe for passwords or secrets?โ–ผ

No. It is a format, not protection. Anyone can decode it in a second, as this page shows. Web servers sometimes use it for a login header, for example user:pass becomes dXNlcjpwYXNz, which is why that header must only ever be sent over HTTPS.