Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To convert an image URL to Base64, download the image’s binary bytes and encode those bytes—not the URL text. In browser JavaScript, fetch the image and turn its Blob into a data URL with FileReader. In Python, retrieve the response bytes and pass them to base64.b64encode(). Browser JavaScript can read a cross-origin image only when the image server permits it through CORS; Python server-side retrieval does not use browser CORS, but still needs careful URL and response handling.

What the conversion produces

Base64 is a text representation of binary data. For an image, the input to the encoding step is the downloaded image file’s bytes. Encoding the URL itself produces text for the address, not an encoded image.

There are two commonly requested output forms:

  • Data URL: includes a media type and encoding declaration, followed by the Base64 payload, for example data:image/png;base64,.... This is useful where a consumer accepts an image directly as a URL-like value.
  • Raw Base64: contains only the encoded payload, without the data:...;base64, prefix. Use this when the destination specifically asks for Base64 text rather than a data URL.

MDN documents that FileReader.readAsDataURL() returns a data URL and explains that its declaration must be removed if the destination expects only the Base64 data: FileReader: readAsDataURL().

Convert an image URL in browser JavaScript

This function fetches the image, checks whether the HTTP request succeeded, reads the response as a Blob, and converts the Blob to a data URL. It returns the complete data URL; a second helper extracts only the payload when needed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sheiaier N64 to HDMI Converter Adapter
  • Universal Display Mode Support: N64 to HDMI Converter supports all N64 display modes including 480i, 576i, and 480p for comprehensive compatibility
  • No Transmission Loss: Compatible with N64, GameCube, SNES, and SFC console signals to HDMI signals, converting original video output without signal degradation
  • Plug and Play Installation: No settings required and no need to install drivers, works seamlessly with HDMI monitors and HDTVs for immediate use
  • Package Contents: Includes 1x N64 to HDMI converter, 1x Micro USB cable for power supply (adapter not included)
  • Multiple Port Configuration: Features 1x N64 input port, 1x HDMI output port, and 1x USB power supply port for complete connectivity
async function imageUrlToDataUrl(url) {
  const response = await fetch(url);
  if (!response.ok) {
    throw new Error(`Image request failed: ${response.status}`);
  }

  const blob = await response.blob();
  return await new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.onload = () => resolve(reader.result);
    reader.onerror = () => reject(reader.error);
    reader.readAsDataURL(blob);
  });
}

function dataUrlToBase64(dataUrl) {
  const comma = dataUrl.indexOf(",");
  if (comma === -1) {
    throw new Error("Not a data URL");
  }
  return dataUrl.slice(comma + 1);
}

const dataUrl = await imageUrlToDataUrl("https://example.com/image.png");
const rawBase64 = dataUrlToBase64(dataUrl);

console.log(dataUrl);   // data:image/png;base64,...
console.log(rawBase64); // Base64 payload only

Replace the example address with the actual image URL. This uses browser APIs and is intended to run in a browser context that supports Fetch and FileReader. The Fetch API’s default mode is CORS; for cross-origin requests, the server must permit your page to read the response. See MDN’s Using the Fetch API guide.

When a URL is same-origin

If the image is served from the same origin as the page, the browser’s same-origin restrictions ordinarily do not block the script from reading the response. The request can still fail for ordinary reasons such as an unavailable resource, an unsuccessful HTTP status, or a network error; the code throws for unsuccessful HTTP status codes.

When a URL is cross-origin

A browser may display a cross-origin image in an <img> element while still preventing JavaScript from reading the image response. Fetching and encoding requires readable response bytes, so the image host must return appropriate CORS permission for your page’s origin. Setting mode: "no-cors" does not bypass this rule: it gives script an opaque response whose body is not available. The Fetch Standard describes this behavior: WHATWG Fetch Standard.

Convert an image URL in Python

