YouTube Embed Code Generator

Paste a video URL or ID, get a correct embed snippet

Preview

Paste a valid video URL or ID above to see a live preview.

Embed HTML

-
Runs entirely in your browser, the video ID is parsed locally and never sent anywhere.

About this tool

This tool parses the video ID out of a standard watch?v= URL, a short youtu.be/ link, a /shorts/ link, or accepts a raw 11-character video ID directly, then builds the exact <iframe> embed HTML YouTube itself recommends, including autoplay, start time and privacy-enhanced mode query parameters when you turn them on. Nothing is sent to a server; the parsing and preview happen entirely in your browser.

How to use it

  1. Paste any YouTube video URL, or just the 11-character video ID.
  2. Pick a size preset or enter a custom width/height.
  3. Toggle autoplay, set a start time, or enable privacy-enhanced mode as needed.
  4. Check the live preview, then copy the generated HTML into your page.

Tips: most browsers block autoplay with sound, so an autoplaying embed will typically start muted unless the visitor has already interacted with your site. Privacy-enhanced mode avoids setting YouTube cookies until the viewer actually plays the video.

Which URL formats does this support?

Standard youtube.com/watch?v=ID links, short youtu.be/ID links, /shorts/ID links, and a raw 11-character video ID pasted directly all work.

What does privacy-enhanced mode actually change?

It swaps the embed domain to youtube-nocookie.com, which YouTube documents as not storing information about visitors on your page unless they actually click play.

Why isn't autoplay working with sound?

This is a browser restriction, not a bug in the embed code, most modern browsers block autoplaying video with sound unless the user has already interacted with the page, so autoplaying embeds usually start muted.

What happens if I paste an invalid URL?

The tool shows a clear error and doesn't generate a broken embed, it only produces HTML once it has successfully parsed a valid-looking 11-character video ID.

Is the video ID sent to any server?

No, parsing, preview rendering and HTML generation all happen locally in your browser using plain JavaScript.