data:image/png;base64,iVBORw0KGgo...HTML、CSS、Markdown など、画像 URL が必要な場所に直接使います。Base64 画像が役立つ場面。
画像をテキストとして扱いたいとき、Base64 はデモ、API ペイロード、メール断片、ドキュメント、小さな UI アセットに向いています。
正しい形式を選ぶ
Data URI は MIME タイプ付きで HTML/CSS に直接使えます。Raw Base64 は API フィールドや設定値に向いています。
iVBORw0KGgoAAAANSUhEUg...JSON、API パラメータ、設定値、MIME タイプを別管理する保存先に使います。よく使う実装パターン
目的に合う形をコピーし、変換器で生成した値に置き換えてください。
Embed an image in HTML
Good for tiny icons, portable demos, or documentation where the image should be self-contained.
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Inline preview" width="120" height="120" />Use a Base64 image in CSS
Useful for small decorative assets, skeleton placeholders, and one-file prototypes.
.avatar-placeholder {
width: 48px;
height: 48px;
background-image: url("data:image/png;base64,iVBORw0KGgo...");
background-size: cover;
}Send images through JSON APIs
Use raw Base64 when the receiving service expects a text field instead of multipart upload.
{
"fileName": "logo.png",
"mimeType": "image/png",
"base64": "iVBORw0KGgoAAAANSUhEUg..."
}Inline image for email templates
Inline Data URIs can help with small fallback images, but always test client compatibility.
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Brand mark" style="display:block;width:96px;height:auto;" />Keep docs and examples self-contained
Base64 keeps screenshots, placeholders, and tiny diagrams inside one Markdown or HTML file.
Debug payloads across languages
Raw Base64 is plain text, so it can be pasted into test fixtures, cURL commands, or logs.
curl -X POST https://api.example.com/upload \
-H "Content-Type: application/json" \
-d '{"mimeType":"image/png","base64":"iVBORw0KGgo..."}'Base64 を使わない方がよい場合
Base64 はサイズが増え、通常の画像キャッシュも使いにくくなります。すべての画像の標準には向きません。
実用的な判断基準
- 01Data URI
HTML、CSS、Markdown、メール、ブラウザ URL 欄に入れる場合。
- 02Raw Base64
MIME タイプ、ファイル名、エンコード内容を別フィールドで扱う場合。
- 03通常の URL
大きい画像、頻繁に再利用する画像、CDN やブラウザキャッシュが必要な場合。