画像をBase64に変換
新着任意の画像をBase64データURL文字列に変換
画像をBase64に変換 の使い方
- 1画像をアップロード
- 2生成されたBase64文字列をコピー
- 3HTML img src、CSS background-image、またはJSONペイロードに貼り付け
- 4Paste it directly into your HTML or CSS
画像をBase64に変換 について
Image to Base64 converts your image file into a Base64 text string that can be embedded directly into HTML img tags, CSS backgrounds, or JSON payloads — no separate image file needed. The tool shows the full data URL, the pure Base64 portion, and an example HTML snippet.
Base64 encoding is the standard technique for embedding binary image data inside text-based formats. It is used everywhere: HTML email templates that cannot reference external files, CSS files that inline background icons, JSON API responses that carry image thumbnails, and SVG files that embed raster images. This tool automates the conversion instantly in your browser.
Three output views are provided: the full data URL (ready to paste into an src attribute), the raw Base64 string (for APIs that expect just the encoded data), and a complete HTML img tag example. One-click copy buttons make it easy to grab each piece without manual selection.
画像をBase64に変換の主な機能
- PNG、JPG、WEBP、GIF、SVGをBase64に変換
- 即使用可能なデータURIを出力
- 完全エンコード出力のワンクリックコピー
- エンコード文字列の長さと推定サイズを表示
- ドラッグアンドドロップ画像アップロードをサポート
- サーバーアップロードなしの即時エンコード
- FileReader APIを使用した100%クライアントサイド
- 任意の画像サイズで動作
対応フォーマット
入力フォーマット
出力フォーマット
The output data URL includes the correct MIME type prefix (data:image/png;base64, etc.) automatically.
使用例
HTMLメールにアイコンをインライン埋め込み
外部画像がブロックされていても表示されるよう、アイコンをメールHTMLに直接埋め込みます。
入力
Small 32x32 PNG icon
出力
data:image/png;base64,iVBOR... (full data URL)
CSSバックグラウンド画像
小さな装飾アセットのHTTPリクエストを避けるため、CSS background-imageプロパティにデータURLを使用します。
入力
Small decorative PNG texture
出力
background-image: url("data:image/png;base64,...")Image in JSON API response
Copy the raw Base64 string to use as the value of an "avatar" field in a JSON payload without the data URL prefix.
入力
User avatar PNG
出力
Raw Base64 string for JSON field value
主な使用ケース
- 追加のHTTPリクエストを避けるために小さなアイコンをHTMLに直接埋め込む
- CSSで背景グラフィック用にインライン画像を含める
- JSONのAPIペイロードや設定ファイルに画像データを保存する
- 埋め込み画像付きの自己完結型HTMLメールテンプレートを作成する
- PDF生成スクリプトへの埋め込み用に署名画像をエンコードする
- 小さなスプライトをJavaScriptソースファイルに直接バンドルする
トラブルシューティング
出力文字列が非常に長くエディタが遅くなる
解決策
Base64エンコードでサイズが約33%増加します。100KB以上の画像には、インラインデータURIではなく通常のファイルとして提供することを検討してください。
データURIがブラウザで表示されない
解決策
データURIに正しいMIMEタイププレフィックス(例:"data:image/png;base64,")が含まれていることを確認してください。ツールが自動生成しますが、コピー時の誤った切り取りを確認してください。
SVGエンコードが壊れた出力を生成する
解決策
SVGファイルの場合、URLエンコードの方がBase64より信頼性が高い場合があります。生のSVGソースを使用するか、SVG文字列をURLエンコードしてください。
よくある質問
画像にBase64を使う理由は?
Base64を使うと、別ファイルリクエストなしでコードに画像を直接埋め込めます。
Base64はファイルサイズを増やしますか?
はい、約33%増加します。埋め込みが必要な場合のみ使用してください。
What is the difference between the data URL and the raw Base64 string?
The data URL includes the MIME type prefix (e.g., data:image/png;base64,) followed by the Base64 data. The raw Base64 string is just the encoded data without that prefix. Use the full data URL in HTML src attributes and CSS url() values; use the raw string when an API expects Base64-only input.
Is there a file size limit?
There is no server-side limit since all encoding happens in your browser. Images up to 10 MB encode reliably on modern devices. Very large images may slow down or crash the browser tab.
Which image formats are supported?
Any format your browser can load: PNG, JPG, WEBP, GIF, SVG, BMP, and ICO are all supported. The MIME type is detected automatically from the file.
Can I use the Base64 output in CSS?
Yes. Use the full data URL as the value of a CSS background-image property: background-image: url("data:image/png;base64,..."). Useful for small decorative images and icons.
JSON APIでBase64出力を使用できますか?
はい。データURLプレフィックスなしの純粋なBase64文字列をコピーして、JSONペイロードの画像フィールドの値として使用します。
Base64出力の透明性はどうなりますか?
ソースがPNGの場合、データURLで透明性が保持されます。プレフィックス内のMIMEタイプ(data:image/png;base64,)がブラウザの正確なレンダリングを保証します。