Responsive preview & sizing
Compute iframe sizes, scale factors and horizontal-overflow flags for mobile/tablet/desktop viewports, emit a preview document with media queries, then render that document on the page inside an iframe with an empty sandbox (scripts never run) and let you download the HTML.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Result
The result can be copied directly.
Paste HTML to see the three viewport sizes
Characters: 0 · Lines: 0 · Viewports: 0 · Attrs removed: 0
What this tool does
- Check whether a layout overflows horizontally at each viewport.
- Get suggested viewport sizes for a screenshot script or a design handoff.
- Produce a downloadable preview document that works outside the tool page.
- See the three viewports rendered right on the page, and download the HTML document.
Example
Input
<div width="800">content</div>
Output
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Responsive preview</title>
<style>body{margin:0;background:#f5f6f8;font:13px/1.6 system-ui,sans-serif}.frames{display:flex;flex-wrap:wrap;gap:16px;padding:16px}.frame{background:#fff;border:1px solid #e4e6eb;border-radius:8px;overflow:hidden}.frame figcaption{padding:6px 10px;color:#5b6270}@media (max-width:900px){.frames{flex-direction:column}}</style>
</head>
<body>
<div class="frames">
<figure class="frame"><figcaption>mobile 375×667</figcaption><iframe title="mobile" width="375" height="667"></iframe></figure>
<figure class="frame"><figcaption>tablet 768×1024</figcaption><iframe title="tablet" width="768" height="1024"></iframe></figure>
<figure class="frame"><figcaption>desktop 1440×900</figcaption><iframe title="desktop" width="1440" height="900"></iframe></figure>
<iframe title="mobile" width="375" height="667" src="about:blank" data-viewport="mobile"></iframe>
<iframe title="tablet" width="768" height="1024" src="about:blank" data-viewport="tablet"></iframe>
<iframe title="desktop" width="1440" height="900" src="about:blank" data-viewport="desktop"></iframe>
</div>
</body>
</html>
Sizes are computed here, rendering lives in the page; `<div width="800">` is flagged `scrollX: true` at 375px.
Frequently asked questions
Does it render three real iframes?
Yes. The logic side only sizes and emits the document; the page renders that document inside an iframe with an empty sandbox, so mobile / tablet / desktop are actually drawn. Because allow-scripts is not set, scripts inside the document never run.
How is scrollX decided?
It takes the first element with a `width` attribute and compares it with the viewport width; it is a hint, not a layout engine.
What does retina change?
Only the emitted scale (2 for mobile/tablet, 1 for desktop); CSS pixel sizes stay the same.
Any limit on gap?
It must be a finite number >= 0, otherwise `invalid-gap` is thrown.
Keywords:html-responsive-previewviewportiframedeveloper