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

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

<img src="photo.jpg" alt="Description of the photo">

The browser loads the HTML and JPEG as separate resources. If you need one portable HTML file with no separate image, encode the JPEG as Base64 and place it in a data:image/jpeg;base64,... URL instead. The two approaches solve different problems, so choose based on portability, maintainability and file size.

What “JPEG to HTML” actually means

HTML is a markup language; JPEG is an image format. An existing JPEG does not become HTML merely by changing its extension. In a normal page, HTML contains a reference to the image, and the browser fetches and decodes the JPEG. MDN describes this pattern with the <img> element in its HTML images tutorial.

There are two practical ways to put the image in a page:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Liene M100 4x6'' Photo Printer, Phone Printer 100 Sheets & 3 Cartridges, Full-Color Photo, Portable Instant Photo Printer for iPhone Android, Thermal Dye Sublimation, Wi-Fi Picture Printer 100 Papers
  • User-Friendly Portable Photo Printer for iPhone, Android & PC - Get beautiful and colourful memories with Liene 4x6 photo printer! After opening the entire package, you can find one cartridge + 20 sheets of photo paper (placed inside the machine packaging), as well as an additional box containing 80 sheets of photo paper (which includes two cartridges + 80 sheets of photo paper). Full package includes smartphone photo printer, Liene 4x6 photo printer papers (100 sheets), 3 colour cartridges, and fully sealed cassette to prevent dust. Minimalist and magnetic design for compact storage.
  • Superior Quality 4x6 Photo Printer - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Clean the print head promptly if smudges are observed on printed photos during operation. Get Liene photo printers now for yourself and your loved ones, print your happy moments together and keep your love forever!
  • Wi-Fi Photo Printer for Smartphone - The built-in hotspot of the photo printer makes it easy to print pictures from your phone, avoiding outside interference with a fast and stable connection. No other networks required! Simply connect your device to the independent instant photo printer 4x6 hotspot.
  • Multiple Device Compatibility - Liene phone printer provides instant photo printing for up to 5 simultaneous connections. Share with family and friends or print from your different devices. No additional cables or Bluetooth required when printing photos with this picture printer. Note: Ensure the ink cartridge clicks into place before printing.
  • Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Square border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this photo printer for iphone 4x6 prints.
  • Separate asset: keep the JPEG beside (or below) the HTML file and use a relative path. This is the normal, maintainable choice.
  • Inline data URL: Base64-encode the JPEG bytes and put the result directly in the HTML. This creates one self-contained file, but makes the markup much larger and harder to edit.

Method 1: reference the JPEG with <img>

Minimal page

Save this as index.html and put photo.jpg in the same directory:

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

Open index.html in a browser. The src value is resolved relative to the HTML document’s location, not relative to your computer’s current folder in a terminal.

JPEG in an images folder

For this structure:

site/
├── index.html
└── images/
    └── photo.jpg

use:

<img src="images/photo.jpg" alt="A mountain lake at sunrise">

To move up one directory, use ../, for example ../photo.jpg. File and folder names are case-sensitive on many web servers, so Photo.JPG and photo.jpg may be different paths after deployment.

Remote JPEG URL

You can point src at an absolute HTTPS URL:

<img src="https://example.com/assets/photo.jpg" alt="Description of the remote photo">

Use a remote image only when you are authorized to do so and the host is reliable. The owner can remove or replace it, visitors need network access to that host, and hotlinking can consume the other site’s bandwidth. Hosting images under a site you control is the more predictable arrangement, as MDN notes in its <img> reference.

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

Useful attributes

  • alt describes the image’s content or purpose. Use alt="" for purely decorative imagery. Do not use a generic value such as “image” or simply repeat the filename.
  • width and height can reserve the correct aspect ratio before the file arrives and reduce layout shifts. When possible, provide the JPEG’s intrinsic pixel dimensions; CSS can still control its displayed size.
  • loading="lazy" can defer images below the initial viewport. Do not lazy-load the main above-the-fold image if doing so delays the content users need immediately.
