WebToolsPlanet
Developer Tools

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

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What 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

1

Copy a share URL from Spotify, YouTube, or SoundCloud (e.g. from the Share menu on a track page).

2

Paste it into the URL field — the platform is detected automatically.

3

Adjust the width and height if needed (defaults are the platform's recommended sizes).

4

Toggle autoplay or Spotify dark theme as needed.

5

Click "Show Preview" to verify the player looks correct.

6

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.

Spotify share URL
https://open.spotify.com/track/4iV5W9uYEdYUVa79Axb7Rh
Generated embed code
<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.

Frequently Asked Questions

Which Spotify content types are supported?
Tracks, albums, playlists, episodes, shows, and artists. Paste any open.spotify.com share URL and the tool extracts the type and ID automatically.
Why does autoplay not work on my page?
Modern browsers block audio autoplay unless the user has previously interacted with the page. The autoplay attribute in the embed code requests autoplay, but the browser can silently ignore it. This is a browser policy, not a bug in the generated code.
Does this work for private Spotify content?
No. The Spotify embed player only works for public tracks, albums, and playlists. Private content requires authentication.
Is the preview real?
Yes — the preview renders the actual platform iframe, so it plays the real content. You may need to be logged in to Spotify to hear the full track (free accounts get 30-second previews without login).