Conversions·Free · No signup required

YouTube Embed Code Generator

Free YouTube embed code generator. Paste any YouTube URL and get a clean responsive iframe with autoplay, mute, loop, captions, and start-time options.

  • Embed a tutorial video into a blog post with autoplay muted on scroll-into-view.
  • Drop a product demo onto a landing page that loops silently as a hero asset.
  • Cue a long talk to a specific timestamp without forcing readers to scrub.
  • Hide YouTube branding and the related-videos overlay on a marketing page.
  • Generate an embed for a YouTube Short or a custom-start-time clip.

Detected video ID: dQw4w9WgXcQ

Live preview

Embed code

<div style="position:relative;padding-top:56.25%;max-width:560px;margin:0 auto;">
  <iframe
    src="https://www.youtube.com/embed/dQw4w9WgXcQ?modestbranding=1&rel=0"
    title="YouTube video player"
    style="position:absolute;top:0;left:0;width:100%;height:100%;border:0;"
    allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
    referrerpolicy="strict-origin-when-cross-origin"
    allowfullscreen
  ></iframe>
</div>

The wrapper div uses the standard 16:9 padding-top hack so the embed scales fluidly on every viewport. The fixed width acts as the maximum size; the iframe shrinks below that. Output runs in your browser; we do not call any YouTube API and your URL is never sent to a server.

What is a YouTube embed code generator?

A YouTube embed code generator turns a video URL into a clean responsive iframe with the parameters you choose - autoplay, mute, loop, captions, start time, branding. The output is the exact HTML snippet you paste into a blog post, landing page, or MDX file. The generator on this page builds the iframe directly from any youtube.com, youtu.be, embed, or shorts URL, with no API key, no signup, and no third-party redirect.

How YouTube embed parameters actually work

YouTube's iframe player accepts a fixed set of query parameters appended to the embed URL. Each parameter toggles a single behaviour. The generator wires them up correctly, including the dependent params most by-hand embeds get wrong (looping needs playlist; autoplay needs mute).

From YouTube URL to a responsive iframe: parse the video ID, append parameters, wrap in a 16:9 containerA three-step pipeline diagram. Step one: parse the video ID from the URL using regex. Step two: assemble the embed URL with chosen parameters (autoplay, mute, loop with playlist, start time, controls, captions, branding). Step three: wrap the iframe in a div with a 56.25% padding-top trick to preserve the 16:9 aspect ratio responsively.1 · PARSE URLyoutube.com/watch?v=VIDEO_ID2 · BUILD IFRAME SRC/embed/VIDEO_ID?autoplay=1&m…ute=1&start=423 · WRAP RESPONSIVE<div padding-top:56.25%><ifr…ame …></div>
Three steps from a pasted URL to a production-ready embed: ID extraction, parameter assembly, responsive wrapper. The generator handles all three; the "copy iframe code from YouTube" share menu only handles step two.
  • autoplay=1 needs mute=1. Browsers block autoplay with sound by default. The generator warns you in the option label.
  • loop=1 needs playlist=VIDEO_ID. YouTube only loops when a playlist is set; the generator adds the playlist param automatically.
  • start=42 sets the start time in seconds. The generator extracts ?t=42 or &t=1m30s from the URL automatically and populates the start field.
  • rel=0 hides related videos. Critical for landing pages where you do not want viewers falling off into a competitor video at the end.
  • modestbranding=1 hides the YouTube watermark. Removes the YouTube logo from the lower-right control bar.
  • cc_load_policy=1 shows captions by default. Honours the viewer's preferred caption language when available.

How to use the YouTube embed code generator

  1. Paste a YouTube URL. Any youtube.com/watch, youtu.be, embed, or shorts URL works. Start-time params (?t=42, &t=1m30s) are detected automatically.
  2. Pick your embed options. Choose width and height, autoplay, mute, loop, captions, controls, modest branding, and related-video suppression. The output updates on every change.
  3. Preview the embed live. The tool renders the actual iframe inline so you see the exact behaviour before copying. The preview honours every parameter you toggle.
  4. Copy the iframe code. One click puts the responsive iframe HTML on your clipboard, including the wrapper div needed for mobile aspect-ratio preservation.
  5. Paste into your page. The output works in any HTML surface: blog post, landing page, MDX, Notion, Webflow, WordPress, Ghost. The wrapper div keeps the 16:9 ratio on every viewport.

