Music Code Generator
Paste a Spotify, YouTube, or SoundCloud share URL and get a ready-to-paste iframe embed code — adjust width, height, and autoplay settings, then copy the HTML.
Last updated: May 26, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is Music Code Generator?
All three major music platforms provide official iframe embeds that display a player widget directly on your web page. Spotify offers embeds for tracks, albums, playlists, and podcasts. YouTube embeds play music videos. SoundCloud embeds play individual tracks. Each platform has a slightly different iframe format with different `allow` attributes and query parameters.
This generator detects the platform from the share URL you paste, fills in the correct embed URL format, and outputs the complete iframe tag you can drop into any HTML page. The live preview lets you see exactly how the player will look before you copy the code.
Note that browser autoplay restrictions may prevent audio from starting automatically even when the autoplay option is enabled — this is a browser-level security policy, not a limitation of the embed code.
How to Use Music Code Generator
Copy a share URL from Spotify, YouTube, or SoundCloud (e.g. from the Share menu on a track page).
Paste it into the URL field — the platform is detected automatically.
Adjust the width and height if needed (defaults are the platform's recommended sizes).
Toggle autoplay or Spotify dark theme as needed.
Click "Show Preview" to verify the player looks correct.
Click Copy and paste the embed code into your HTML page.
Common Use Cases
- Adding a Spotify track player to a blog post or artist portfolio.
- Embedding a YouTube music video in a website without navigating away.
- Showcasing SoundCloud tracks on a personal music page or press kit.
- Building a playlist or mixtape page with multiple embedded players.
- Adding a background soundtrack widget to an event landing page.
Example Input and Output
A Spotify track URL converts to a ready-to-use Spotify embed iframe.
https://open.spotify.com/track/4iV5W9uYEdYUVa79Axb7Rh<iframe src="https://open.spotify.com/embed/track/4iV5W9uYEdYUVa79Axb7Rh" width="100%" height="352" frameborder="0" allowtransparency="true" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>Privacy
The embed code is generated in your browser. No URL is sent to our servers. When visitors load the embedded player on your page, they connect directly to Spotify, YouTube, or SoundCloud — those platforms may set cookies.
GDPR / cookie consent
Embedding music from third-party platforms loads their scripts and may set tracking cookies. Consider adding a cookie consent notice or lazy-loading the iframe so it only loads after the user accepts.
Responsive embeds
Set width to 100% and wrap the iframe in a container with a fixed height for a responsive embed that fills its parent width.

