How to open an HTML file in Safari on iPhone, iPad, and Mac
Quick answer
On a Mac, open Safari and choose File > Open File (Command-O), or Control-click the .html file and choose Open With > Safari. On an iPhone or iPad, tapping the file in Files opens a Quick Look preview that ran no JavaScript in our tests: open an HTML viewer in Safari and choose the file there, or send a link.
Free plan: no credit card, 1 published page.
On this page
Your .html file opens in TextEdit, in a code editor, or in Chrome on your Mac, or as a preview on your iPhone, and you want it in Safari. This guide covers the Safari part on each device: the menu, the shortcut, the default app, Terminal, and what an iPhone or iPad does instead. For everything else about one device, see the guides for iPhone, iPad, and Mac. For Chrome, see how to open an HTML file in Chrome.
Sending a file you made? The upload box at the top of this page turns it into a preview link without an account. That preview runs no scripts, so a quiz or game won't respond there. Click Keep this page — free, no card and sign up, and the page moves into your account, where its scripts run and you can publish it.
Open an HTML file in Safari on a Mac in 4 steps
These steps come from Apple's help pages, read on November 4, 2026. That day we read the menu labels in Safari 26.5.2's own files and opened a test page with the Terminal command, on macOS 26.5.2. We didn't try the menu, a drag, the Finder's Open With, or Get Info > Change All.
1. Choose File > Open File in Safari
Open Safari and choose File > Open File, or press Command-O, then pick the file. Safari 26.5.2's menu file names the item Open File. Apple's list of Mac keyboard shortcuts describes Command-O as "Open the selected item, or open a dialog to select a file to open."
2. Or drag the file onto Safari
Apple's guide to opening a file with a particular app says: "Drag the file onto the app icon in the Finder or the Dock." Drop the .html file on Safari's icon in the Dock.
3. Or choose Open With > Safari
Apple's steps: "Control-click the file, choose Open With, then choose an app." Pick Safari. On our Mac, macOS listed Safari among the apps that can open an .html file. This opens the file in Safari once. The next double-click still uses the app set for .html files.
4. Make Safari the app for .html files
Apple's steps: select the file, choose File > Get Info, and under Open with, "Click the pop-up menu, choose an app, then click Change All." Choose Safari. Apple adds: "Don't click Change All if you only want the specific file you selected to open with that app."
From then on, a double-click opens every .html file in Safari. On the Mac we tested, .html files were set to open in Google Chrome. Apple's help for making Safari your default web browser is about webpages: in System Settings > Desktop & Dock, choose Safari next to Default web browser. Apple notes that "Some apps open webpages in a browser other than your default browser."
From Terminal
In Terminal, go to the folder with the file and run:
open -a Safari page.html
macOS's manual for open says -a "Specifies the application to use for opening the file", and that file names are read "relative to the shell or Terminal window's current working directory". Without -a, open page.html opens the file "just as if you had double-clicked the file's icon", in the app set for .html files.
We ran the command on November 4, 2026, on macOS 26.5.2, from the folder of a test page with files beside it. Safari 26.5.2 opened the page at a file:/// address. What the page did there:
| In the test page | In Safari 26.5.2, from file:/// |
|---|---|
| A script written inside the file | Ran |
style.css and photo.png in the same folder | Loaded |
classic.js in the same folder, loaded with <script src="classic.js"> | Ran |
game.js in the same folder, loaded with <script type="module" src="./game.js"> | Didn't run |
fetch("data.json") for a file in the same folder | Failed, with "TypeError: Load failed" |
A number saved with localStorage, then the file opened again | Kept |
On an iPhone
Tapping an .html file in the Files app doesn't open Safari. Apple's guide to Files on iPhone says: "If you haven't installed the app that created a file, a preview of the file opens in Quick Look." In our iOS 26.3 Simulator test of October 6, 2026, that preview showed the text and the CSS inside the file, ran no JavaScript, and loaded nothing from the web.
To see the page in Safari, open the free HTML viewer in Safari, tap Choose an .html file, and pick the file. The page runs in Safari, and the file isn't uploaded. If someone sent you a file you weren't expecting, ask them first, and turn off Run scripts before you choose it. The iPhone guide has the steps and what to do with a file from Mail, WhatsApp, or Messages.
Apple also describes Open With: touch and hold the file, "Choose Open With from the menu, then choose an option." We didn't test which apps an iPhone lists there, or what Safari does with a file:// path typed into its address bar.
On an iPad
In our iPadOS 26.5 Simulator test of October 24, 2026, the Files app gave Safari no way in:
- A tap opened a Quick Look preview. The CSS applied, but the script didn't run and a button counter stayed at 0.
- Open With said "No Apps Available", with one choice: Preview with Quick Look.
- Get Info showed the kind as "HTML text", and Always Open With said "No Apps Available".
- The preview's share button offered Copy, Print, Add Tags, and Save to Files, and its list of apps was empty.
The same file ran in Safari when we chose it in the HTML viewer: the script ran and the counter counted taps. For a file someone sent you that you weren't expecting, ask the sender first, and turn off Run scripts before you choose it. The iPad guide has the steps and the full test. We didn't test a physical iPad, iPadOS 26.7 or 27, or a file:// path typed into Safari.
Why it opens in Safari but looks broken
A page opened from your Mac's disk has a file:/// address, and Safari blocks some of what it loads there. In our test, a module script and a data.json fetch from the page's folder failed, while CSS, images, and plain scripts beside the page loaded. A file that came to you alone, by email or chat, has nothing beside it at all.
- Code instead of a page, or a blank page: see HTML file shows code or a blank page.
- Text with no pictures or styles: see HTML file missing images or styles. The
.cssand image files the page points to have to sit beside it, or be inside it.
To see the error, open Web Inspector from the Develop menu. Apple says its console shows "logs, errors, and warnings emitted from a webpage". If you don't see the Develop menu, Apple says to "choose Safari > Settings, click Advanced, then select 'Show features for web developers.'"
Safari also has a switch for local pages. Apple's developer documentation says that once those features are shown, "Safari adds a Developer pane to its settings", and lists Disable local file restrictions there: "Disable security checks that may prohibit local development when loading content with the file:// protocol." Safari 26.5.2's settings files carry the same label. We didn't turn it on. It changes only your own Safari, not the browser of anyone you send the file to.
The fix that works everywhere: ask the AI that made the page for one HTML file with the CSS, the JavaScript, and any data inside it, or put the page at a web address.
Ways to open it in Safari, compared
| Way to open it | Where it works | What runs | Files beside it | Who sees the page |
|---|---|---|---|---|
| File > Open File, a drag, or Open With > Safari | Mac | The page from file:/// | Module scripts and data files blocked (same file:/// address as our Terminal test; these ways not tried) | Only you |
open -a Safari page.html | Mac (tested) | The page from file:///, scripts inside it included | As above | Only you |
| Tap the file in Files | iPhone, iPad | A Quick Look preview, not Safari: no JavaScript in our iOS 26.3 and iPadOS 26.5 tests | Not loaded | Only you |
| HTML viewer in Safari, Choose an .html file | iPhone, iPad, Mac | The page in a walled-off frame, scripts on unless you turn off Run scripts | Not loaded; the viewer lists files named in tags | Only you |
| Another browser or a file app from the App Store | iPhone, iPad | Not tested | Not tested | Only you |
| A link to a published page | Any phone or computer | The page from https://, in Safari or the default browser | One HTML file goes up, so fold them into the page first | Everyone with the link |
Send a link that opens in Safari
A file you send arrives as a file, so the other person goes through the steps above on their own device, and on an iPad, Files gave Safari no way in. A link opens the page from an https:// address in their browser, which on an iPhone, iPad, or Mac is Safari unless they changed it. In our iPad test, a published Convika page opened in Safari with its scripts running.
With Convika:
- Drop your file into the upload box at the top of this page, or paste the code. You get a preview link in seconds, without an account. It works for 3 minutes, with scripts and forms off.
- Click Keep this page — free, no card and sign up. The page moves into your account, and its scripts run in the dashboard preview.
- Click Publish page. Under Who can open this page?, choose Public and click Next. The first time, click Publish free.
- Copy the address under Live URL and paste it into the email or chat instead of the file.
On Free, the page is published as Public: anyone with the link can open it, and it may show up in search results and in Convika's gallery. To keep it out of both, choose Private link (Pro) under Who can open this page? when you publish. Anyone with a private link can still open it.
Convika hosts one HTML file per page, so fold any game.js or style.css into the page first. You can also start from the free HTML publishing tool, which has the same upload box. How to share an HTML file as a link compares other free hosts, and Is it safe to open an HTML file? covers files you weren't expecting.
Frequently asked questions
How do I open an HTML file in Safari on a Mac?
Open Safari, choose File > Open File (Command-O), and pick the file. Or Control-click the file in the Finder, choose Open With, and pick Safari, or drag it onto Safari's icon in the Dock, as Apple's guide describes. The page opens at a file:/// address. In Terminal, open -a Safari page.html does the same; we tested it in Safari 26.5.2.
How do I open an HTML file in Safari on iPhone?
Open an HTML viewer in Safari, such as Convika's free HTML viewer, tap Choose an .html file, and pick the file from Files. The page runs in Safari, and the file isn't uploaded. Tapping the file in Files opens a Quick Look preview instead, which ran no JavaScript in our iOS 26.3 test. For a file you weren't expecting, ask the sender first, and turn off Run scripts before you choose it.
How do I open an HTML file in Safari on iPad?
The same way: open an HTML viewer in Safari, tap Choose an .html file, and pick the file in the Files sheet. In our iPadOS 26.5 test, the Files app's Open With said "No Apps Available", so it offered no way to send the file to Safari, and its preview ran no JavaScript. The viewer ran the same file's script in Safari.
Can I open a local HTML file in Safari on iPhone?
Not from the Files app in our tests: a tap opened Quick Look, not Safari. We didn't test typing a file:// path into Safari's address bar. A web page that reads the file in Safari, such as an HTML viewer, runs it, and a link to a published page opens in Safari with one tap.
How do I make Safari open HTML files by default on a Mac?
Select an .html file, choose File > Get Info, pick Safari under Open with, and click Change All, as Apple's guide describes. Then a double-click opens every .html file in Safari. Choosing Safari as the Default web browser in System Settings > Desktop & Dock sets the browser for webpages, which Apple's Safari help covers.
How do I open an HTML file in Safari from Terminal?
Go to the file's folder and run open -a Safari page.html. In our test on macOS 26.5.2, it opened the file in Safari 26.5.2 at a file:/// address, and the script inside the page ran. Without -a, open page.html uses the app set for .html files.
Why does my HTML file look broken in Safari?
Because a page opened from your disk can't load everything. In our test, Safari 26.5.2 blocked a game.js module and a data.json fetch from the page's folder, though CSS, images, and plain scripts beside it loaded. A file sent alone has nothing beside it. Web Inspector, in the Develop menu, shows the error in its console. Ask the AI for one self-contained HTML file, or publish the page and open its link.
Sources
- Choose an app to open a file on Mac (Apple) (read November 4, 2026)
- Mac keyboard shortcuts (Apple) (read November 4, 2026)
- Make Safari your default web browser on Mac (Apple) (read November 4, 2026)
- Use the developer tools in the Develop menu in Safari on Mac (Apple) (read November 4, 2026)
- Changing Developer settings in Safari on macOS (Apple Developer) (read November 4, 2026)
- Web Inspector (Apple Developer) (read November 4, 2026)
- Find and view files and folders in Files on iPhone (Apple) (read November 4, 2026)
- Find and view files and folders in Files on iPad (Apple) (read November 4, 2026)
- The
openmanual page on macOS 26.5.2 (man open; read November 4, 2026)
Next step
How to password protect an HTML page without code, on your own domain
JavaScript passwords sit in the page code. Put an HTML page from ChatGPT or Claude behind a server-checked password on your own domain.
Related articles
- How do I open an HTML file on an iPhone, and how do I send one that opens?Tap an .html file in the iPhone Files app and you get a preview with no scripts. Open it in Safari with a free viewer, or send a link instead of the file.
- How do I open an HTML file on an iPad, and why does my quiz or game not respond?On iPad, the Files app opens an .html file in a Quick Look preview that ran no scripts in our test. Run it in Safari with a free viewer, or send a link.
- How do I open an HTML file on a Mac, and why does my AI-made page break?A Mac opens an .html file in your browser from a file:// address. Our October 2026 test shows what Chrome blocks there, and 3 fixes: one file, a server, a link.
- How to open an HTML file in Chrome (computer, iPhone, and Android)Open an .html file in Chrome with Open with or Ctrl + O, make Chrome the default, run it from the terminal or VS Code, and what works on a phone.
- Why does my HTML file open as code (or a blank page) instead of a page?An HTML file shows code when an editor, a preview, or a .txt name opens it, and goes blank when its script can't run. Our October 2026 tests, and each fix.
- My HTML file opens but the images and styling are missing. Why?An .html file is only the page: its images, style.css, scripts, and fonts are other files. Our October 2026 tests show what goes missing, and how to fix each.