画像 ↔ Base64
画像を data URL に変換、または Base64 から画像を復元。
画像 ↔ Base64とは
画像 ↔ Base64 は、画像ファイルを Base64 の data URL(data:image/...;base64,...)に変換する、または貼り付けた Base64 を画像に復元してプレビュー・ダウンロードできるツールです。HTML や CSS に画像をインライン埋め込みするときに使えます。処理はブラウザ内で完結し、ファイルは送信されません(4MB まで)。
🔒 処理はすべてブラウザ内で完結し、データは送信されません。
このツールの前提
- 処理場所
- このページのブラウザ内(JavaScript / Canvas)
- アップロード
- なし — ファイルは端末の外に出ません
- オフライン
- ページを開いた後は通信不要
Turning an image into a data URI
The file is read with FileReader as a data URL, giving data:image/png;base64,… That string can be placed directly into an img src or a CSS background with no network request, which is the entire appeal: one fewer round trip and no broken-image flash on load.
The cost is size. Base64 inflates by about a third, and the image cannot be cached separately, cannot be loaded in parallel, and blocks the render of whatever contains it. Under roughly 2 KB inlining usually wins; above that the extra bytes and the lost caching almost always lose, and well above that it visibly hurts first paint.
Where the string breaks
Data URIs in CSS need quoting discipline: a base64 body contains no quotes, but the surrounding url() still needs the right syntax, and a stray line break inserted by a formatter breaks the value. In HTML attributes, very long values are legal but unreadable, and some templating engines truncate them.
Email clients are the other trap. Many strip data URIs entirely, so an inlined icon that works on the web disappears in the newsletter. For HTML email, host the image and reference it by URL.
When to use a file instead
Keep the image as a file if it appears on more than one page, if it is larger than a few kilobytes, or if it needs cache headers, responsive variants or a CDN. The data URI approach is for one-off, tiny, render-critical assets — a favicon fallback, a spinner, a single decorative mark.
Also check the MIME type in the prefix against the actual bytes. A PNG that announces itself as image/jpeg will still render in most browsers (they sniff), but image processing pipelines downstream will fail on it, and the failure is far from the line that caused it.
使い方
- 1.方向を選ぶ(Encode / Decode)
- 2.Encode:画像を選ぶ / Decode:Base64 を貼り付け
- 3.実行して結果をコピーまたはダウンロード
他の方法との比較
同じ変換をする方法は 3 つあります。ブラウザ内(このページ)、サーバー側の変換サービス、デスクトップアプリ。差がつくのは速度ではなく、ファイルがどこへ行くかと、無料でどこまでできるかです。
| 観点 | このツール | サーバー側の変換サービス | デスクトップアプリ |
|---|---|---|---|
| ファイルの処理場所 | このページのブラウザ内 | ベンダーのサーバー(アップロード後) | 自分の PC(アプリをインストール) |
| アカウント | 不要 | 多くの場合必要(無料枠の制限解除に登録を求める) | 不要(ライセンス認証は必要な場合あり) |
| 無料で扱えるサイズ | サイズ制限なし(回数制限もなし) | 数ファイル/時間、または 5〜10MB 程度で課金 wall | ディスクとメモリ次第 |
| 料金 | 無料。Pro は月 $9(大きいファイルと AI 機能のみ) | サブスクが一般的。おおむね月 $7〜15(2026 年 11 月時点) | 買い切り、またはサブスク |
| オフライン | 一度開けば通信不要 | 不可 | 可 |
| 20MB を処理し始めるまで | 待ち時間なし(アップロードが無い) | アップロードが支配的(10Mbps 上りで約 16 秒) | アプリの起動のみ |
| 保証できないこと | 出力は決定的です。他の実装と突き合わせて検証できます | 同じ(変換の原理は変わらない) | 同じ。ただし書式の再現はより忠実な場合がある |
サーバー側のサービスが優れている点は明確にあります。巨大なファイル、チームでの共有、変換履歴の管理、スクリプトからの自動化。逆に「1 回だけ、手元のファイルを別形式にしたい」という今回の用途では、アップロードの待ち時間と登録の手間だけが増えます。
よくある質問
data URL はどこに使える?
HTML の <img src> や CSS の url() にそのまま貼れます。小さいアイコンをインライン化すると HTTP リクエストを減らせます。大きい画像はファイルサイズが約 33% 増えるため非推奨です。
対応形式は?
PNG / JPEG / GIF / WebP / SVG / BMP / ICO を判別できます。decode 時は Base64 の先頭バイトから形式を自動判定します。
この変換で失われるもの
エンコードとハッシュは Web Crypto API または純 JavaScript 実装で行います。出力は決定的で、同じ入力からは常に同じ結果になります。他のツールと突き合わせて検証できます。