YouTube's "Share" then "Embed" button gives you iframe code with a fixed width of 560 and height of 315, so the video looks small on a computer or spills past a phone screen. Jood's YouTube Embed Code Generator gives you responsive code that fills the width of wherever you put it and keeps the video's proportions, with the playback options you need.
How to use it
Paste the link in the "YouTube Video URL" box. Normal links, short links and Shorts links all work.
To start at a given moment, fill in "Start Time (Seconds)", and if needed "End time (in seconds, optional)". Two and a half minutes is 150 seconds.
Pick the "Aspect Ratio": 16:9 for a regular video, 9:16 for Shorts, or 4:3 and 1:1.
Tick the options you want and click "Start Now". A preview of the video appears with the code below it; copy it with the "Copy Result" button.
What the options do
Show player controls: ticked by default. Untick it and the playback bar disappears, which suits a short background clip better than a tutorial.
Autoplay: browsers block video with sound until the visitor clicks, so the tool mutes the video with this option; otherwise it would not start.
Mute: the video starts silent and the visitor turns the sound up.
Loop the video: it starts over when it ends. YouTube needs a playlist for this, so the tool adds the video itself as a one-item playlist.
Privacy mode: uses the youtube-nocookie.com domain. According to YouTube, the embedded video is not used to personalise the visitor's recommendations, and no cookies are stored until they press play. Handy if your site asks visitors to consent to cookies.
Why the code works anywhere
The code puts the iframe in a box that is 100% wide, with its proportions fixed by the CSS property aspect-ratio. No library or stylesheet is needed, so it works in a WordPress Custom HTML block, in Blogger or in a page you write by hand. A 9:16 video stays at most 360 pixels wide and centred, so it does not take over the height of a computer screen. The iframe only loads when the visitor gets close to it, so it does not slow down the first view of the page. That also means an autoplay video near the bottom of a page starts when the visitor reaches it.
Before you publish
The video's owner can switch off embedding, in which case an error message shows instead of the video. Check the preview before publishing.
Embedding does not copy the video to your server: it stays on YouTube and the views count for the owner's channel.
We use cookies to measure traffic and improve the site (Google Analytics), and may show ads later. Nothing is enabled without your consent. Privacy policy