メインコンテンツへスキップ
Z

Base64 vs URL encoding

Base64 vs URL encoding (percent-encoding) compared — what each does, output and use cases, with free encoders.

Base64 turns binary data into ASCII text (e.g. embedding an image in JSON); URL encoding (percent-encoding) escapes characters that are unsafe in a URL. They solve different problems and are often used together.

Base64 vs URL encoding at a glance

Base64 URL encoding
Purpose Binary → text Make text URL-safe
Output A-Z a-z 0-9 + / = %XX escapes
Size ~33% larger Slightly larger
Use Data URIs, tokens, email Query strings, form data

When to use Base64

Use Base64 to carry binary (images, files, keys) through text-only channels.

When to use URL encoding

Use URL encoding to safely put arbitrary text into a URL or query string.

Tools for Base64 & URL encoding

Base64 vs URL encoding

どのエンコードモードを選べばいいですか?

HTMLにテキストを埋め込む際に本当に必要なのは「最小限」モードで、< > & " ' のみをエスケープします。「非ASCII」は上位バイトを除去する環境向けです。「既知の名前付きすべて」は主にタイポグラフィのデモ用途です。

文字によって &#x になったり名前付きになったりするのはなぜですか?

named形式を選んだ場合、対応する名前が存在すればそれを出力し、存在しなければ選択した形式(10進数または16進数)にフォールバックします。

XMLの場合はどうすればいいですか?

XML用にエスケープするには、当サイトのEscape / Unescapeツールをご利用ください。XMLでは < > & " ' のみが組み込みエンティティとして定義されています。

関連するツールはありますか?

言語ごとの文字列エスケープにはEscape / Unescapeを、パーセントエンコーディングにはURL Encoderをご利用ください。