FIRST CH TOOLS / Dev / 17 BASE64 & DATA URI
Base64 & Data URI Encoder / Decoder
Text ⇄ Base64, and images to a data URI with <img> and CSS snippets — in your browser. For SVG it compares the Base64 and percent-encoded sizes and gives you the shorter one.
Supported formats and details
Text is encoded as UTF-8 bytes before Base64, and decoding runs live in the other direction. Dropping an image, font or other file gives you its data:image/… data URI plus ready-to-paste HTML <img> and CSS background-image snippets. URL-safe Base64, 76-column wrapping and turning a data URI back into a file are all supported. Nothing is uploaded.
Text ⇄ Base64 — type in either box
Text is encoded as UTF-8 bytes first, so non-ASCII characters (most CJK ones are three bytes) become four Base64 characters each. URL-safe Base64 swaps + and / for - and _ and drops the = padding — the form used by JWTs and query strings. The decoder accepts either alphabet, tolerates embedded whitespace and newlines, and does not require the padding to be present.
Image / file → data URI + HTML / CSS snippets
The file is only read locally — nothing is uploaded. Inlining works best for icons and small SVGs up to a few KB.
Data URI / Base64 → back to a file or text
Share the SVG size comparison as an image
The card shows the Base64 and percent-encoded data URI lengths and the difference. By default it uses the public sample (a map pin). Load your own SVG and the numbers become yours; the picture and file name stay off the card unless you tick the box below.
How to Use
- Convert textType into the left box and the Base64 appears on the right; paste Base64 or a data URI on the right and the original text comes back on the left. URL-safe and 76-column forms are one checkbox away.
- Turn an image into a data URIOn the second tab, drop an image (or press “Try a sample SVG”) to get its
data:image/…URI plus ready-to-paste<img>and CSSbackground-imagesnippets. - Copy and pasteUse the copy button on each box. To turn a data URI or Base64 blob back into a file, paste it on the third tab and download it. Everything runs inside your browser.
About This Tool
Base64 represents arbitrary bytes using only 64 characters (A–Z a–z 0–9 + /). Because every three bytes become four characters, the data always grows by about 33%. It exists so binary can travel through text-only channels: data: URIs that inline images and fonts into HTML and CSS, MIME email attachments, and binary payloads inside JSON or JWTs. It is an encoding, not encryption — it hides nothing.
Inlining as a data URI saves a request but costs you caching and rendering. An inlined image is part of the HTML or CSS, so it cannot be cached on its own, and inside CSS it lengthens the render-blocking download. It pays off for icons and rules of a few KB, or where file references are not available at all, such as HTML email. This tool flags anything over 10 KB.
For SVG, percent-encoding beats Base64: Base64 always inflates by ~33%, while most of an SVG's bytes are characters that can be written literally. This tool shows both lengths whenever you load an SVG and picks the shorter one by default. The output always escapes & " < > # %, whitespace and non-ASCII, so it can be pasted into an HTML attribute or a CSS url("…") unchanged.
The decoder accepts standard and URL-safe Base64, tolerates embedded whitespace and newlines, and does not need the trailing = padding. It trusts the actual bytes (magic numbers) over the MIME type a data URI claims, so a copy-paste with a wrong declaration still previews correctly.
Worked example (sample SVG): the 48 × 48 map pin loaded by “Try a sample SVG” (508 bytes, with an XML declaration, a comment and line breaks, the way design tools export) is 706 characters as a Base64 data URI and 507 characters percent-encoded — 28% shorter. The percent-encoded length is after this tool strips the XML declaration, comments and line breaks on output; the Base64 length encodes the file as-is. Both are what the tool actually outputs. The sample card is drawn from this SVG.
You can open a conversion through the URL: /en/base64/?text=Hello, /en/base64/?b64=SGVsbG8=, or start with the sample SVG loaded: /en/base64/?sample=1. Values in the URL reach the server as part of the page request, so paste secrets into the boxes instead.
Sources (checked 2026-11-05)
- Three bytes (24 bits) become four characters, the URL-safe - _ alphabet (§5), and when padding may be skipped (§3.2, §5): RFC 4648 “The Base16, Base32, and Base64 Data Encodings” rfc-editor.org/rfc/rfc4648.html
- The data:[mediatype][;base64],data form, %xx encoding when ;base64 is absent, and “only useful for short values”: RFC 2397 “The "data" URL scheme” rfc-editor.org/rfc/rfc2397.html
- 76-column lines (MIME): RFC 2045 §6.8 “The encoded output stream must be represented in lines of no more than 76 characters each.” rfc-editor.org/rfc/rfc2045.html
From AI Agents
This encoding and decoding logic is also available as the base64_encode tool on the MCP (Model Context Protocol) server @first-ch/tools-mcp, so AI agents can call it directly without driving a browser. See Using these tools from AI agents for setup details.
Install
claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
Example calls
# Encode text as Base64 base64_encode(text="hello") # Turn an image file into a data URI + HTML/CSS snippets base64_encode(path="/path/to/icon.svg", snippets=true) # Decode Base64 / a data URI back into a file base64_encode( mode="decode", base64="data:image/png;base64,iVBORw0K…", outputPath="/path/to/out.png")
Other Tools
See all tools
- 01Batch Image → WebPWebP Converter
- 02White Background RemoverWhite BG Remover
- 03WCAG Contrast CheckerContrast Checker
- 04Character CounterCharacter Counter
- 05llms.txt Generatorllms.txt Generator
- 06JSON-LD GeneratorJSON-LD Generator
- 07Markdown → PDFMD → PDF
- 08OGP Meta Tag WizardOGP Wizard
- 09Favicon GeneratorFavicon Generator
- 10TikTok PublisherTikTok Publisher
- 11Encoding & Line Ending ConverterEncoding Converter
- 12Batch Image → AVIF + pictureAVIF Converter
- 13Test Data GeneratorTest Data Generator
- 14Marp Markdown → SlidesMarp Slides
- 15Text & Code Diff CheckerDiff Checker
- 16Cron Explainer & Next RunsCron Explainer
- 18URL Parameter Editor & UTM BuilderURL Parameters
- 19HTML Entity Escape & UnescapeHTML Escape
- 20JSON ⇄ YAML ConverterJSON ⇄ YAML
- 21PX ⇄ REM / EM ConverterPX ⇄ REM / EM 単位変換
- 22Color Converter & Alphaカラーコード変換&アルファ透過
- 23MD5 / SHA-256 Hash Generatorハッシュ生成
- 24JWT Decoder & Expiry CheckerJWTデコーダー&有効期限チェッカー
- 25User-Agent ParserUser-Agent解析&デバイス判定
- 26UUID & ULID GeneratorUUID (v4) & ULID 一括生成
- 27Aspect Ratio Calculatorアスペクト比計算&サイズ算出
- 28Markdown Table & CSV/TSV ConverterMarkdownテーブル整形&CSV/TSV変換
- 29SQL Query FormatterSQLクエリ整形(フォーマッター)
- 30QR Code GeneratorQR Code Generator
- 31Regex Tester正規表現テスター
- 32Unix Timestamp ConverterUNIXタイムスタンプ⇄日時変換
- 33New Tab Memo新規タブメモ帳
- 34Image Resizer & Cropper画像リサイズ&クロップ
- 35EXIF Viewer & RemoverEXIF情報の確認&除去
- 36robots.txt Generatorrobots.txt ジェネレーター
- 37Password Generator安全なパスワード生成
- 38Case Converter文字列ケース変換
- 39CSV/TSV ⇄ JSON ConverterCSV/TSV ⇄ JSON 相互変換
- 40PDF Merge, Split & ExtractPDF結合・分割・ページ抽出
- 41Full-width ⇄ Half-width Converter全角⇄半角変換&テキストクリーナー
- 42X (Twitter) Post CounterX(Twitter)投稿の文字数計算(重み付き)
- 43CSS clamp() Fluid Typography CalculatorCSS clamp() 計算機
- 44CSS Gradient GeneratorCSSグラデーションジェネレーター
- 45Image Colour Palette Extractor画像からカラーパレット抽出
- 46QR Code ReaderQRコード読み取り
- 47SVG Optimizer & Data URISVG最適化&data URI化
- 48Redirect Generatorリダイレクトルール ジェネレーター
- 49IP / CIDR CalculatorIPアドレス・CIDR計算機
- 50ICS Calendar Event GeneratorICS Generator
- 51cubic-bezier Easing Preview & ComparisonEasing Preview
- 52CSS box-shadow Generatorbox-shadow ジェネレーター
- 53Japanese Dummy Text Generator和文ダミーテキスト生成
- 54Social Media Image ResizerSNS画像サイズ一括書き出し
- 55Time Zone Converter & World Clockタイムゾーン変換・世界時計
- 56Date & Business Day Calculator日数・営業日計算
- 57HTML → MarkdownHTML→Markdown変換
- 58HEIC to JPEG/PNG ConverterHEIC Converter
- 59Print Size & DPI Calculator印刷サイズ・DPI計算機
- 60Color Blindness SimulatorColor Blindness Simulator
- 61SERP Preview & Meta Tag Length CheckerSERPプレビュー&メタタグ文字数チェック
- 62Flexbox & CSS Grid GeneratorFlexbox / CSS Grid ジェネレーター
- 63Text Line Toolsテキスト行操作ツール
- 64Screenshot Frame & Background Makerスクリーンショット枠装飾
- 65Japanese Era ⇄ Western Calendar Converter和暦 ⇄ 西暦変換
- 66URL Slug Generator (Japanese → Romaji)URLスラッグ生成(日本語→ローマ字)
- 67htpasswd Generatorhtpasswd ジェネレーター
- 68OGP Image GeneratorOGP画像ジェネレーター
- 69Stamp Shape Generatorスタンプ形ジェネレーター
- 70Stay Awakeスリープ防止
- 71Screen Recorder with Click Auto-Zoom画面録画+クリック自動ズーム
- 723D Device Mockup Generator3Dデバイスモックアップジェネレーター
- 73OpenAPI Docs & TS Types GeneratorOpenAPI→日本語ドキュメント&TS型定義
- 74Screen Review Board画面レビューボード
- 75AI Decision JournalAI活用案件の判断記録
- 76Card Binder Plannerカードバインダー配置プランナー
- 77e-Stat CSV to Charte-Stat CSV かんたんグラフ化
- 78FAQ Schema (JSON-LD) & Markdown GeneratorFAQ構造化データ(JSON-LD)&Markdown ジェネレーター
- 79Code to Imageコード画像化
- 80Wiki Duplicate, Orphan & Term Checker社内文書の重複・孤立・表記ゆれチェッカー
- 81Site Style to AI Brand Guideサイトのスタイル→AI向けブランドガイド
- 82Profile Icon Preview: Old vs Newアイコンの丸切り抜きプレビュー
- 83Silent Sleep Camera寝顔を撮る無音カメラ
- 84Instagram PublisherInstagram投稿ツール
- 8512 Months in Photos今年の12枚
- 86Inner Envelope Box Fitterご祝儀袋・香典袋の中袋用 記入下書き
- 87Pixel Art Normal Map Generatorドット絵に光を当てる
- 88LINE Rich Menu Settings Sheet MakerLINEリッチメニューの設定表作成
- 89AI Reply Fact CheckAI返信案の送る前チェック
- 90Invoice Price Cut Checkインボイス値下げ、応じる前の3問チェック