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

You normally do not convert JPEG bytes into HTML. Keep the .jpg or .jpeg file and reference it from an HTML <img> element:

<img src="photo.jpg" alt="Describe what the image shows">

The browser loads the JPEG as a separate resource. If you need one self-contained HTML file, encode the JPEG as Base64 and use a data:image/jpeg;base64, URL instead.

Use an HTML image element for a normal webpage

HTML is markup; JPEG is an image format. The usual solution is therefore an HTML document that points to the existing JPEG. You do not need to re-encode the picture or use a conversion program.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Photo example</title>
</head>
<body>
  <img src="photo.jpg" alt="A mountain lake at sunrise">
</body>
</html>

Save this as index.html in the same folder as photo.jpg, then open the HTML file in a browser. If the image is in a subfolder, include that folder in the relative path:

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.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
<img src="images/photo.jpg" alt="A mountain lake at sunrise">

Relative paths are resolved from the HTML file’s location. A file named Photo.JPG may work on a case-insensitive computer but fail on a case-sensitive web server, so match the spelling and capitalization exactly.

Write useful alternative text

Use alt text that conveys the image’s content or function. Do not use a generic value such as “image” or simply repeat the filename. For a purely decorative image, use an empty attribute, alt="", so assistive technology can skip it. When the image communicates information, provide an equivalent explanation in nearby text when appropriate.

Reserve the image’s space

If you know the JPEG’s intrinsic pixel dimensions, include them:

<img src="photo.jpg" alt="A mountain lake at sunrise" width="1600" height="1000">

The browser can reserve the correct aspect ratio before the file arrives, reducing layout movement. These attributes should describe the image’s intrinsic dimensions; use CSS for the size at which you want to display it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
img {
  max-width: 100%;
  height: auto;
  display: block;
}

Choose between a separate JPEG and an inline data URL

Need Approach Trade-off
Ordinary website page Separate JPEG with a relative src Readable HTML, independent caching and reuse, and easier replacement of the image.
One portable HTML file Base64 data URL The image bytes travel inside the document, but the markup becomes much longer and less maintainable.
Image hosted elsewhere Absolute URL in src Works only while that host permits and serves the file; the owner can remove or change it, and your page may consume the host’s bandwidth.

Separate resources let the browser begin displaying the document while a larger image is still loading. Use a data URL for a deliberate single-file or offline-delivery requirement, not because HTML requires it.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Make one self-contained HTML file with Base64

A data URL has this form:

data:[media-type][;base64],encoded-data

For a JPEG, the correct media type is image/jpeg. The comma separates the header from the encoded payload, and base64 tells the browser how to decode the bytes.

<img
  src="data:image/jpeg;base64,PASTE_BASE64_DATA_HERE"
  alt="A mountain lake at sunrise">

Replace PASTE_BASE64_DATA_HERE with the complete encoded file. The placeholder is not an image and must not remain in your finished document. Keep the payload uninterrupted; accidental spaces, missing characters or line breaks can make the URL fail in practical use.

Generate the file with Python

This script reads the JPEG as raw bytes, encodes it and writes a complete HTML file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from pathlib import Path
import base64

jpeg_bytes = Path("photo.jpg").read_bytes()
payload = base64.b64encode(jpeg_bytes).decode("ascii")
html = f'''<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Embedded JPEG</title>
<img src="data:image/jpeg;base64,{payload}" alt="A mountain lake at sunrise">
'''
Path("single.html").write_text(html, encoding="utf-8")

Run it from the directory containing photo.jpg. Open the resulting single.html; no second image file is needed for that copy.

Generate the payload from a Unix-like shell

base64 -w 0 photo.jpg

On systems whose base64 command does not support -w 0, remove wrapping newlines with:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
base64 photo.jpg | tr -d 'n'

Copy the output after data:image/jpeg;base64, in the src attribute. Treat the output as opaque data; do not edit it.

Generate it in Windows PowerShell

$bytes = [System.IO.File]::ReadAllBytes("photo.jpg")
$payload = [Convert]::ToBase64String($bytes)
$payload | Set-Clipboard

This reads binary bytes directly. Reading an image as UTF-8 text can corrupt it, so use ReadAllBytes rather than a text-file command.

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

Understand the practical limits

