iFrame Embed Code Generator

Use this iframe generator to build clean embed code for any URL — videos, maps, forms, calendars and widgets — with the size, responsive behaviour and security options set properly.

1Paste the URL to embed
2Set size, title and options
3Copy the code into your page

Sandbox permissions — the frame is restricted unless you allow:

Private by design: 100% in your browser — nothing is uploaded, no sign-up. This tool runs entirely on your device.

How to use this iframe generator

Paste the address of the page you want to embed. For services like YouTube or Google Maps, use the special embed URL they give you rather than the normal page address — those are built for framing and will not be blocked. Set the width and height to suit the content, or tick the responsive option and let the generator wrap the frame in a ratio box so it fits every screen from a wide monitor to a small phone. Add a plain-English title describing what the frame contains, decide on lazy loading, and the code below updates as you type.

The sandbox options deserve a moment of thought. An unsandboxed iframe runs the other site's page with considerable freedom inside yours. Ticking at least one sandbox option switches the restrictions on; then each "allow" you add gives one permission back. Start strict, preview the embed, and add permissions only until it works — a video player typically needs scripts and same-origin, a map needs nothing at all.

Example: embedding a video

With the default values on this page (a YouTube embed URL, 560 by 315, lazy loading on, full screen allowed, no sandbox), the generator produces:

<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" width="560" height="315" style="border:0" title="Embedded video player" loading="lazy" allowfullscreen></iframe>

Tick the responsive box with the same numbers and the output changes shape: the width and height become the 16:9 ratio of a wrapper box, so the same video stretches to the full width of a phone screen and shrinks neatly on a desktop sidebar — no separate mobile code needed.

Why some sites refuse to be embedded

If your frame comes up blank, the problem is almost never your code. A website can tell browsers "never show me inside another site" by sending an X-Frame-Options header or a frame-ancestors rule, and browsers obey it. Banks, payment pages, social networks and most big platforms do this to stop clickjacking — tricking people into clicking on a disguised page. There is no legitimate workaround from the embedding side; the honest fix is to link to the page instead, or use an official embed or API the service offers. Before blaming the generator, test the same URL in a fresh browser tab: if it loads there but not in the frame, framing is blocked.

Getting the size right

The most common iframe mistake is a fixed desktop size on a page most visitors open on phones, where the frame either overflows sideways or leaves a tiny, unusable window. Responsive mode exists precisely to prevent that: it preserves the proportions you chose while letting the width follow the screen. Choose proportions that match the content — 16:9 for video, squarer shapes for forms and calendars, and a wide, shorter strip for maps. Height matters too: an embedded form cut off mid-way, with its submit button trapped inside an internal scrollbar, converts terribly. Give forms and documents generous height, or embed them responsively and test on a real phone before publishing.

Security habits for anything you embed

An iframe is a window into someone else's website, and like any window it deserves a frame you control. Three habits keep embeds safe. First, only embed addresses you trust, over HTTPS — an embedded HTTP page inside your HTTPS site will be blocked by the browser as mixed content, and rightly so. Second, use the sandbox options whenever the embed allows it; they exist so that a compromised or careless embedded page cannot redirect your visitors, open pop-ups over your content, or submit forms in your name. Third, review embeds occasionally. The page you framed last year is run by someone else, and its content, owners and behaviour can change without telling you. A quarterly check — does it still load, still show what you intended, still deserve your visitors' trust — takes minutes. If an embed stops being trustworthy, the fix is simple: remove the frame and link instead.

Frequently asked questions

How do I use the generated iframe code?

Copy the code and paste it into your page's HTML where the embedded content should appear. In WordPress, use a Custom HTML block; in a website builder, use its embed or HTML element. The embedded page loads inside the frame as soon as a visitor opens your page (or when it scrolls into view, if lazy loading is on).

Why does my iframe show a blank page or an error?

Most websites can be embedded, but some block it deliberately with an X-Frame-Options or frame-ancestors header — banks, social networks and many large platforms do this for security. If the frame is blank and the URL works in a normal tab, the site is almost certainly blocking embedding, and no code change on your side can override that.

What does the responsive option do?

It wraps the iframe in a container that keeps the same proportions at every screen width, using your width and height as the ratio — 560 by 315 gives the standard 16:9 video shape. The embed then fills the width of a phone screen and scales down gracefully instead of overflowing or staying fixed at desktop size.

What is the sandbox attribute for?

Sandboxing restricts what the embedded page may do: by default a sandboxed frame cannot run scripts, submit forms, open pop-ups or navigate your page. Each allow option you tick lifts one restriction. Use it when embedding content you do not fully control, and only allow what the embed genuinely needs — a map needs none of them, a video player usually needs allow-scripts and allow-same-origin.

Why should I add a title to an iframe?

Screen readers announce the title so blind visitors know what the frame contains, and accessibility checkers and some validators flag title-less iframes. Write a short description of the content, such as 'Booking calendar' or 'Product demo video' — not 'iframe' or the raw URL.

Does lazy loading help my page speed?

Yes, for embeds below the fold. loading="lazy" tells the browser to postpone loading the frame until the visitor scrolls near it, so the rest of your page renders faster. Do not lazy-load an embed that is visible immediately at the top of the page — it delays the very content the visitor came for.

Can I embed a YouTube video or Google Map with this?

Yes, as long as you use the embed URL those services provide (for YouTube, the youtube.com/embed/… address; for Maps, the URL from Share → Embed a map). Both are designed for iframes and allow embedding. This generator then adds your sizing, title and loading choices around them.

Is it legal to embed another website in mine?

Embedding is a normal, intended use of the web for content offered with an embed option, but the embedded page's terms still apply, and content that blocks framing will simply not load. Do not embed someone else's work in a way that presents it as your own, and respect paywalls — a frame is not a way around them, and most paywalled sites block framing anyway.

What size should my iframe be?

Match the content: 560 by 315 (16:9) for video, taller shapes like 800 by 600 for documents and forms, and full-width responsive mode for maps and booking widgets. If in doubt, choose responsive mode — a fixed-size frame is the most common cause of embeds that look broken on phones.

Related tools