Python’s urllib.request can open a URL, and the standard base64 module encodes bytes-like input. This example reads the response bytes and converts them to ASCII Base64 text:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Kaico N64 to HDMI Adapter for Nintendo 64, SNES & Gamecube
  • Passthrough HDMI - Analogue HDMI Adapter for use with Nintendo Consoles. Support for SVideo and Composite outputs.
  • No Messy Cables - The N64, Super Nintendo and Gamecube all work well with this HDMI Converter. Does Not Need Any Additional Power to Work.
  • N64 Snes and Gamecube compatible - Plug and Play HDMI Adapter, no need to install additional software or hardware.
  • All in One - Works with Nintendo N64. Super Nintendo, Super Famicon and Gamecube via the proprietary analogue port.
  • 12 Months Support, Repair, and Replace Warranty with Kaico on all HDMI adapters. Packaging may vary.
import base64
from urllib.request import urlopen

image_url = "https://example.com/image.png"

with urlopen(image_url, timeout=15) as response:
    image_bytes = response.read()

base64_text = base64.b64encode(image_bytes).decode("ascii")
print(base64_text)

The result is raw Base64. To build a data URL, prepend a media type that matches the image, such as data:image/png;base64, for a PNG:

data_url = "data:image/png;base64," + base64_text

Do not label the payload as PNG unless the downloaded content is actually PNG. The response’s Content-Type can be useful, but for untrusted input it should not be treated as definitive proof that the bytes are a valid image. Python documents URL opening in urllib.request and Base64 encoding in the base64 module.

Make server-side URL fetching safer

The short example is suitable for a controlled script with a known image URL. A service that accepts user-supplied URLs needs additional safeguards because it is making network requests on someone else’s behalf. Apply controls appropriate to your application, including:

  • Allow only expected URL schemes, and consider an allowlist of permitted hosts.
  • Set a timeout and enforce a response-size ceiling while reading, rather than allowing an unbounded download.
  • Validate that the returned content is an image your application accepts, rather than trusting the URL suffix or response header alone.
  • Handle HTTP errors, redirects, DNS resolution, and access to internal network destinations according to your service’s network policy.

There is no universal image-size limit established by the cited references. Choose limits based on your application, destination, and resource budget; large Base64 strings may also exceed the receiving service’s request-size limits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
MAYFLASH N64 to HDMI Adapter N64 Gamecube SNES SFC to HDMI Converter 1080P for Full HD Converter with 3.5mm Audio Jack HDMI Output N64 to HDMI Converter
  • [System Compatibility]: N64, GC, SNES, SFC.
  • [Fantastic Gaming Experience] Using the brand new decoder chip and advanced signal processing with great precision, colors and resolution, MAYFLASH N64 to HDMI Converter will ensure you a fantastic gaming experience. Just Plug and Play!
  • [Small Size] Size: 4.0x3.3x1.4cm. MAYFLASH N64 to HDMI Converter is much smaller than a standard lighter.
  • [Extra Audio Jack] An extra 3.5mm audio jack allows you to connect a speaker or headphone. Enjoy your gaming time without disturbing anyone at any time.
  • [Buy with Confidence] Your warranty begins working as soon as you place an order. All MAYFLASH products are fully and strictly tested before shipping. If you have any questions or have any difficulty operating the device, please reach out to our service team and we will be more than happy to help you out.

Choose the right output and method

Approach Output Access constraint Where to apply controls
Browser JavaScript with Fetch and FileReader Data URL by default; strip the declaration for raw Base64 Cross-origin response must grant CORS permission; opaque no-cors responses cannot be read Browser code can check status and handle errors; URL access remains governed by the browser and server
Python with urllib and base64 Raw Base64; construct a data URL by adding the correct prefix Not subject to browser CORS, but the URL must be reachable from the Python environment Server-side code can enforce URL policies, timeouts, response-size limits, and content validation

Common problems and fixes

The browser says the request was blocked by CORS

The image host has not authorized your page to read the cross-origin response. Configure the host to return suitable CORS headers if you control it, use a server-side retrieval route you control, or ask the image host to allow your origin. An image displaying in a page does not prove that JavaScript can read its bytes.