<img
  src="images/photo.jpg"
  alt="A mountain lake at sunrise"
  width="1600"
  height="1067"
  loading="lazy">

Method 2: make one self-contained HTML file with Base64

A data URL embeds the image bytes inside the document. Its structure is data:[media-type][;base64],data; for a JPEG, the media type is image/jpeg. The comma separates the header from the encoded payload. MDN documents this syntax in its Data URLs reference.

HTML form

Replace the placeholder below with the complete Base64 output from your JPEG. Do not leave the placeholder text in the final file, and do not insert spaces or line breaks into the payload:

Rank #2
KODAK Dock Plus 4x6 Photo Printer, Smartphone Docking, 4PASS, 50 Sheets
  • Dock Photo Printer: The KODAK Dock Plus is a home photo printer that produces high-quality 4x6” prints directly from compatible smartphones. Featuring an integrated docking station, users can place their phone on the printer for better connection while simultaneously charging the device during printing.
  • Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
  • Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Dock Plus is built for straightforward operation, making it ideal for first time users and everyday photo printing.
  • Home Printing Station: Designed for stable desktop use, this dock photo printer connects to a power outlet for consistent performance and larger 4x6” prints. Ideal for home printing, photo albums, framing, family events, and everyday picture printing.
  • KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Embedded JPEG</title>
</head>
<body>
  <img
    src="data:image/jpeg;base64,PASTE_BASE64_DATA_HERE"
    alt="A mountain lake at sunrise"
    width="1600"
    height="1067">
</body>
</html>

Encode the JPEG on Unix-like systems

On Linux, GNU base64 can write an unbroken payload:

base64 -w 0 photo.jpg > photo.b64

On macOS (and on systems where -w is unavailable), remove wrapping newlines:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
base64 photo.jpg | tr -d 'n' > photo.b64

Open photo.b64, copy its entire contents after data:image/jpeg;base64,, and save the HTML. The command reads binary bytes; do not first convert the JPEG to UTF-8 text.

Encode with Windows PowerShell

PowerShell should read raw bytes, not text:

$b64 = [Convert]::ToBase64String([IO.File]::ReadAllBytes("photo.jpg"))
Set-Content -Path photo.b64 -Value $b64 -NoNewline

Paste the resulting file contents into the data URL. A missing comma, a wrong media type such as image/jpg, or a typo in base64 can make the browser ignore the data URL without a useful diagnostic.

Generate the complete file with Python

This script avoids manual copy and paste and preserves the JPEG bytes:

import base64
from pathlib import Path

image = Path("photo.jpg").read_bytes()
payload = base64.b64encode(image).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("embedded.html").write_text(html, encoding="utf-8")

Separate file or data URL?

Need Better choice Reason
Ordinary website or a reused image Separate JPEG and relative src Readable HTML, independent caching and easy replacement.
One file to email, archive or upload where no asset folder is allowed Base64 data URL The image travels inside the HTML document.
Large JPEG or many images Separate files Inline Base64 makes every copy of the HTML larger and less manageable.
Image supplied by another site Remote src only with permission The remote server controls availability and bandwidth use.

