Iframe embed code generator cropped

Allow attributes The features the embedded page may use, listed in the allow attribute.
Sandbox options With no tokens ticked, the sandbox allows nothing at all. Tick only what the embedded page needs.

Some websites block iframe embedding through security headers (X-Frame-Options and Content-Security-Policy frame-ancestors). If the preview stays blank, the site blocks embedding — the generated code is still correct, and there is no way to bypass those headers.

What is the Iframe Embed Code Generator?

The Iframe Embed Code Generator is a free online tool that builds the HTML for embedding another page inside your own — an <iframe> — with all the attributes that make it safe, fast and accessible. You set the URL, the size, the title, the loading behaviour, the permissions and the sandbox, and the tool gives you the complete markup to paste into your page. It is made for anyone who needs to show outside content on their site: a map, a video, a form, a document, or another website — and for beginners learning what an iframe is and how its attributes work.

But iframes have limits. Some websites block embedding through security headers — X-Frame-Options and Content-Security-Policy frame-ancestors — and when they do, the frame stays blank. The tool never tries to bypass those headers, because there is no way to, and it says so on the page. The generated code is still correct; the other site simply does not allow itself to be framed.

Everything runs in your browser. There is no sign-up, and nothing you type leaves your device.

How to use the Iframe Embed Code Generator

  1. Enter the URL. Type the full address — http:// or https:// — of the page you want to embed. The default is https://example.com/. The tool validates the URL and tells you if it is not a full web address.
  2. Set the Width and Height. The defaults are 600px wide and 400px tall, and each can be in pixels or percent. A width of 100% makes the frame stretch across its container — the usual choice for a responsive page.
  3. Write the Title. This is read aloud by screen readers, so describe what the frame shows: “Embedded content” is the default, but “Map of our shop in Lahore” is far better. Never leave the title empty.
  4. Choose the Loading behaviour. lazy loads the frame only when it scrolls into view (the default, and the best choice for pages with content below the fold); eager loads it right away; auto lets the browser decide.
  5. Set the Referrer policy. This controls how much of your page’s address is sent to the embedded site. The default, strict-origin-when-cross-origin, is the browser’s own default and the right choice for most embeds.
  6. Choose the Allow attributes. “Allow fullscreen” is ticked by default, along with eight features the embedded page may use: accelerometer, autoplay, clipboard-write, encrypted-media, fullscreen, gyroscope, picture-in-picture and web-share. Untick any the embedded page does not need.
  7. Decide about the Sandbox. The sandbox is off by default. Tick “Enable sandbox” to restrict what the embedded page can do, then tick only the permissions it needs — allow-scripts, allow-forms, allow-popups, and the rest. With no tokens ticked, the sandbox allows nothing at all.
  8. Watch the live preview. The preview shows the embedded page where the target website permits embedding. If it stays blank, the site blocks embedding — the code is still correct.
  9. Copy the code. Click Copy to take the generated iframe markup. Clear wipes the settings; Reset restores the defaults.

Worked example

Take the defaults: URL https://example.com/, 600px by 400px, title “Embedded content”, loading lazy, and the allow attributes as ticked. The generated markup looks like this:

<iframe src="https://example.com/" width="600" height="400" title="Embedded content" loading="lazy" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share"></iframe>

Try it yourself: change the width to 100% so the frame fills its container, and change the title to describe what you are embedding. The preview resizes at once, and the generated code updates to match. Then tick “Enable sandbox” with only “allow-scripts” ticked, and watch the sandbox attribute appear in the output.

Where an iframe generator actually helps

Embedding a map. A “find us” page needs a map, and the map provider gives you an embed URL. Paste it here, set the width to 100% and the height to 400px, and you have a map that fills the page width and loads lazily — so it does not slow down the rest of the page for readers who never scroll to it.

Embedding a video or a form. A video platform or a form service gives you an embed code, but the code is often a bare iframe with no title and no loading attribute. Rebuilding it here adds the title a screen reader needs and loading="lazy" for performance, and the sandbox lets you lock down what the embedded page is allowed to do.

Learning how iframes work. An iframe has more attributes than most beginners expect, and each one has a job: the title for accessibility, loading for performance, allow for permissions, sandbox for security, referrerpolicy for privacy. Building one in the tool and reading the output is the fastest way to learn what each attribute does and why it matters.

Tips for better embeds

  • Always write a real title. An iframe without a title is announced to screen reader users as just “frame” — they have no idea what is inside it. One sentence describing the content is enough, and it costs nothing.
  • Use lazy loading for anything below the fold. A map or video at the bottom of a page should not load before the reader gets there. lazy is the default in this tool for that reason — leave it on unless the frame is at the very top of the page.
  • Use a percentage width. A fixed 600px frame overflows on a 360px phone screen. A width of 100% adapts to any screen, and the height stays fixed so the frame keeps its shape.
  • Tick only the permissions the embed needs. Every allow feature and every sandbox token is a capability you are handing to another site’s code. A map does not need autoplay; a video does not need clipboard-write. The defaults are generous — trim them to what the embed actually uses.
  • Do not fight a blocked embed. If the preview stays blank, the site sends headers that forbid framing, and no attribute or trick will get around them. Link to the page instead of embedding it, or ask the site’s owner whether they offer an embed-friendly version.

Frequently asked questions

Why does the preview stay blank for some websites?

Because the site sends security headers — X-Frame-Options or a Content-Security-Policy frame-ancestors rule — that tell browsers not to display it inside a frame. This is the site owner’s choice, usually to prevent clickjacking, and it applies to every site that tries to embed them, not just to this tool. The generated code is still correct; link to the page instead.

What is the sandbox attribute for?

It restricts what the embedded page can do: without any tokens, it cannot run scripts, submit forms, open popups or navigate the top window. You then add back only the permissions the embed needs — allow-scripts for a page that needs JavaScript, allow-forms for one with a form. It is the strongest safety control an iframe has, which is why it is off by default and must be switched on deliberately.

What is the difference between loading=”lazy” and loading=”eager”?

lazy tells the browser to wait until the frame is near the viewport before loading it, which keeps the page fast for readers who never scroll down to it. eager loads it immediately, which is right for a frame at the top of the page. auto leaves the decision to the browser. For most embeds — maps, videos, forms below the fold — lazy is the best choice.

Why does the title matter so much?

Because an iframe is a separate page inside your page, and a screen reader announces it by its title. Without one, the reader hears only “frame” and has to guess what is in it. With a good title — “Video: How to make bread” — they can decide whether to enter it or skip past it, just like a sighted reader scanning a heading.

Can I embed any website?

Technically you can write the markup for any URL, but whether it displays depends on the other site. Many large sites — Google, Facebook, most banks — block framing entirely. Video and map services usually allow it, because embedding is how they are meant to be used. If you are unsure, paste the URL into the tool and look at the preview: a blank preview means the site blocks embedding.

Conclusion

An iframe is a window into another page, and like any window it needs a label, a sensible size, and a lock you control. The Iframe Embed Code Generator above builds all of that in one place — title, loading, permissions and sandbox included. Try it with a map or a video you actually want on your site, then use the HTML Boilerplate Generator to start the page it will live on.

Related Tools