Using no-cors gives an empty or unusable result

An opaque response deliberately hides its body and headers from JavaScript. Remove mode: "no-cors"; it is not a CORS bypass. Use a CORS-enabled image host or retrieve the image from a server-side environment with appropriate network controls.

The output starts with data:image/... but the API rejects it

The destination may expect raw Base64 instead of a data URL. Remove everything through and including the first comma, keeping the payload after it. Conversely, if a destination expects a data URL, retain the prefix and ensure its media type matches the image.

The request returns an error or the encoded value is not a usable image

Check that the URL is reachable from the environment running the code, that the HTTP response succeeded, and that the response body is the image you intended to retrieve. A URL can return an error page, a redirect destination, or non-image content. In Python, catch and handle the appropriate URL and HTTP exceptions in production; in browser code, retain the status check and surface the error rather than silently encoding a failed response.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
N64 to HDMI Converter Adapter, 720P 1080P 60Hz Upscaler for HDTV Monitor Projector, Retro Gaming Adapter with 4:3 16:9 Mode for N64 Console
  • Upscale to Crisp 720P 1080P 60Hz Video: This N64 to HDMI upscaler instantly converts your original N64 console output to high definition 720P or 1080P resolution at a smooth 60Hz refresh rate. Eliminate blurry, fuzzy images and enjoy sharper, clearer graphics on modern HDTVs, monitors, or projectors. Experience your favorite retro classics with significantly enhanced visual clarity and reduced lag.
  • Fast Plug and Play Installation with No Drivers: Simply connect the N64 HDMI adapter between your console and TV via AV cable and HDMI cable. There is no complicated setup or software driver installation needed. This n64 to hdtv converter adapter works instantly right out of the box. Just plug in and start playing your nostalgic game library without any extra configuration.
  • Between Classic 4:3 and Widescreen 16:9 Modes: Easily toggle between :3 aspect ratio for authentic retro feel or full screen 16:9 widescreen mode to fill your modern display. This n64 display adapter gives you the flexibility to choose your preferred viewing experience. Whether you want to preserve the classic look or stretch to match your screen size, .
  • Broad Compatibility with All N64 Console : Designed specifically for the 64, this n64 video converter adapter works with all original NTSC and PAL N64 console versions. It supports all standard N64 AV cables and is perfect for connecting to HDTVs, computer monitors, projectors, and gaming capture cards. A must have n64 accessory for any serious retro .
  • Compact and Portable Design for Easy Setup: The lightweight, compact n64 signal converter adapter takes up minimal space near your entertainment center. Its simple and durable build ensures reliable performance for years of retro gaming sessions. Ideal for home gaming setups, retro game rooms, or travel to friends houses, this adapter keeps your classic console setup clean and convenient.

The Base64 value is unexpectedly large

Base64 represents the full binary image as text, and the data URL adds a declaration as well. Large values consume memory and may exceed the destination’s request limits. Prefer passing an image URL or uploading the image as a file when the receiving system supports those options; apply limits specific to that system.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your actual goal is to capture a website screenshot and receive an image file, rather than encode an existing image URL, ScreenshotNeo is a screenshot API and MCP server for developers. It returns a screenshot or PDF from a URL; it is not a Base64 conversion endpoint. Here is its one-call cURL example, which saves a WebP screenshot:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for API parameters. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.

Why the distinction matters

Choose conversion when you already have an image URL and the destination requires the image’s bytes represented as text. Choose a screenshot API when you need to render a webpage and capture what it looks like. Converting the screenshot file to Base64, if later required by another system, is a separate step from taking the screenshot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Base64 conversion change or compress the image?

No. Base64 changes how the same bytes are represented as text; it is not an image-compression format.

Can I convert a URL to Base64 without downloading the image?

No. The conversion requires the image bytes. A server or browser must retrieve those bytes before encoding them.

Can I use a data URL anywhere an image URL is accepted?

Not necessarily. The destination must support data URLs, and some systems impose size or content restrictions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.