Image to Base64 / data URI
image_to_base64Encode images or files as Base64 for embedding as data URIs, CSS, HTML, Markdown, or SVG URIs; detects MIME type, warns when inline size is too large, and saves oversized output to a text file.
Instructions
Encode an image (or any file) as Base64: a data URI, bare Base64, a CSS background-image rule, an HTML tag (with width/height), Markdown, or for SVG a URL-encoded data URI (usually ~30% smaller). Detects the type from the bytes and warns when the result is too big to inline (over 10 KB: slows pages; over 1 MB: use a normal file). Results longer than maxChars are written to a .txt file instead of being returned. Web version: https://s3eidat.github.io/image-to-base64/
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as | No | What to return: dataUri (default), base64, css, html, markdown, or svgUri (SVG only). | dataUri |
| image | Yes | The image: a local file path (absolute, or relative to the server's --root) or base64 data (raw or a data: URI). | |
| output | No | Where to write the result: a file path, or a folder ending in "/". Default: the server output folder (a temp folder unless --out-dir is set). | |
| maxChars | No | Longest text returned inline; longer results go to a file. Default 200000. | |
| mimeType | No | Override the detected MIME type (e.g. image/svg+xml). |