YouTube Embed Code
Generator
Generate custom responsive YouTube iframe embed codes in seconds — with full control over autoplay, loop, mute, start time, privacy mode, and more. No signup required.
Customize your embed
Adjust dimensions, playback behavior, and privacy settings below — your code and preview update instantly.
<!-- Paste a YouTube URL above to generate your embed code -->
Everything you need to embed YouTube videos
The most complete free YouTube embed generator — built for developers, bloggers, and marketers who need full control over their video embeds.
youtube-nocookie.com — YouTube sets no cookies until the visitor actually clicks play. Essential for GDPR compliance.Embed a YouTube video in 3 steps
No coding knowledge needed. Works with any website, WordPress, Webflow, Wix, Squarespace, or plain HTML.
youtube.com/watch?v=, youtu.be/, or just the video ID.How to make a YouTube embed responsive
By default, YouTube iframes have fixed pixel dimensions. On mobile devices, this causes the video to overflow or be cut off. The Responsive toggle in this generator wraps your iframe in a CSS container:
- The wrapper uses
padding-bottom: 56.25%(for 16:9) to maintain aspect ratio - The iframe inside is absolutely positioned to fill the container
- The result scales perfectly from 320px mobile to 4K desktop
WordPress tip
In the Gutenberg editor, add a Custom HTML block and paste the full embed code. For the Classic editor, switch to the HTML tab before pasting.
What does youtube-nocookie.com do?
When you use youtube-nocookie.com instead of youtube.com in your embed URL, YouTube does not set any tracking cookies on your visitor's browser until they actually click play. This is important if your site has European visitors and you want to stay compliant with GDPR without a complex cookie consent setup just for embedded videos.
Frequently asked questions
Everything you need to know about YouTube embed codes.
The complete guide to YouTube embed codes
Embedding YouTube videos on your website is one of the most effective ways to enrich your content without increasing your hosting costs. Instead of uploading video files to your own server, you let YouTube handle the delivery — giving you access to YouTube's global CDN, adaptive bitrate streaming, and automatic format optimisation for free.
Understanding the YouTube embed URL structure
A standard YouTube embed URL looks like this:
https://www.youtube-nocookie.com/embed/VIDEO_ID?rel=0&autoplay=1&mute=1
The part after the ? is the query string, where parameters control behaviour. Common parameters include:
- autoplay=1 — starts playing on load (requires mute=1 in modern browsers)
- mute=1 — starts with sound off
- loop=1 — repeats the video (also requires playlist=VIDEO_ID for single videos)
- controls=0 — hides the player control bar
- rel=0 — shows only related videos from the same channel at end
- start=30 — begins playback at 30 seconds
- end=120 — stops playback at 120 seconds
- fs=0 — hides the fullscreen button
- modestbranding=1 — removes the YouTube logo from the control bar
Responsive YouTube embeds: the CSS technique
The standard approach to making a YouTube embed responsive is the aspect-ratio padding trick. Here is what the generated responsive code looks like:
.video-responsive { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; }
56.25% is simply 9 ÷ 16 — the height as a percentage of width for a 16:9 video. For 4:3 video, use 75%. The iframe inside is then positioned absolutely to fill this container exactly. Modern browsers also support the CSS aspect-ratio property as an alternative approach.
YouTube embeds and page speed
Embedding YouTube videos can slow your page because the YouTube player loads several megabytes of JavaScript even if the visitor never plays the video. Advanced techniques to solve this include using a poster image with a play button overlay, and only loading the YouTube iframe when the visitor clicks — this is called a "lazy YouTube embed" or "facade pattern" and is recommended by Google's Lighthouse performance tool.
Embedding YouTube videos in WordPress
In the Gutenberg block editor (WordPress 5+), add a Custom HTML block and paste your generated embed code. Do not use the standard Video or YouTube block if you need custom parameters — those blocks do not support advanced options like nocookie mode or start times. In the Classic Editor, switch the editor to Text mode and paste the code there; never paste embed code in the Visual editor.