Base64 is an encoding, not compression. The resulting text is longer than the original binary, and the markup becomes difficult to inspect or edit. There is no single standards-required maximum data-URL length; browser and application limits vary, so test the actual browsers and delivery systems you support rather than relying on a universal number. Separate resources also allow a page to begin displaying while a larger image is still downloading.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Nelko PP01 Photo Printer, 2x3 Portable Photo Printer, Mini Printer, White
  • 2x3" Portable Photo Printer: The upgraded PP01 photo printer uses advanced inkjet technology. This portable photo printer produces vivid, full-color prints on premium sticky-backed photo paper that is smudge-proof, water-resistant, and tear-resistant. The Nelko mini photo printer is pocket-sized and weighs only 308g, making it ultra-portable for school, travel, and field trips. Each ink cartridge prints up to 80 full-color 2x3 photos on sticky-backed paper
  • Easy Printing via Bluetooth: The PP01 mini photo printer is compatible with iOS and Android phones via Bluetooth. Simply download the Nelko app from Google Play or the App Store. Load the 2x3 photo paper with the smooth side facing down. Install the ink cartridge, connect via Bluetooth, and print directly using the Nelko app. A USB charging cable is included; the adapter is not included
  • High Photo Quality: This mini photo printer uses advanced inkjet technology for clear, vibrant prints. This portable photo printer produces 600 DPI high-resolution images with precise colors, capturing fine details and realistic tones. Each photo comes with adhesive backing, perfect for scrapbooks and preserving your memories. Personalize every photo for holidays, birthdays, or daily events
  • Powerful App: The Nelko 2x3" PP01 photo printer app lets you edit photos and offers a variety of frame designs, making it perfect for personalizing your photos for projects like scrapbooking or journaling. Download the Nelko app to create collages and customize photos with filters, graffiti, borders, stickers, text, AI image editing, and many other features. Edit photos on your phone, then send them to the Nelko app for instant printing in under 90 seconds
  • Versatile Usage Scenarios: This portable photo printer is ideal for travel journals, party favors, and family gatherings. Students use it for planners and photo printing. Crafters use it for DIY projects, custom labels, and scrapbooking. It's a practical tool for bloggers, small businesses, and event photographers to create instant giveaways. Perfect for Mother's Day surprises and heartfelt moments with loved ones using Nelko sticky-backed photo paper.

When JavaScript and canvas are appropriate

You do not need JavaScript or a canvas to place an existing JPEG in HTML. Canvas is useful only when you must process pixels in the browser—for example, resize an image, draw annotations, or export a newly generated JPEG.

const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
const image = new Image();

image.onload = () => {
  canvas.width = image.naturalWidth;
  canvas.height = image.naturalHeight;
  ctx.drawImage(image, 0, 0);

  // Quality is a request from 0 to 1; the browser may choose its own encoding.
  const jpegDataUrl = canvas.toDataURL("image/jpeg", 0.85);
  document.querySelector("#preview").src = jpegDataUrl;
};
image.src = "photo.jpg";

toDataURL() creates the entire image as an in-memory string. For large images, MDN recommends toBlob() with URL.createObjectURL() to avoid a large data URL and memory spike. A requested output type the browser does not support falls back to PNG, so check the result if the format matters. Drawing an image from another origin without the required CORS permission can taint the canvas; calling toDataURL() then raises a SecurityError.

Layout, accessibility and delivery checks

Write useful alternative text

Describe what a user needs to know, not how the file is named. For a chart or diagram, include the important conclusion in nearby text as well; an alt attribute alone may not convey a complex equivalent.

Prevent unexpected shifts

Set intrinsic width and height, or use CSS aspect-ratio, so the browser can reserve space before the JPEG arrives. Keep the rendered proportions equal to the source unless intentional cropping is applied.

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

Check the deployed path

Test the published URL, not only a local file. A page that works from file:// can fail after deployment because the server’s directory, URL encoding and case rules differ. In browser developer tools, a 404 means the path is wrong or the asset was not uploaded; a 403 usually indicates permissions or hotlink protection.

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

Troubleshooting

Broken-image icon or 404

Inspect the request URL in the Network panel. Correct the relative path, filename capitalization and URL-encoded spaces, then confirm the JPEG exists at that exact server path.

Rank #4
Liene Amber M110 Bluetooth Photo Printer 80 Sheets, Portable Photo Printer for iPhone, Thermal Dye Sublimation, Picture Printer 60 Sheets 4x6 Paper & 20 Sheets 3" Square Sticker Paper & 2 Cartridges
  • Dual 4x6" & 3x3" Photo Printer Paper Tray Convenience: Seamlessly print both 6-inch standard photo paper and 3-inch sticky-backed paper with our innovative dual tray design. This compact phone photo printer for smartphone offers easy storage and quick access, making it perfect for diverse printing needs without taking up much space. Enjoy vibrant, high-quality prints every time.
  • Fast Bluetooth Connectivity: Experience lightning-fast printing with our liene photo printer's Bluetooth connection, which pairs in just 13 seconds. Enjoy a seamless and efficient printing experience, perfect for capturing and sharing memories on the go without the hassle of cables or complex setups.
  • Superior Quality Photo Printer 4x6 - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Get Liene photo printers now as amazing gifts for yourself and your loved ones, print your happy moments together and keep your love forever!
  • Multiple Device Compatibility - Liene picture printer for iphone provides instant photo printing for up to mutiple simultaneous connections. Share with family and friends or print from your different devices. No additional cables required when printing photos with this phone printer.
  • Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Polaroid border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this iphone photo printer for 4x6 & 3x3 prints.

