<!-- Markdown twin of https://pixelvault.dev/blog/base64-image-to-hosted-url/ -->

[← Back to blog](/blog/)

By [PixelVault](/about/) November 27, 2026

# Convert a Base64 image to a hosted URL

AI image models (OpenAI `b64_json`, Gemini), HTML5 Canvas `toDataURL()`, and n8n/Make nodes often hand you a giant base64 string when the next API expects an HTTPS link. Here is how to convert it in your browser or automate it in one call.

## Why inline `data:image` URIs break in production

Embedding a base64 string directly into HTML or JSON looks convenient until you ship it:

-   **Email clients strip them:** Gmail and Outlook block `data:image/...` URIs, leaving a blank box.
-   **Social & messaging APIs reject them:** Open Graph `og:image`, Slack webhooks, Twilio MMS, WhatsApp, and Buffer all require a real HTTPS URL.
-   **33% payload bloat and zero browser caching:** every response re-sends the full encoded bytes instead of letting the CDN cache a single URL.

## One-off conversion in your browser (no signup)

If you just copied a base64 string from DevTools, a JSON response, or an AI playground, paste it into our free [Base64 image to URL converter](/tools/base64-to-url/). It strips the `data:image/...;base64,` prefix (or auto-detects PNG, JPEG, WebP, GIF, AVIF, or SVG from raw base64 magic bytes), decodes locally in your browser, and returns a hosted CDN link plus Markdown and HTML tags.

## Automating Base64 → URL in Node.js

When your backend or workflow receives `b64_json` from an image model, decode it into a `Blob` and POST to `POST /v1/images`. You get back a permanent CDN URL in `data.url`:

Node.js

// Convert a data:image/...;base64,... string (or raw b64\_json) to a permanent CDN URL async function hostBase64Image(base64Input, filename = "generated.png") { const clean = base64Input.replace(/^data:\[^;\]+;base64,/, ""); const bytes = Buffer.from(clean, "base64"); const form = new FormData(); form.append("file", new Blob(\[bytes\], { type: "image/png" }), filename); const res = await fetch("https://api.pixelvault.dev/v1/images", { method: "POST", headers: { Authorization: \`Bearer ${process.env.PIXELVAULT\_API\_KEY}\` }, body: form, }); if (!res.ok) throw new Error(\`Upload failed: ${res.status}\`); const json = await res.json(); return json.data.url; }

## Sending Base64 directly as JSON (great for n8n & Make)

If you are inside a no-code HTTP Request node (n8n, Make, Zapier) where building multipart form data is awkward, PixelVault's batch endpoint accepts raw base64 straight inside a JSON body:

cURL

\# Or send base64 directly to /v1/images/batch (no multipart encoding needed) curl -s -X POST https://api.pixelvault.dev/v1/images/batch \\ -H "Authorization: Bearer $PIXELVAULT\_API\_KEY" \\ -H "Content-Type: application/json" \\ -d '{"collection":{"type":"generation","name":"cards"},"images":\[{"data":"iVBORw0KGgo...","filename":"card.png"}\]}' \\ | jq -r '.data.items\[0\].url'

Once hosted, you can also resize or convert on the fly with URL params (`?w=800&fmt=webp`) without regenerating the image. See our guides on [hosting GPT Image 2 output](/blog/host-gpt-image-2-images/) and [hosting images in Resend emails](/blog/host-images-in-resend-emails/).

## Predictable pricing — subscription or pay once

Start free with 200 MB storage and 1 GB monthly bandwidth. When your pipeline grows, [Starter](/pricing/) gives 25 GB storage and 100 GB bandwidth for $9/mo — or as a one-time **prepaid pass** ($10 for 30 days, $79 for 1 year) with zero auto-renew.

## More in AI-generated images

-   [Generate an image and get a hosted URL in one API call](/blog/generate-images-with-one-api-call/) Send a prompt, get a finished image on a CDN URL back. Real curl, Node, Python and Claude examples, with the credits, models and limits.
-   [How to host GPT Image 2 images on a permanent URL](/blog/host-gpt-image-2-images/) GPT Image 2 returns image bytes with temporary URLs that expire — OpenAI itself says to store them in your own CDN. Here's the one-call way to turn a gpt-image-2 result into a permanent, embeddable URL.
-   [Generate images with Nano Banana, host them on PixelVault](/blog/nano-banana-image-hosting/) Turn a prompt into a permanent CDN URL your coding agent can embed: generate a hero or OG card with Nano Banana (Google's Gemini image model), host it on PixelVault, done. Includes the open-source skill that does it.

[All posts in AI-generated images →](/blog/topics/ai-images/)