Data URLs have no single standards-mandated maximum length, and browser limits differ by implementation and version. Large Base64 documents are also harder to edit, review, cache and transfer. If a file opens on one browser but not another, or becomes unwieldy, return to a separate JPEG reference.

Do not use canvas unless you actually need image processing

Canvas is unnecessary for embedding an existing JPEG. It is useful when JavaScript has already drawn or transformed pixels and you specifically need a new data URL:

const canvas = document.querySelector("canvas");
const jpegDataUrl = canvas.toDataURL("image/jpeg", 0.85);
document.querySelector("#preview").src = jpegDataUrl;

The second argument requests JPEG quality; the browser may use a fallback format if the requested type is unsupported. toDataURL() creates the entire image as an in-memory string, so large canvases can consume substantial memory and produce a URL that is impractical to place in markup. For larger results, use a Blob and an object URL:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
canvas.toBlob((blob) => {
  if (!blob) return;
  const url = URL.createObjectURL(blob);
  document.querySelector("#preview").src = url;
  // Call URL.revokeObjectURL(url) when the preview is no longer needed.
}, "image/jpeg", 0.85);

A cross-origin image can taint a canvas. Once tainted, reading it with toDataURL() or similar APIs can raise a SecurityError; the image server must permit the required cross-origin access.

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

Common failures and fixes

Symptom Likely cause Fix
Broken-image icon with a separate file The path is relative to a different folder than expected, or the filename’s case differs. Check the HTML file’s location, verify the folder name, and match the exact filename including .jpg versus .jpeg.
Image appears when opened locally but not after upload The server uses case-sensitive paths or the JPEG was not uploaded. Upload the image and update the path to match the server’s spelling and directory structure.
Base64 image does not render The MIME type, comma, base64 marker or encoded payload is damaged. Start with data:image/jpeg;base64,, regenerate from the original bytes, and paste the complete payload without edits.
Huge or slow HTML file A large JPEG was embedded inline. Keep the JPEG as a separate resource, resize or recompress the source, or use a Blob/object URL for a runtime canvas result.
Canvas throws SecurityError A cross-origin image tainted the canvas. Serve the image from the same origin or configure the image host for the appropriate cross-origin request before drawing it.
Layout jumps while loading No intrinsic dimensions were provided. Add accurate width and height attributes and keep height: auto in CSS.

Performance, privacy and maintenance decisions

  • Reuse: A separate JPEG can be referenced by several pages and replaced without rewriting every HTML document.
  • Delivery: Separate resources allow the document and image to load independently. An inline payload makes every copy of the HTML carry the image bytes.
  • Editing: A normal src remains readable in source control. Base64 is opaque and difficult to review manually.
  • Portability: Data URLs are convenient for an offline handoff or a single-file attachment, provided the resulting document is acceptable to the recipient’s browser and size limits.
  • Ownership: A remote URL depends on another host’s availability and permission. Download and host the JPEG yourself when you need dependable control.
  • Accessibility: Choosing the correct alt text is part of embedding the image, not an optional cleanup step.
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 task is to capture a rendered HTML page as an image or PDF—not to place a JPEG inside markup—ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP or PDF. Before capture it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled.

Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

One-call examples

See the full parameter reference in the ScreenshotNeo documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Beyond a basic shot, options include full-page capture with lazy images loaded, a CSS-selector element capture, dark mode, 12 device presets or any viewport, retina scale, PDF paper settings and page ranges, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector/delay/network-idle waits, ad and tracker blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work for easier migration.

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

Every feature is included on every plan:

Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free. You can start with 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000 shots.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Final decision

For almost every webpage, leave the JPEG as a file and point to it with <img src="..." alt="...">. Use accurate paths, meaningful alternative text and intrinsic dimensions. Choose a Base64 data URL only when the single-file requirement outweighs its longer, less maintainable markup. Use canvas only when you need to create or transform pixels.

Frequently Asked Questions

Does changing a JPEG filename to .html convert it?

No. Renaming changes only the extension; the file still contains JPEG bytes. An HTML document must contain markup that references or embeds those bytes.

Can I make the JPEG itself editable HTML text?

No. A JPEG stores pixels, not selectable headings, paragraphs or other semantic elements. You can display it in HTML, but recreating editable content requires writing that content as HTML.

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

Which MIME type belongs in a JPEG data URL?

Use image/jpeg in the prefix data:image/jpeg;base64,; .jpg and .jpeg files use the same media type.

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.