The image downloads instead of displaying

Check that the response has a usable JPEG content type such as image/jpeg and that the file is actually a valid JPEG. A server rule forcing Content-Disposition: attachment can also trigger a download.

Nothing appears with a data URL

Verify the prefix is exactly data:image/jpeg;base64,, including the comma. Re-encode from the original file, remove line breaks, and ensure the entire payload was copied. Do not add quotes or Markdown fences inside the URL.

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

PowerShell output is corrupt

Use [IO.File]::ReadAllBytes(). Reading the image with a text cmdlet changes binary data and produces an invalid Base64 payload.

Canvas throws a security error

The source image is cross-origin without an approved CORS response. Serve the image from the same origin or configure the image host to allow the requesting origin before drawing it to the canvas.

Page becomes very slow or huge

Remove unnecessary inline copies, resize the source JPEG to the largest displayed dimensions, and keep frequently reused images as separate files. For generated images, prefer a Blob/object URL over a giant data URL.

Images are blurry

Do not enlarge a small JPEG with CSS and expect new detail. Export at an appropriate intrinsic size, and remember that JPEG quality loss is cumulative when repeatedly re-encoding.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
KODAK Mini 2 Retro 2x3 Portable Photo Printer, 4PASS, 38 Sheets, White
  • Instant Photo Printing: The KODAK Mini 2 Retro is a portable photo printer designed to turn smartphone pictures into high quality prints in seconds. Whether capturing family moments, travel highlights, journaling pages, or creative projects, this mini printer lets you print real photos anytime, anywhere.
  • Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
  • Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Mini 2 Retro is built for straightforward operation, making it ideal for first time users and everyday photo printing.
  • Print Anytime, Anywhere: Small enough to fit in your hand, bag, or even a pocket, the Mini 2 Retro is built for on-the-go printing. Ideal for parties, trips, school projects, scrapbooks, and spontaneous moments where you want real prints without waiting.
  • KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.

Or skip the browser setup

If your actual task is to capture a rendered webpage as an image or PDF—not to turn JPEG bytes into HTML—ScreenshotNeo provides a single-call website screenshot API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP tools (take_screenshot, get_page_info and capture_pdf) work with Claude, Cursor and other MCP clients.

Use the ScreenshotNeo API documentation for all options. A cURL request:

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

Python:

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)

Node.js (save the response after the supplied request):

import { writeFile } from 'node:fs/promises';

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`ScreenshotNeo returned ${res.status}`);
await writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo includes full-page capture, element selection, device presets, custom CSS and JavaScript, waits, request blocking, headers and cookies, geolocation, resizing, caching, signed links, asynchronous webhooks and bulk capture. Every feature is on every plan: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000 shots, with yearly billing providing two months free. Create a free ScreenshotNeo account to try it.

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

Frequently Asked Questions

Can I rename a JPEG file to .html?

No. Renaming changes only the filename extension; it does not create HTML. Put the JPEG in an <img> element or embed its encoded bytes in a data URL.

Should I use image/jpg in the data URL?

Use the standard MIME type image/jpeg.

Will a Base64 image work in email?

Some email clients sanitize or restrict data URLs, so support is not universal. Test the specific clients or use the email platform’s supported image-hosting or attachment method.

Does embedding the JPEG improve SEO?

Embedding does not by itself improve search ranking. Descriptive alternative text, useful surrounding content, sensible dimensions and reliable delivery matter more.

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.