Renan Gautier142 downloadsPreview local HTML files in an isolated iframe, with device widths and live reload, and embed them in your notes.
Preview HTML files stored in your vault, rendered in a real browser context instead of being injected into Obsidian's DOM.
Useful if you keep design mockups, exported artifacts, or standalone HTML prototypes alongside your notes.
Plugins that render local HTML by inserting it into the Obsidian document leak the
prototype's global CSS (body, :root, *, h1…) into the app's own interface, and
have to block scripts to stay safe.
This plugin loads the file into an <iframe> instead. The prototype gets its own
document, its own stylesheet scope and its own script context — nothing bleeds into
Obsidian, and JavaScript simply works.
No local web server is involved: the file is resolved through Obsidian's own resource
URL (app.vault.getResourcePath), the same mechanism used to display images from your
vault. This works on desktop and mobile alike.
.html and .htm files natively. Click a file in the file explorer and it
opens in a tab.html-preview code block.```html-preview
[[My prototype.html]]
height: 700
```
The block accepts a wiki link, a vault-relative path, or explicit keys:
| Key | Meaning |
|---|---|
path: (or file:) |
The HTML file to render |
height: |
Preview height in pixels — defaults to the plugin setting |
width: |
Fixed render width in pixels — defaults to full width |
The command Insert a prototype preview in the note generates the skeleton.
| Setting | Description |
|---|---|
| Default render width | Width applied when opening an HTML file |
| Reload automatically | Refresh the preview when the file changes on disk |
| Preview height in notes | Default height for html-preview blocks |
| Strict isolation | Drops allow-same-origin from the iframe sandbox |
By default the iframe keeps its origin, so prototypes can use localStorage and load
neighbouring files (images, fonts, sibling pages). This also means a prototype's scripts
run with the same origin as the app.
Enable Strict isolation for HTML you did not write yourself: the prototype then runs
in an opaque origin and cannot reach the Obsidian API — at the cost of localStorage and
relative file loading.
Only one view can own the .html extension. If another HTML-rendering plugin (such as
HTML Reader) is enabled at the same time, which one wins depends on plugin load order.
Disable the other one for predictable behaviour.
npm install
npm run dev # watch build
npm run build # type-check, then production bundle
To deploy the build into a vault for testing, point the repo at it — either with the
OBSIDIAN_VAULT environment variable, or by writing the vault's absolute path into a
git-ignored .vault-path file at the repo root — then:
npm run build && npm run install-local
This copies main.js, manifest.json and styles.css into
<vault>/.obsidian/plugins/html-prototype-viewer/. Reload Obsidian afterwards.
MIT — see LICENSE.