Turn any URL into clean, accessible iframe embed code. Choose a fixed size or a responsive aspect ratio, style the border, set allow permissions and sandbox rules, enable lazy loading, and check the result in a live preview.
Last updated:
Source
Size
:
Appearance & loading
Permissions (allow)
Sandbox
Everything is blocked unless you allow it:
Advanced: id, name, class
Embed code
Live preview
Blank or "refused to connect"? The site forbids framing (X-Frame-Options / CSP frame-ancestors). Use its official embed link instead.
Advertisement
Advertisement
How to use the Iframe Generator
Paste a URL (or an existing <iframe> snippet). Video and music page links are converted to their embed URLs automatically.
Add a title that describes the embedded content, so screen reader users know what the frame contains.
Choose the size: a fixed width and height, or responsive mode with an aspect ratio that scales to the width of your layout.
Set behavior: border and corners, lazy loading, fullscreen, allow permissions and, for untrusted content, sandbox restrictions.
Check the preview, then copy the code into your HTML, CMS or page builder (use an HTML or Custom code block).
Iframe attributes explained
Attribute
Example
What it does
src
https://…/embed
The page to load inside the frame
title
Store location map
Accessible name announced by screen readers (required by WCAG for frames)
width / height
560 / 315
Fixed size in CSS pixels; width can also be a percentage
style
aspect-ratio:16 / 9
CSS for border, corners and responsive sizing
allow
autoplay; encrypted-media
Permissions policy: which browser features the framed page may use
allowfullscreen
(boolean)
Lets the frame enter fullscreen, e.g. a video player's fullscreen button
sandbox
allow-scripts allow-forms
Applies extra restrictions; each token re-enables one capability
loading
lazy
Defers loading until the frame is near the viewport
referrerpolicy
strict-origin-when-cross-origin
How much of your page URL is sent to the embedded site
frameborder, scrolling
(obsolete)
Old HTML4 attributes; use CSS border and the embedded page's own overflow instead
Responsive iframe: the formula
A responsive frame keeps its shape as its width changes. With modern CSS this takes one property: width:100%; aspect-ratio:16 / 9. The legacy technique uses a wrapper whose padding-top is a percentage of its width:
The iframe is then positioned absolutely to fill the wrapper. Both approaches give the same result; aspect-ratio is supported by all current browsers.
Iframe tips
Use the official embed URL. Normal page URLs of YouTube, Vimeo, Spotify and many others refuse to load in a frame; their /embed/ URLs are made for it. This generator converts common links automatically.
Always use https. Browsers block http:// frames on https:// pages.
Sandbox untrusted content. If you embed user-supplied or third-party HTML, start from an empty sandbox and add only the tokens it needs.
Lazy load below-the-fold embeds. Iframes are expensive; deferring them improves page speed and Core Web Vitals.
Frequently asked questions
What is an iframe?
An iframe (inline frame) is an HTML element that embeds another web page inside the current page. It is how videos, maps, forms, music players and widgets from other sites are usually embedded.
How do I make an iframe responsive?
Set the iframe to width:100% and give it a fixed shape with the CSS aspect-ratio property, for example aspect-ratio: 16 / 9. For very old browsers, wrap it in a container with padding-top equal to height divided by width (56.25% for 16:9) and position the iframe absolutely inside it. This tool can output either version.
Why does the preview say the site refused to connect?
Many sites forbid being framed by other sites using the X-Frame-Options header or the Content-Security-Policy frame-ancestors directive. That is set by the embedded site and cannot be changed from your page. Use the site's official embed URL if it offers one.
What does the sandbox attribute do?
An empty sandbox attribute applies all restrictions: no scripts, no forms, no popups, and the content is treated as a unique origin. Each token such as allow-scripts or allow-forms lifts one restriction. Avoid combining allow-scripts with allow-same-origin for content from your own origin, because the frame could then remove its own sandbox.
What is the allow attribute?
The allow attribute sets a permissions policy for the frame: which powerful features (autoplay, camera, microphone, geolocation, fullscreen, clipboard-write, encrypted-media and others) the embedded page may use. Features not listed are denied for cross-origin frames.
Should I add loading="lazy" to iframes?
Yes for iframes below the fold. Lazy loading tells the browser to defer loading the frame until the user scrolls near it, which speeds up the initial page load. Leave it off for an embed at the very top of the page.
Why does my iframe need a title?
Accessibility guidelines (WCAG) require frames to have a title that describes their content. Screen readers announce it when users navigate into the frame.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.