Why use our YouTube embed code generator

  • Live preview, not just code. The actual iframe renders inline so you see autoplay, mute, and start time work before copying.
  • Dependent parameters wired correctly. Loop adds the required playlist param. Autoplay warns you if mute is off. Most by-hand embeds break on at least one of these.
  • Responsive wrapper included. The output uses the standard 16:9 padding-top hack so the embed scales fluidly on every viewport.
  • Shorts and start times detected. Paste a Shorts URL and the dimensions flip to portrait. Paste a URL with ?t=42 and the start field fills.
  • No API call, no signup. Pure browser-side regex + string build. Your URLs are never logged or sent anywhere.

Best practices for embedding YouTube

  • Hide the YouTube logo and related videos on landing pages. Both modestbranding=1 and rel=0keep viewer attention on your CTA instead of falling off into a competitor video.
  • Mute autoplay or do not autoplay. Sound-on autoplay is universally blocked by browsers and universally hated by users. Either pair autoplay with mute, or wait for a click.
  • Use the privacy-enhanced domain on EU-facing pages. For EU GDPR compliance you may want to swap youtube.com/embed for youtube-nocookie.com/embed in the generated HTML. The parameter API is identical.
  • Lazy-load embeds below the fold. Add loading="lazy" to the iframe in your CMS for embeds that are not above the fold. The cost of an autoloaded YouTube iframe is roughly 500 KB per embed.
  • Keep one embed per fold on mobile. Multiple iframes compound the JS weight. A single embed plus a thumbnail-link to a second video is cheaper for INP.

Examples: real URLs to real embeds

Tutorial cued to 0:42
Input:  https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=42s
Output: <iframe src=".../embed/dQw4w9WgXcQ?start=42&modestbranding=1&rel=0">

The start parameter cues the video at 42 seconds without forcing the viewer to scrub.

Hero video with silent autoplay loop
Options: autoplay + mute + loop + no controls + hide branding
Output:  src=".../embed/ID?autoplay=1&mute=1&loop=1&playlist=ID&controls=0&modestbranding=1&rel=0"

Standard hero-video pattern: silent loop, no controls, no branding. The playlist parameter is required for loop to actually work.

YouTube Short in portrait
Input:  https://www.youtube.com/shorts/abc123
Result: 315×560 portrait embed, controls visible

The tool detects the Shorts URL pattern and flips the default dimensions to portrait so the embed renders correctly without manual sizing.

Frequently asked questions

What YouTube URL formats does the generator accept?

All five common forms: standard youtube.com/watch?v=ID, the shortened youtu.be/ID, the canonical embed URL youtube.com/embed/ID, the Shorts URL youtube.com/shorts/ID, and any of those with a start-time parameter (?t=42 or &t=1m30s). The video ID is extracted automatically.

Why does autoplay only work when mute is on?

All major browsers (Chrome, Safari, Firefox) block autoplay with sound by default to protect the user. The autoplay parameter only fires if the video starts muted. The tool surfaces this dependency in the option label so you do not ship a 'broken' autoplay embed.

How does the loop option work?

YouTube's loop parameter only triggers when the iframe also includes playlist=VIDEO_ID. The generator adds that automatically when you toggle loop on, so the embed actually replays on end instead of stopping silently.

Is the generated embed responsive?

Yes. The output wraps the iframe in a position:relative div with a 56.25% padding-top trick (the standard 16:9 aspect-ratio hack) so the embed scales fluidly on every viewport. The fixed width and height attributes you set are overridden by the wrapper.

Will the embed work without a YouTube account?

Yes. Embeds use YouTube's public iframe player. No sign-in is required to view, no API key is needed to generate. The tool runs entirely in your browser.

Can I embed YouTube Shorts?

Yes. Paste any youtube.com/shorts/ID URL and the tool generates a portrait-oriented embed by default (315×560). Adjust the width/height inputs if you need a different ratio.

YouTube Embed Code Generator: Paste a YouTube URL, pick autoplay / mute / loop / start time / captions, copy a clean responsive iframe ready to paste into any blog or landing page.
YouTube Embed Code Generator - a free SocialCRM tool. Share the card or copy the link below.
Maintained by the SocialCRM team · Last audited Version 1.0.0

Background and tactics that go deeper than this tool's surface.